PHPÁ¬½ÓMySQL
<?php
/**
* Mysql DB
*
* @author Administrator
* @package defaultPackage
*/
class MySqlDB{
private $_db;
private static $_instance;
private function __construct(&$db_type){
global $connectionstr;
$conn_db=$connectionstr[$db_type];
$this->_db=mysql_pconnect($conn_db["servername"],$conn_db["usernmae"],$conn_db["pwd"]);
if(!$this->_db){
die("'Could not connect: ".mysql_error());
}
mysql_select_db($conn_db["dbname"],$this->_db);
}
private function __clone(){
}
public static function getInstance(&$db_type){
if(!(self::$_instance instanceof self)){
self::$_instance=new self($db_type);
}
return self::$_instance;
}
function query($sql){
mysql_query("SET NAMES 'GBK'",$this->_db);
return mysql_query($sql,$this->_db);
}
function get_result_sql($sql){
return $this->query($sql);
}
/***¸ù¾Ýsql£¬·µ»ØÊý×éÊý¾Ý,ÓдíÎóÌáʾ***/
function getarray($sql){
$result_ay=array();
if($re=$this->query($sql)){
while ($row=mysql_fetch_array($re)) {
$result_ay[]=$row;
}
}
else {
js_msg("Êý¾Ý·ÃÎÊÓÐ´í£¡",-1);
}
return $result_ay;
}
/***¸ù¾Ýsql£¬·µ»ØÊý×éÊý¾Ý***/
function getarray_no_msg($sql){
$result_ay=array();
if($re=$this->query($sql)){
while ($row=mysql_fetch_array($re)) {
$result_ay[]=$row;
//mysql_fetch_array,mysql_fetch_row,
}
}
return $result_ay;
}
/***ÅúÁ¿²éѯ,×Ö¶ÎÏàͬ£¬·µ»ØÒ»Êý×é***/
function getarray_sqls($sql){
$result_ay=array();
if(is_array($sql)){
//print_r($sql);
foreach ($sql as $k=>$v){
if($re=$this->query($v)){
while ($row=mysql_fetch_array($re)) {
$result_ay[]=$row;
}
}
}
}
else {
$result_ay=$this->getarray_no_msg($sql);
}
return $result_ay;
}
/**
* »ñÈ¡¶à¸ö½á¹û¼¯
*
* @param array sqls
* @return array
*/
function getarrays_sqls($sql){
$result_ay=array();
if(is_array($sql)){
foreach ($sql as $k=>$v){
$temary=array();
Ïà¹ØÎĵµ£º
ÈçºÎ´´½¨ÎÒÃǵĵÚÒ»¸öPHPÒ³ÃæÄØ£¿·Ç³£¼òµ¥µÄ£¡Ñ¡ÔñÎÒÃÇʹÓõÄÒ»¸ö×îºÃµÄÉè¼Æ¹¤¾ß£¬µ±È»ÄãÒ²¿ÉÒÔ Ö»Ê¹ÓüÇʱ¾¡£´´½¨Ö®ºó¼ÇµÃÒª±£´æΪÀ©Õ¹ÃûΪPHPµÄÎļþ£¬È»ºó´«µ½ÎÒÃǵķþÎñÆ÷
ÉÏ¡£
¡¡¡¡ÔÚ±àдPHP³ÌÐò֮ǰͨ³£ÎÒÃÇÐèÒªÅäÖÃÎÒÃǵĻ·¾³£¬Ò²¾ÍÊÇ˵·þÎñÆ÷
ÒªÖ§³ÖPHP²ÅÄÜÐа¡
¡¡¡¡Ò»¡¢PHPµÄ»ù±¾½á¹¹£º
¡¡¡¡Ê¹ÓÃIncl ......
ÎÊ£º
±ÈÈçÎÒÏëÖ±½ÓÔÚphp µÄ½Å±¾Àïдһ¸öÀàËÆ£¬install.phpµÄ½Å±¾
Õâ¸ö½Å±¾µÄ×÷ÓþÍÊÇ£¬Á¬½ÓmysqlÊý¾Ý¿â£¬²¢½¨Á¢ÎÒËùÏëÒª½¨Á¢µÄÊý¾Ý¿â£¬Êý¾Ý±í£¬ÒÔ¼°Ïà¹Ø×ֶΡ£
Çë¾ßÌåдһ¸öÀý×Ó£¬Ð»Ð»£¡
______________________________________________________________________________________________
´ð1£º
連½Ó·½· ......
1¡¢Ä£°åµÄÓÉÀ´
ÔÚûÓÐÄ£°å¼¼Êõ֮ǰ£¬Ê¹ÓÃPHP¿ª·¢³ÌÐò£¬Í¨³£¶¼ÊÇphp´úÂëºÍhtml»ì±àÔÚÒ»Æð¡£±ÈÈç˵ÐÂÎÅÁÐ±í£¬ºÜ¿ÉÄܾÍÊÇÒ»¸önewslist.phpÒ³Ã棬½á¹¹ÈçÏ£º
<?
//´ÓÊý¾Ý¿âÖжÁÈ¡³öÒªÏÔʾµÄÐÂÎżÇ¼
?>
<html>
<head>……..
</head>
<body>
<?
While ($news ......
ÄÚÈÝ£º
*************
1
°²×°£Í£Ù£Ó£Ñ£Ìºó¸ü¸ÄÁˣңϣϣԵÄÃÜÂëºóÓÃ
net startmysql
Æô¶¯Ê±ÎÒ¾ÍÓöµ½ÁËÕâÑùµÄÎÊÌ⣮ʹÓÃÒÔÏÂÃüÁîºó
c:\mysql\bin\mysqladmin-u root -p shutdown
ÔÙnet start mysql¾ÍûÓÐÕâ¸ö´íÎóÌáʾÁË!
*************
2
MySQLµÄ1067´íÎó
Q£ºÎÒµÄMysqlÅöµ½ÁË 1067 ´íÎó
´íÎóÐÅϢΪ£º
......
Ê×ÏÈÒªÉùÃ÷Ò»µã£¬´ó²¿·ÖÇé¿öÏ£¬ÐÞ¸ÄMySQLÊÇÐèÒªÓÐmysqlÀïµÄrootȨÏ޵ģ¬ ËùÒÔÒ»°ãÓû§ÎÞ·¨¸ü¸ÄÃÜÂ룬³ý·ÇÇëÇó¹ÜÀíÔ±¡£ ·½·¨Ò»Ê¹ÓÃphpmyadmin£¬ÕâÊÇ×î¼òµ¥µÄÁË£¬ÐÞ¸Ämysql¿âµÄuser±í£¬ ²»¹ý±ðÍüÁËʹÓÃPASSWORDº¯Êý¡£ ·½·¨¶þʹÓÃmysqladmin£¬ÕâÊÇÇ°ÃæÉùÃ÷µÄÒ»¸öÌØÀý¡£ mysqladmin -u root -p password mypasswd ÊäÈëÕâ¸ö ......