¼òµ¥µÄPHP²Ù×÷MysqlÀà
<?php
/*
* Ãû³Æ : MySQLÊý¾Ý¿â»ù±¾²Ù×÷
* ×÷Õß : pjx
* °æ±¾ : v 2010/02/25 v 1.0
* ˵Ã÷ : ¸ÃÀàÓÃÓÚ¶ÔMySQL×öһЩ¼òµ¥µÄ²Ù×÷
* ʾÀý £º
* ʵÀý => $db = new DB_MYSQL($database),´ò¸ö$databaseÊý¾Ý¿â
* ²éѯÊý¾Ý¿â => $db->query($sql_str),²éѯ$sql_strÓï¾ä
* »ñµÃÐнá¹û => $db->get_rows_result();
* »ñµÃÐÐÊý => $db->get_rows();
* »ñµÃÁнá¹û => $db->get_files_result();
* »ñµÃÁÐÊý => $db->get_files();
* ÊͷŽá¹û¼¯ => $db->free();
* ²éѯ²¢»ñµÃÐнá¹û(ÐèʵÀý OP_MYSQL($database)) => query_and_get_rows($sql_str);
* ²éѯ²¢»ñµÃÐнá¹û(ÐèʵÀý OP_MYSQL($database)) => query_and_get_files($sql_str);
**/
class DB_MYSQL{
/*
* host : Ö÷»úÃû»òµØÖ·
* db : Êý¾Ý¿â
* user : Êý¾Ý¿âÓû§Ãû
* pw : Êý¾Ý¿âÓû§ÃÜÂë
* */
var $host = "localhost";
var $db = "";
var $user = "root";
var $pw = "";
/*
* link_id : Êý¾Ý¿âÁ¬½ÓµÄid
* query_id : Êý¾Ý¿â²éѯµÄid
* error : Õë¶ÔÓû§µÄ´íÎóÏûÏ¢
* error_mysql : Êý¾Ý¿â·µ»ØµÄ´íÎóÏûÏ¢,Õë¶Ô³ÌÐòÔ±
* rows : ½á¹ûÐÐÊý
* files : ½á¹ûÁÐÊý
* result_rows : Ðнá¹û¼¯
* result_files : Áнá¹û¼¯
*/
var $link_id = 0;
var $query_id = 0;
var $error = "";
var $error_mysql = "";
var $rows = 0;
var $files = 0;
var $result_rows = array();
var $result_files = array();
var $mysql_char = "utf8";
function __construct($d="",$h="",$u="",$p=""){
&
Ïà¹ØÎĵµ£º
1¡¢Ñ¡È¡×îÊÊÓõÄ×Ö¶ÎÊôÐÔ
¡¡¡¡MySQL¿ÉÒԺܺõÄÖ§³Ö´óÊý¾ÝÁ¿µÄ´æÈ¡£¬µ«ÊÇÒ»°ã˵À´£¬Êý¾Ý¿âÖеıíԽС£¬ÔÚËüÉÏÃæÖ´ÐеIJéѯҲ¾Í»áÔ½¿ì¡£Òò´Ë£¬ÔÚ´´½¨±íµÄʱºò£¬ÎªÁË»ñµÃ¸üºÃµÄÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ½«±íÖÐ×ֶεĿí¶ÈÉèµÃ¾¡¿ÉÄÜС¡£ÀýÈ磬ÔÚ¶¨ÒåÓÊÕþ±àÂëÕâ¸ö×Ö¶Îʱ£¬Èç¹û½«ÆäÉèÖÃΪCHAR(255),ÏÔÈ»¸øÊý¾Ý¿âÔö¼ÓÁ˲»±ØÒªµÄ¿Õ¼ä£¬ÉõÖÁʹ ......
BLOB
TEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ65535(2^16-1)¸ö×Ö·û¡£
MEDIUMBLOB
MEDIUMTEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ16777215(2^24-1)¸ö×Ö·û¡£
LONGBLOB
LONGTEXT
Ò»¸öBLOB»òTEXTÁУ¬×î´ó³¤¶ÈΪ4294967295(2^32-1)¸ö×Ö·û¡£
¿Éͨ¹ýÐÞ¸Äphp.iniÎļþ£¬¸Ä±ä×î´ó³¤¶ÈÉèÖá£
; Valid range 0 - 2147483647.  ......
æµµÄ2009ÖÕÓÚ¹ýÈ¥£¬Ò²ÖÕÓÚ°ÑÈËÉú´óÊÂæÍêÁË£¬»Øµ½Õý³£µÄ¹¤×÷Éú»îÖÐÀ´¡£2010¶ÔÎÒÀ´ËµÓ¦¸ÃÊdzäÂúÐÂÆÚÍûµÄÒ»Ä꣬еÄÆõ»ú¾ÍÔÚÑÛÇ°£¬¼ÓÓÍŬÁ¦°É~
ÁíÍâ×¼±¸12¸öÔÂÖ®ºóÔÙÀ´×ܽáһϽñÄêµÄÖØ´óʼǣ¬ºÇºÇ~
˳±ã¿´µ½Ò»¸öMysqlµÄ²âÊÔÎÄÕ£¬¸Ð¾õ»¹ÂúÓвο¼¼ÛÖµµÄ£¬ÓÚÊǼǼÏÂÀ´ÒÔ±ã²Î¿¼¡£
ÒÔÏÂÊÇÒ»¸öMySQLÖÐMyISAMÒýÇæÓëInnoDBÒ ......
¹ØÓÚ·ÖÒ³µÄÓÅ»¯¡£
ÎÒÃÇÖªµÀ£¬ÔÚMySQLÖзÖÒ³ºÜ¼òµ¥£¬Ö±½ÓLIMIT page_no,page_total ¾Í¿ÉÒÔÁË¡£
¿ÉÊǵ±¼Ç¼ÊýÂýÂýÔö´óʱ£¬Ëý¾Í²»ÄÇôºÃʹÁË¡£
ÕâÀïÎÒÃÇ´´½¨ÕªÒª±íÀ´¼Ç¼ҳÂëºÍÔ±íÖ®¼äµÄ¹ØÁª¡£
ÏÂÃæΪ²âÊÔÊý¾Ý¡£
Ô±í£º
CREATE TABLE `t_group` (
`id` int(11) NOT NULL auto_increment,
`money` decim ......
˵µ½¼Æ»®ÈÎÎñ´ó¼Ò¿ÉÄܶ¼Ïëµ½ÓÃcrontabÀ´ÊµÏÖ¡£¿ÉÊDz¢²»ÊÇËùÓÐÈ˶¼ÊÇʹÓÃlinuxϵͳ£¬Ò²²»ÊÇËùÓÐÈ˶¼ÓжÀÁ¢·þÎñÆ÷¡£ÕâʱºòÈçºÎÓÃphpÀ´
ʵÏּƻ®ÈÎÎñÄØ¡£
º¯Êý- ignore_user_abort()
£¬
Õâ¸öº¯Êý¿ÉÒÔ°ïÖúÎÒÃÇʵÏÖÏñlinuxÖеÄcronÒ»ÑùʵÏּƻ®ÈÎÎñ£¬ÏÂÃæÒ»ÆðÀ´¿´Ï¸ÃÈçºÎÀ´ÊµÏÖ¡£
¸Ãº¯Êý°´ÕÕ×ÖÃæÒâ˼¾ÍÊÇ“ºöÂÔÓû§Ö ......