MySQL UPDATE By SELECT

Posted on Friday, April 30, 2010 in MySQL

UPDATE by SELECT example:

UPDATE [table0_name] AS T0, [table1_name] AS T1
SET T0.[field0_name]=T1.[field1_name]
WHERE T0.[field0_id]=T1.[field1_id]

Ubuntu Number of Files in Directory

Posted on Thursday, April 29, 2010 in Linux

#ls | wc -l

Ubuntu Save Alias

Posted on Thursday, April 29, 2010 in Linux

Ubuntu (9.04) Edit /etc/bash.bashrc
Add alias lines:
alias z='ls -l'
Logout/login to save/use

Ubuntu Symbolic Link

Posted on Thursday, April 29, 2010 in Linux

ln -s
From /var/www/example2:

#ln -s /var/www/example/httpdocs httpdocs

To remove link, delete directory/file

Disabling open_basedir Restriction

Posted on Thursday, April 29, 2010 in Linux

<Directory /var/www/vhosts/example_2.com/httpdocs>
php_admin_value open_basedir "/var/www/vhosts/example_2.com/
httpdocs:/var/www/vhosts/example.com/httpdocs:/tmp"
</Directory>

ORDER BY IN Value

Posted on Tuesday, April 20, 2010 in MySQL

Query will order results by newest tasks first with exception that any task 100% complete will be displayed last
SELECT *
FROM tasks
ORDER BY task_percent_complete IN(100) ASC, task_datetime DESC

Add Ubuntu Directory Index

Posted on Tuesday, April 20, 2010 in Linux

Add directory index to:
/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>
 DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

Ubuntu Logrotate

Posted on Monday, April 19, 2010 in Linux

Create logrotate file /etc/logrotate.d/example
/var/log/webserver/barsupply.log {
daily
rotate 7
missingok
compress
notifempty
#olddir will change log archive directory (not required)
olddir /var/log/example/archive
}

Register logrotate file:
#logrotate -f /etc/logrotate.d/example

View file status in logrotate:
/var/lib/logrotate/status

Apache2 Custom php.ini

Posted on Monday, April 19, 2010 in Linux

<VirtualHost 0.0.0.0:80>
[...]
PHPINIDir /var/www/example/config
[...]
</VirtualHost>

Unicode data in a Unicode-only collation

Posted on Thursday, April 15, 2010 in Linux, PHP

PHP Error on MSSQL query:
Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library

Edit /etc/freetds/freetds.conf (Ubuntu)
uncomment line:
;tds version = 4.2
and change to:
tds version = 8.0