·ÖÏíÒ»¸ömysqlÀà~
<?php
/**
* ²Ù×÷mysql
µÄ»ù´¡À࣬ÆäËüÓëmysqlÓйصÄÀ඼¼Ì³ÐÓÚ´Ë»ùÀà
*
* ´ËclassÖеÄ$table¶¼ÊÇÒѾ°üº¬±íǰ׺µÄÍêÕû±íÃû
*
* ver 20090717
* ʹÓ÷¶Àý
* $db = new DB('localhost','root','password','database','utf8');
* $db->debug = true;
* $db->primaryKeys = array (
* 'table_1' => 'id',
* 'table_2' => 'id2'
* );
* $db->find('table_1', 1);
* $db->findAll('table_2', '*', 'catid=1', 'id desc');
* ……
*/
class DBBase extends Base {
public $debug; //µ÷ÊÔ
public $primaryKeys = array(); //É趨¸÷±íµÄÖ÷¼ü£¬ÔÚ´´½¨ÀàʵÀýºó±ØÐëÉ趨±íÖ÷¼ü $db->primaryKeys(array('±í1'=>'Ö÷¼ü×Ö¶Î
1','±í2'=>'Ö÷¼ü×Ö¶Î2'))
public $queryCount = 0;
public $haltOnError = true;
public $displayError=true;
public $queryID;
public $connected = false;
public $tableFields = array();
public $dbhost;
public $dbuser;
public $dbpwd;
public $dbname;
public $dbcharset;
public $pconnect = false;
public function __construct($host, $user, $pwd, $database = null, $charset = null, $pconnect = null) {
$this->dbhost = $host;
$this->dbuser = $user;
$this->dbpwd = $pwd;
$this->dbname = $database;
$this->dbcharset = $charset;
$this->pconnect = $pconnect;
}
public public function connect()
{
if ($this->pconnect) {
@mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpwd) || die('<b>MySQL
ERROR:</b> ' . mysql_error());
} else {
@mysql_connect($this->dbhost, $this->dbuser, $this->dbpwd) || die('<b>MySQL ERROR:</b> ' . mysql_error());
}
if ($this->dbname != null) {
$this->selectdb($this->dbname);
}
$this->connected = true;
}
public function selectdb($dbname) {
$this->dbname = $dbname;
mysql_select_db($this->dbname) || die('<b>MySQL ERROR(mysql_selectt_db):</b> ' . mysql_error());
$serverVersion=$this->serverVersion();
if ($this->dbcharset && $this->serverVersion()>='4.1') {
mysql_query("SET NAMES " .
Ïà¹ØÎĵµ£º
Explain MySQL architecture
. - The front layer
takes care of network connections and security authentications, the
middle layer does the SQL query parsing, and then the query is handled
off to the storage engine. A storage engine could be either a default
one supp ......
Õ⼸ÌìËù×÷µÄ¹¤×÷Éæ¼°µ½Êý¾Ý¿âÐÐתÁеÄÎÊÌâ
¼Ç¼һϳöÏֵĴíÎó£¬ÒÔÃâÒÔºóÔÙ·¸
¾ÙÍøÉÏ×îͨË×µÄÀý×Ó°É
Name Subject Result
ÕÅÈý ÓïÎÄ 80
ÕÅÈý Êýѧ 90
ÕÅÈý ÎïÀí &n ......
MysqlÊý¾Ý¿âÊÇÒ»¸ö¶àÓû§£¬¶àÏ̵߳ĹØϵÐÍÊý¾Ý¿â£¬ÊÇÒ»¸ö¿Í»§»ú/·þÎñÆ÷½á¹¹µÄÓ¦ÓóÌÐò¡£ËüÊǶԸöÈËÓû§ºÍÉÌÒµÓû§ÊÇÃâ·ÑµÄ.
MysqlÊý¾Ý¿â¾ßÓÐÒÔÏÂÓŵ㣺
1.ͬʱ·ÃÎÊÊý¾Ý¿âµÄÓû§µÄÊýÁ¿²»ÊÜÏÞÖÆ
2.¿ÉÒÔ±£´æ³¬¹ý5ǧÍòÌõµÄ¼Ç¼
3.ÊÇÄ¿Ç°Êг¡ÉÏÏÖÓÐÊý¾Ý¿â²úÆ·ÖÐÔËÐÐËÙ¶È×î¿ìµÄÊý¾Ý¿âϵͳ
4.Óû§È¨ÏÞÉèÖüòµ¥¡¢ÓÐ ......
Ò»¸ö¼òµ¥Ê¾Àý--
1£¬×¼±¸£ºMySQLÊý¾Ý¿âÇý¶¯°ü¡¾mysql-connector-java-5.1.10-bin.jar¡¿µ¼Èë
2£¬´´½¨²âÊÔÁ¬½ÓÖ÷³ÌÐò
package mysqlConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class JdbcDemo {
public static void main(String[] args) {
......
ÕâÀï½éÉÜÒ»¸ö¼¯³É»·¾³ XAMPP¡£
XAMPP ÊÇÒ»¸öÒ×ÓÚ°²×°ÇÒ°üº¬ MySQL¡¢PHP ºÍ Perl µÄ Apache ·¢Ðа档XAMPP µÄÈ··Ç³£ÈÝÒ×°²×°ºÍʹÓãºÖ»ÐèÏÂÔØ£¬½âѹËõ£¬Æô¶¯¼´¿É¡£
ÏÂÔصØÖ·£º
http://www.apachefriends.org/zh_cn/xampp.html
µ½Ä¿Ç°ÎªÖ¹£¬XAMPP ¹²ÓÐÒÔÏÂËÄÖÖ°æ±¾£º
£¨1£©ÊÊÓÃÓÚ Linux µÄ XAMPP
£¨2£©ÊÊÓÃÓÚ Windows µ ......