<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>音波网</title>
	<atom:link href="http://yinbo.org/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://yinbo.org</link>
	<description>关注移动互联网，软件开发。记录生活点滴！</description>
	<lastBuildDate>Sat, 12 Nov 2011 15:48:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>实现PHP&amp;MySql 数据库连接类</title>
		<link>http://yinbo.org/index.php/2011/11/php-mysql-db-connect-class/</link>
		<comments>http://yinbo.org/index.php/2011/11/php-mysql-db-connect-class/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 11:58:27 +0000</pubDate>
		<dc:creator>陈律</dc:creator>
				<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://yinbo.org/?p=1</guid>
		<description><![CDATA[背景 因为从事的是.Net开发，对于PHP一直只是“有所研究”，但是没具体去实践过。这是第一次，用PHP去写点东西。 正文： 很早就学习过“算法+数据结构=程序”。所以我每学习一门语言，入门了之后，就会开始去和数据库打交道。 至于PHP和MySql的安装，就不赘述了。（如果不会就Google/百度） 学习 PHP&#38;MySql 最好去参考官方文档，比较全，比较新， 英文：http://www.php.net/manual/en/ 中文：http://www.php.net/manual/zh/ MySql文档：http://php.net/manual/en/book.mysql.php PHP和MySql天生就是一对最佳拍档，一提到PHP开发，数据库就肯定是MySql了。我本地的MySql用户名和密码是“devaccount/app123”，先创建一个数据库，叫“Test”。 代码： &#60;?php // 数据库连接，这只是一个简单的实例，具体应用时候，还是需要具体实现的。 class MyDB { var $conn; var $host = 'localhost'; //服务器地址 var $uid = 'devaccount'; //用户名 var $pwd = 'app123'; //密码 var $dbName = 'Test'; //数据库名称 function Open(){ if(!$this-&#62;conn) // 这里可以用 mysql_connect 或者 mysql_pconnect，mysql_pconnect是持久连接，效率高些 $this-&#62;conn = mysql_pconnect( $this-&#62;host, $this-&#62;uid, $this-&#62;pwd) [...]]]></description>
			<content:encoded><![CDATA[<h3>背景</h3>
<p>因为从事的是.Net开发，对于PHP一直只是“有所研究”，但是没具体去实践过。这是第一次，用PHP去写点东西。</p>
<h3>正文：</h3>
<p>很早就学习过“算法+数据结构=程序”。所以我每学习一门语言，入门了之后，就会开始去和数据库打交道。</p>
<p>至于PHP和MySql的安装，就不赘述了。（如果不会就Google/百度）</p>
<p>学习 PHP&amp;MySql 最好去参考官方文档，比较全，比较新，</p>
<ul>
<li>英文：http://www.php.net/manual/en/</li>
<li>中文：http://www.php.net/manual/zh/</li>
<li>MySql文档：http://php.net/manual/en/book.mysql.php</li>
</ul>
<p>PHP和MySql天生就是一对最佳拍档，一提到PHP开发，数据库就肯定是MySql了。我本地的MySql用户名和密码是“devaccount/app123”，先创建一个数据库，叫“Test”。</p>
<h3>代码：</h3>
<pre class="wp-code-highlight prettyprint">
&lt;?php
// 数据库连接，这只是一个简单的实例，具体应用时候，还是需要具体实现的。
class MyDB {
	var $conn;
	var $host = 'localhost';   //服务器地址
	var $uid = 'devaccount';    //用户名
	var $pwd = 'app123';    //密码
	var $dbName = 'Test'; //数据库名称

	function Open(){
		if(!$this-&gt;conn)
			// 这里可以用 mysql_connect 或者 mysql_pconnect，mysql_pconnect是持久连接，效率高些
                        $this-&gt;conn = mysql_pconnect(
				$this-&gt;host,
				$this-&gt;uid,
				$this-&gt;pwd) or die(&quot;Could not connect to $this-&gt;host&quot;);

		mysql_query(&quot;SET NAMES 'utf8'&quot;,$this-&gt;conn); 

		mysql_select_db(
			$this-&gt;dbName,
			$this-&gt;conn) or die('Could not open database.');
	}

	function Close() {
		if($this-&gt;conn) {
			mysql_close($this-&gt;conn);
		}
	}
}
$db = new MyDB();
$db-&gt;Open();
//
//... 具体实现
//
$db-&gt;Close();
?&gt;
</pre>
<h3>实例下载：</h3>
<p>赞不提供！</p>
]]></content:encoded>
			<wfw:commentRss>http://yinbo.org/index.php/2011/11/php-mysql-db-connect-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

