PHPºÍMYSQLµÄ±àÂëÎÊÌâ
1 MYSQLÖеÄ×Ö·û¼¯¸ÅÄî
MysqlµÄ×Ö·û¼¯ÀïÓÐÁ½¸ö¸ÅÄһ¸öÊÇ"Character set£¨×Ö·û¼¯£©"£¬ÁíÒ»¸öÊÇ"Collations"¡£
1.1 Collations
Collations·³ÉÖÐÎÄÊÇ"УÑé"£¬ÔÚÍøÒ³¿ª·¢µÄ¹ý³ÌÖУ¬Õâ¸ö´Ê»ã£¬Ö»ÔÚMysqlÀïʹÓã¬Ö÷Òª×÷ÓÃÊÇÖ¸µ¼Mysql¶Ô×Ö·ûµÄ±È½Ï£¬±ÈÈ磬 ASCII×Ö·û¼¯ÀCollations¹æ¶¨ÁËaСÓÚb£¬aµÈÓÚa£¬ÒÔ¼°aÊÇ·ñµÈÓÚAÖ®ÀàµÄ¡£Í¨³££¬´ó¼Ò»ù±¾¿ÉÒÔºöÂÔCollationsµÄ´æÔÚ£¬ÒòΪÿ¸ö×Ö·û¼¯¶¼ÓÐÒ»¸öĬÈϵÄCollations£¬Í¨³££¬Ê¹ÓÃĬÈϵÄCollations¾Í¿ÉÒÔÁË¡£
1.2 Character set
ÓëÕâ¶Ô±ÈµÄÊÇ£¬×Ö·û¼¯ÊǸö¸ü¹ãµÄ¸ÅÄ¼´Ê¹ÊÇWindowsÏÂÆÕͨµÄÎı¾Îļþ£¬Ò²Éø¼°µ½×Ö·û¼¯µÄÎÊÌâ¡£²»Í¬µÄ×Ö·û¼¯£¬¹æ¶¨Á˲»Í¬µÄ×Ö·ûµÄ±àÂ뷽ʽ¡£Ò»¸ö character set (×Ö·û¼¯)ÊÇÒ»×é·ûºÅºÍ±àÂ룬±ÈÈ磬ASCII×Ö·û¼¯£¬°üÀ¨µÄ×Ö·ûÓУºÊý×Ö£¬´óСд×Öĸ£¬·ÖºÅ¡¢»»ÐÐÖ®ÀàµÄ·ûºÅ£¬±àÂ뷽ʽÊÇÓÃÒ»¸ö7bit±íʾһ¸ö×Ö·û£¨AµÄ±àÂëÊÇ65£¬bµÄ±àÂëÊÇ98£©¡£ASCIIÖ»¹æ¶¨ÁËÓ¢ÎÄ×ÖĸµÄ±àÂ룬·ÇÓ¢ÎÄÓïÑÔ²»ÄÜÓÃASCII±àÂë±íʾ£¬Îª´Ë£¬²»Í¬µÄ¹ú¼Ò£¬¶¼Îª×Ô¼ºµÄÓïÑÔ×öÁ˱àÂ룬±ÈÈ磬ÎÒÃǹú¼Ò£¬¾ÍÓÐGB2312±àÂë¡£µ«Ã¿¸ö¹ú¼ÒÖ®¼äµÄ±àÂ벻ͬ£¬Ò²´æÔÚ×ÅһЩ¿çƽ̨µÄÎÊÌ⣬Ϊ´Ë£¬Ò»Ð©¹ú¼Ê»¯±ê×¼×éÖ¯£¬¾ÍÖƶ¨ÁËһЩ¹ú¼ÊͨÓõıàÂ룬×î³£ÓõľÍÊÇUTF8ÁË¡£ASCIIÖ»¶ÔÓ¢ÎÄ·ûºÅºÍÓ¢ÎÄ×Öĸ×öÁ˱àÂ룬GB2312¶ÔÓ¢ÎÄ·ûºÅ£¬Ó¢ÎÄ×Öĸ£¬ºº×Ö×öÁ˱àÂ룬UTF8¶ÔÊÀ½çÉÏËùÓеÄÓïÑÔÎÄ×Ö×öÁ˱àÂ룬ËùÒÔ£¬GB1212µÄ×Ö·û°üº¬ÁËASCII×Ö·û£¬UTF8°üº¬ÁËGB2312×Ö·û¡£Óɴ˿ɼû£¬UTF8ÊÇËùº¬×î¹ã×Ö·ûµÄ×Ö·û¼¯£¬ËùÒÔ£¬ÔÚһЩ¶àÓïÑÔµÄWEBϵͳÖУ¬Ò»°ãÓÃUTF8×Ö·û¼¯£¨PHPMyAdminʹÓÃUTF8±àÂ룩¡£
ÈκÎÎı¾µÄ´æ´¢£¬¶¼Éø¼°µ½×Ö·û¼¯µÄ¸ÅÄî¡£°üÀ¨Êý¾Ý¿â£¬Ò²°üÀ¨ÆÕͨµÄÎı¾Îļþ¡£
±àÂëºÍ×Ö·û¼¯Á½¸ö¸ÅÄÒ×»ìÏý£¬ÒòΪһ°ãÇé¿öÏ£¬±àÂëµÄÃû×ÖºÍ×Ö·û¼¯µÄÃû×ÖÏàͬ£¬È磺GB2312¼ÈÊÇÒ»ÖÖ×Ö·û¼¯µÄÃû×Ö£¬Ò²ÊÇÒ»ÖÖ±àÂë¸ñʽµÄÃû×Ö¡£
×Ö·û£ººº×Ö£¬Ó¢ÎÄ×Öĸ£¬±êµã·ûºÅ£¬À¶¡Îĵȵȡ£
±àÂ룺½«×Ö·ûת»»³É¼ÆËã»ú´æ´¢µÄ¸ñʽ£¬±ÈÈ磬AÓÃ65±íʾ¡£
×Ö·û¼¯£ºÒ»×é×Ö·ûÒÔ¼°¶ÔÓ¦µÄ±àÂ뷽ʽ¡£
¿É¼û×Ö·û¼¯ºÍ±àÂëÊÇÁ½¸ö²»Í¬µÄ¸ÅÄî¡£Ò»¸ö×Ö·û¼¯¿ÉÒÔÓжàÖÖ±àÂ뷽ʽ£¬ÈçUnicode×Ö·û¼¯¾ÍÓÐUTF-8¡¢UTF-16¡¢UTF-32µÈ±àÂ뷽ʽ¡£
charset=utf-8£¬ÔÚÍøÒ³ÖеÄÒâ˼ÊǸÃÒ³Ãæʱ²ÉÓÃUnicode×Ö·û¼¯£¬²¢²ÉÓÃUTF-8±àÂ뷽ʽ¡£
1.3 MysqlµÄ×Ö·û¼¯
MysqlÄ¿Ç°Ö§³Ö¶à×Ö·û¼¯£¬²¢ÇÒ£¬Ö§³ÖÔÚ²»Í¬µÄ×Ö·û¼¯Ö®¼äת»»£¨±ãÓÚ
Ïà¹ØÎĵµ£º
Ô¶³ÌÁ¬½ÓÁíһ̨µçÄÔµÄmysqlµÄÊý¾Ý¿âʱ£¬Èç¹ûÁ¬½Ó²»ÉÏ£¬Õâʱºò¾ÍÒªÔÚ±»Á¬½ÓµÄµçÄÔÉÏÖ´ÐÐÒÔÏÂÃüÁ
ÔÒò£ºÊÇûÓиøµÇ¼Óû§ÃûÉèÖÃÔ¶³ÌÖ÷»úµÇ¼µÄȨÏÞ
1¡£µÇ¼mysql £º
Ö´ÐУºmysql -u root -p
2¡£ÐÞ¸Ä MySQL Êý¾Ý¿âÖÐ user ±íÖÐ ¶ÔÓ¦Óû§ÃûµÄ Host ×ֶΣ¬½« localhost ¸ÄΪ %
Ö´ÐУºuse mysql;
ÔÙÖ´ÐУºupd ......
1. Êý¾Ý¿â
Çл»Êý¾Ý¿â£º use mydb
2. ʼþ
²é¿´Ê¼þ£º show events
Æô¶¯µ÷¶ÈÆ÷: set global event_scheduer = 1;
²é¿´ÊÇ·ñÆô¶¯£º show variables like 'event_scheduler';
3. ±¸·Ý
ÔÚadministatorÖеÄbackupÖÐÎÞ·¨±¸·ÝÊý¾Ý¿âµÄʼþ¡£ÐèÒªÊÖ¶¯½«´´½¨Ê¼þµÄ½Å±¾Ìí¼Óµ½sql±¸ ......
Èí¼þ°æ±¾:
php-5.2.13-Win32
apache_2.2.9-win32-x86-no_ssl-r2.msi(×¢Ò⣺APACHE 2.2.X°æ±¾ÒÔÉÏÒªÔö¼Ó²å¼þ²ÅÖ§³ÖPHP 5µÄ)
mysql-5.1.44-win32.msi
ÏÈ×°µÄphp5,Ö±½Ó½âѹÎļþµ½C:\php(°²×°µ½ÄÄÀï²¢²»»áÓÐÓ°Ï죬ƾ¸öÈËϲºÅ£¬±¾ÎÄÖеÄËùÓз¾¶¶¼ÒÔÎҵݲװ·¾¶£¬Çë´ó¼ÒÔÚ×Ô¼ºµÄ»úÆ÷ÉÏ°²×°µÄʱºò×¢ÒâÐÞ¸ÄΪ×Ô¼ºµÄ·¾¶)
½Ó× ......
°²×°»·¾³£ºVMware Workstation 5.5.0 build-18463
Linux°æ±¾£ºRed Hat Enterprise Linux AS (2.6.9-42.EL)
Èí¼þ°æ±¾£ºMySQL5 - mysql-5.0.37.tar.gz
¡¡¡¡¡¡¡¡¡¡Apache2 - httpd-2.2.4.tar.gz
¡¡¡¡¡¡¡¡¡¡PHP5 - php-5.2.1.tar.gz
¡¡¡¡¡¡¡¡¡¡(½«ÒÔÉÏÎļþ±£´æÖÁ/home/tmpĿ¼)
[MySQL]
# cd /home/tmp (½øÈëѹËõ°ü ......
1 <?php
2 $doc = new DOMDocument('1.0', 'utf-8');
3 $doc->load('./articles.xml');
4
5 $xpath = new DOMXPath($doc);
6 /*
7 * $xpath = domxml_open_file("articles.xml");
8 */
......