Sunday, December 11, 2011

Compare two columns using like syntax In MYSQL



if you have two tables:
emp (id , name, grad)
grad (id, name)

 and you want to compare column (emp.name and grad.name) with LIKE % use this:

select e.name, g.name 
from emp e inner join grad g 
ON e.grad like CONCAT('%',g.name, '%');

Saturday, December 3, 2011

Good example for CRUD OOP for PHP and MYSQL

By creating a MySQL CRUD class you can easily create, read, update and delete entries in any of your projects, regardless of how the database is designed.

This is good example for CRUD OOP for PHP and MYSQL: 


http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/

Thursday, December 1, 2011

Arabic problem in mysql command line client

To make mysql show arabic in command line use add this command :

mysql -u root -p --default-character-set=utf8

Fix "Can't connect to local MySQL server through socket '/tmp/mysql.sock'"

If you use Zend server or MAMP and when you trying to connect to MySQL and got this error above just check the path to mysql.sock and link it in /tmp/ folder like this:

sudo ln -s /usr/local/zend/mysql/tmp/mysql.sock /tmp/mysql.sock





Sunday, November 20, 2011

How to make FreeBSD radio station web server

I like internet radio station and it`s sound good to have your owen Station 

So i find this site here it will guid you to build a FreeBSD server with radio station.

Good luck :)

Friday, November 18, 2011

Color Mac OSX Terminal Like Gentoo or Other

Edit:
~/.bash_profile
or
~/.profile
 
To set Gentoo-like colors on bash prompt, edit ~/.profile (or /etc/profile for system-wide defaults) and add the following:
if [[ ${EUID} == 0 ]] ; then
       PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' 
else
      PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] ' 
fi

and add the following two lines:
export CLICOLOR=1
 
#Dark blue
#export LSCOLORS=ExFxCxDxBxegedabagacad
 
#Gentoo Color
export LSCOLORS=ExGxFxDxCxDxDxhbhdacEc
 
#Light Blue Color
#export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx

source site here 



Saturday, October 15, 2011

MySQL configuration for Zend Framework

To use MySql database in your zend project u should add the following code to application/configs/application.ini under "[production]":


resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = "USERNAME"
resources.db.params.password = "PASSWORD"
resources.db.params.dbname = "DATABASE_NAME"
// for Arabic or other language you should add this lines below  //
resources.db.params.charset = "utf8"
resources.db.params.driver_options.1002 = "SET NAMES utf8"