Archive for the ‘ MySql ’ Category

Add table constraint: UNIQUE

To add a unique contraint for two table fileds, simply execute the following command:

ALTER TABLE scene_commands ADD UNIQUE (scene_id, command_id);

Simple MySql Dump

Not very big script, but it can be helpful if you don’t remember how to write mysqldump

🙂

mysqldump -r /home/job/MyDump.sql mydatabase -u root -p

Forbidden Words

SQL statements which can be dangerous.
I will create an array witch contains all these words and a function to test whether the request contains these words.

$forbidden = array(';','DELETE','DO','INSERT','UPDATE','REPLACE','ALTER','CREATE','DROP','RENAME','DESCRIBE','USE','LOAD');
$tmp_found = false;
foreach ($forbidden as $forbidden_word) {
	if (stristr($_POST['request'],$forbidden_word)) $tmp_found = true;
}