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
Ïà¹ØÎĵµ£º
ʾÀý£º
create procedure proc_name (in parameter integer)
begin
declare variable varchar(20);
if parameter=1 then
set variable='MySQL';
else
set variable='PHP';
end if;
insert into tb (name) values (variable);
end;
MySQLÀ©Õ¹Ò²ÊÇÖ§³Ö´æ´¢¹ý³ÌµÄ£¬²»¹ýÖ»Ö§³ÖÎÞ·µ»Ø½á¹ûµÄ´æ´¢¹ý³Ì
¿ÉÒÔÊ¹Ó ......
1005£ºMYSQL´´½¨±íʧ°Ü
¡¡¡¡
¡¡¡¡1006£ºMYSQL´´½¨Êý¾Ý¿âʧ°Ü
¡¡¡¡
¡¡¡¡1007£ºMYSQLÊý¾Ý¿âÒÑ´æÔÚ£¬´´½¨Êý¾Ý¿âʧ°Ü
¡¡¡¡
¡¡¡¡1008£ºMYSQLÊý¾Ý¿â²»´æÔÚ£¬É¾³ýÊý¾Ý¿âʧ°Ü
¡¡¡¡
¡¡¡¡1009£ºMYSQL²»ÄÜɾ³ýÊý¾Ý¿âÎļþµ¼ÖÂɾ³ýÊý¾Ý¿âʧ°Ü
¡¡¡¡
¡¡¡¡1010£ºMYSQL²»ÄÜɾ³ýÊý¾ÝĿ¼µ¼ÖÂɾ³ýÊý¾Ý¿âʧ°Ü
¡¡¡¡
&nbs ......
¹Ø¼ü´Ê£ºMySQL ±¸·Ý »Ö¸´
¡¡¡¡±¸·ÝÊÇ×î¼òµ¥µÄ±£»¤Êý¾ÝµÄ·½·¨£¬±¾½Ú½«½éÉܶàÖÖ±¸·Ý·½·¨¡£ÎªÁ˵õ½Ò»¸öÒ»Öµı¸·Ý£¬ÔÚÏà¹ØµÄ±íÉÏ×öÒ»¸öLOCK TABLES£¬ÄãÖ»ÐèÒ»¸ö¶ÁËø¶¨£¬µ±ÄãÔÚÊý¾Ý¿âĿ¼ÖÐ×öÎļþµÄÒ»¸ö¿½±´Ê±£¬ÕâÔÊÐíÆäËûÏ̼߳ÌÐø²éѯ¸Ã±í;µ±Äã»Ö¸´Êý¾Ýʱ£¬ÐèÒªÒ»¸öдËø¶¨£¬ÒÔ±ÜÃâ³åÍ»¡£
¡¡¡¡Ê¹ÓÃSQL ......
mysql alter Óï¾äÓ÷¨,Ìí¼Ó¡¢Ð޸ġ¢É¾³ý×ֶεÈ
//Ö÷¼ü549830479
alter table tabelname add new_fiel ......
ǰ׺Ë÷Òý
(1)Èç¹ûÒÔ¶à¸ö×Ö¶Î×÷ΪË÷Òý£¨a,b£¬c)×÷Ϊһ¸ökey,ÔÚ²éѯʱ·Ö¸ù¾ÝÆ¥ÅäÇé¿öÊÇ·ñʹÓÃË÷Òý£¬ËùÒÔ£¬a/ a,b/ a,b,cÕâÑùµÄ²éѯ¶¼ÄÜʹÓõ½£¬µ«ÊÇb,a/a,c/c,aµÈ²»·û֪ǰ׺ƥÅä¾Í²»ÄÜʹÓã¬ËùÒÔÔÚдsqlʱÐèҪעÒâ
(2)¶ÔÓںܳ¤µÄ×Ö·û´®ÐèÒªÉú³Ékeyʱ£¬¿ÉÒÔÕÒ³ö×ʹÓõÄ×Ö·û´®µÄ×î³£¼ûǰ׺(Ç°N¸ö×ÖÌõ×÷Ϊkey,¶ø²»Êǽ ......