MySql²Ù×÷Àà
×î½üдÁËÒ»¸ö¼òµ¥µÄMysql²Ù×÷À࣬ÄóöÀ´ºÍ´ó¼Ò·ÖÏíһϣ¬»¹Çë¸÷λ¸ßÊÖÖ¸ÕýÒ»ÏÂÎö¹¹º¯ÊýµÄÓ÷¨£º
<?php
/*
* Created on 2010-5-25
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*
* class mysql
* made by S71ENCE
*/
class mysql
{
private $host;//Ö÷»úÃû
private $name;//Óû§Ãû
private $pwd;//ÃÜÂë
private $dataBase;//Êý¾Ý¿âÃû
private $coding;//±àÂë
//³õʼ»¯
function __construct($host,$name,$pwd,$dataBase,$coding)
{
$this->host=$host;
$this->name=$name;
$this->pwd=$pwd;
$this->dataBase=$dataBase;
$this->coding=$coding;
$this->connect();//³õʼ»¯Á¬½Ó
}
/*********************************************************************************************
* Êý¾Ý¿â
* »ù±¾·½·¨
********************************************************************************************/
//Êý¾Ý¿âÁ¬½Ó
function connect()
{
$link=mysql_connect($this->host,$this->name,$this->pwd) or die($this-error());
mysql_select_db($this->dataBase,$link) or die("ÎÞ·¨Á¬½ÓÊý¾Ý¿â".$this->dataBase);
mysql_query("set names '$this->coding'");
}
//´íÎóÐÅÏ¢
function error()
{
return mysql_error
Ïà¹ØÎĵµ£º
½ñÌìʹÓÃPowerDesigner´î½¨ÁËÒ»¸öСÏîÄ¿£¬×îºóÖ´ÐÐÍêSQL½Å±¾Ê±²Å·¢ÏÖÓÐ2ÕűíµÄ±íÃûÖмä¶àÁËÒ»¸ö¿Õ¸ñ£¬²éÍê×ÊÁÏ£¬×îºó²¢¾ªÆæ·¢ÏÖÓ³ÉäÎļþ¾¹È»¶àÁË2¸ö`,¾ÍÊÇshift+Êý×Ö¼ü1µÄÄǸö£¬Ò²¾ÍÊÇËûÔڽű¾ÊÇÕâÑùдµÄ£º
create table `table1`(....);
ÎÊÌâ½â¾ö¡£
PS:´ÓÍøÉÏÕÒµ½µÄ×ÊÁÏ£º
×÷Ϊһ¸öOracle DBA£¬MySQLºÜ¶àSQLÓï·¨ÓëOrac ......
ÓÃmysql_query£¬mysql_fetch_array()ºóÓ¦¸ÃÒª
free_result().function count_admin($where = '')
{
if($where) $where = " WHERE $where";
$result = $this->db->get_one("SELECT count(*) as num from $this->table_admin_role $where");
return $result['num'];
} ......
¹ØÓÚMySqlµÄµ¼Èëµ¼³öÎÊÌâ
ÔÚÖÕ¶ËÖУ¬½øÈëmysqlµÄ·¾¶ÏµÄbinÖУ¬ÔÚÕâ¸ö·¾¶Ï¿ÉÒÔÖ´ÐÐmysql£¬mysqldumpµÈÃüÁî¡£
»òÕßÌí¼Ó»·¾³±äÁ¿ ÉèÖû·¾³±äÁ¿path "...(mysqlµÄ°²×°Â·¾¶ÏµÄbinĿ¼)"£¬ÕâÑù¾Í²»±ØÃ¿´Î¶¼½øÈëÉÏÃæËù˵µÄ·¾¶Ï²Ù×÷¡£
µ¼³öÒ»¸ö¿â£º
mysqldump ......
mysqlÊý¾Ý¿âlimit²éѯÓÅ»¯
MYSQLµÄÓÅ»¯ÊǷdz£ÖØÒªµÄ¡£ÆäËû×î³£ÓÃÒ²×îÐèÒªÓÅ»¯µÄ¾ÍÊÇlimit¡£mysqlµÄlimit¸ø·ÖÒ³´øÀ´Á˼«´óµÄ·½±ã£¬µ«Êý¾ÝÁ¿Ò»´óµÄʱºò£¬limitµÄÐÔÄܾͼ±¾çϽµ¡£
ͬÑùÊÇÈ¡10ÌõÊý¾Ý
select * from yanxue8_visit limit 10000,10 ºÍ
select * from yanxue8_visit limit 0,10
¾Í²»ÊÇÒ»¸öÊýÁ¿¼¶±ðµ ......
ǰ׺Ë÷Òý
(1)Èç¹ûÒÔ¶à¸ö×Ö¶Î×÷ΪË÷Òý£¨a,b£¬c)×÷Ϊһ¸ökey,ÔÚ²éѯʱ·Ö¸ù¾ÝÆ¥ÅäÇé¿öÊÇ·ñʹÓÃË÷Òý£¬ËùÒÔ£¬a/ a,b/ a,b,cÕâÑùµÄ²éѯ¶¼ÄÜʹÓõ½£¬µ«ÊÇb,a/a,c/c,aµÈ²»·û֪ǰ׺ƥÅä¾Í²»ÄÜʹÓã¬ËùÒÔÔÚдsqlʱÐèҪעÒâ
(2)¶ÔÓںܳ¤µÄ×Ö·û´®ÐèÒªÉú³Ékeyʱ£¬¿ÉÒÔÕÒ³ö×ʹÓõÄ×Ö·û´®µÄ×î³£¼ûǰ׺(ǰN¸ö×ÖÌõ×÷Ϊkey,¶ø²»Êǽ ......