Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Benoit Asselin http://www.ab-d.fr

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Copy MySQL table

CREATE TABLE table_destination SELECT * FROM table_source ;


CREATE TABLE table_destination LIKE table_source ;
INSERT INTO table_destination SELECT * FROM table_source ;


Source: Asselin Benoit Development ( MySQL, SQL ) & Agence ici, agence de communication

Regular Expressions with MySQL

SELECT * FROM texts WHERE content REGEXP '[^a-z]Hello[^a-z]' ;


If you really want to force a REGEXP comparison to be case sensitive, use the BINARY keyword to make one of the strings a binary string.
SELECT * FROM texts WHERE content REGEXP BINARY '[^a-zA-Z]Hello[^a-zA-Z]' ;


Warning: some characters do not work. Example :
SELECT * FROM texts WHERE content REGEXP '[^\w]Hello[^\w]' ;


ab-d.fr source code

Some problems with charset in UTF-8 ?

So you can use this request MySQL before all others, for fix your problems :
...
mysql_query( "SET NAMES 'utf8' " );
...


Source: ab-d.fr
Languages: PHP and MySQL

Use get_magic_quotes_gpc();

function f_magic_quotes($text) {
	if ( !get_magic_quotes_gpc() ) {
		return addslashes($text);
	} else {
		return $text;
	}
}


function f_clean_quotes($text) {
	if ( !get_magic_quotes_gpc() ) {
		return $text;
	} else {
		return stripslashes($text);
	}
}


Source: ab-d
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS