25 March 2012

unique combination of multiple columns in mysql


alter table tablename add unique index(column1,column2,column3);

14 March 2012

[mysql ] perform order by column and rand() in single query

SELECT * FROM
(
    SELECT * FROM table1
    ORDER BY nos desc limit 0,1) 
          )  T1 ORDER BY RAND()
 
 
 
 
usage: 
if the column nos is same in multipe rows then fetch a random row..



29 February 2012

How to install the Sun Java JDK on Ubuntu 10.10?

sudo apt-get install python-software-properties

sudo add-apt-repository ppa:sun-java-community-team/sun-java6

sudo apt-get update

sudo apt-get install sun-java6-jdk

30 January 2012

search files in linux server

find /etc -name '*.conf'





/etc is directory or path


*.conf is file name * represents any name.conf files.

install Imagick on CentOS 5.x 32bit

Run the following commands


yum install ImageMagick

yum install ImageMagick-devel

yum install php-pear

pecl install imagick

echo "extension=imagick.so"> /etc/php.d/imagick.ini



service httpd restart

check Imagick is configured corectly by following command.

php -m | grep imagick

this will display output as "Imagick" that means you are Done.

cron job in kloxo/lxAdmin

command php -q /home/username/domain name/path to cron file

know the list of disabled functions on server

<?php
error_reporting(E_ALL);
$disabled_functions = ini_get('disable_functions');
if ($disabled_functions!='')
{
$arr = explode(',', $disabled_functions);
sort($arr);
echo 'Disabled Functions:
';
for ($i=0; $i<count($arr); $i++)
{
echo $i.' - '.$arr[$i].'<br>';
}
}
else
{
echo 'No functions disabled';
}
?>