<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[先展望php6(当然也可能是php5.2之类，暂未确定)]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Wed, 25 Oct 2006 15:04:38 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	先展望php6(当然也可能是php5.2之类，暂未确定)<br/><br/>去掉的东西(感觉有必要提的)<br/>2.1 register_globals<br/>这个影响安全,又不好处理.<br/>2.2 magic_quotes<br/>这个本意很好，但反对的声音很多…<br/>2.3 safe_mode<br/>这个东西被E_CORE_ERROR代替了.<br/>2.11 register_long_arrays, HTTP_*_VARS<br/>这个东西影响速度<br/><br/>特别的<br/>1. Unicode<br/>这个东西好!不用再担心很多了.<br/>3.1 XMLReader / XMLWriter in the distribution, on by default<br/>以后处理rss之类的就更容易了<br/>3.2 Move non-PDO DB extensions to PECL<br/>下面特别讨论.<br/>3.3 Move ereg to PECL<br/>实际preg,ereg差不多.用两个等于浪费.<br/><br/>其余的参见(http://www.php.net/~derick/meeting-notes.html)<br/><br/>============================================<br/>下面描述一下,在php6,没有mysql_*,我们怎么过.<br/><br/>首先要连接mysql数据库<br/>$dbh = new PDO(’mysql:host=localhost;dbname=test’, $user, $pass);<br/>//如果你想连mssql:<br/>//mssql:host=localhost;dbname=testdb<br/>//连pgsql:<br/>//pgsql:host=localhost port=5432 dbname=testdb user=bruce password=mypass<br/>//连odbc(DSN)<br/>//odbc:testdb<br/>//连access:<br/>//odbc:Driver=&#123;Microsoft Access Driver (*.mdb)&#125;;Dbq=C:&#92;&#92;db.mdb;Uid=Admin<br/>//还有oracle,sqlite,db2….<br/><br/>我要执行个查询<br/>foreach ($dbh->query(’SELECT * from FOO’) as $row) &#123;<br/>print_r($row); //这个结果和mysql_fetch_array差不多。PDOStatement::setFetchMode 可以调整。<br/>&#125;<br/>//现在多简单<br/><br/>另外还可以：<br/>$sth = $dbh->prepare(”SELECT name, colour FROM fruit”);<br/>$sth->execute();<br/><br/>/* Fetch all of the remaining rows in the result set */<br/>print(”Fetch all of the remaining rows in the result set:&#92;n”);<br/>$result = $sth->fetchAll();<br/>print_r($result);<br/>得到：<br/>Fetch all of the remaining rows in the result set:<br/>Array<br/>(<br/>[0] => Array<br/>(<br/>[NAME] => pear<br/>[0] => pear<br/>[COLOUR] => green<br/>[1] => green<br/>)<br/><br/>[1] => Array<br/>(<br/>[NAME] => watermelon<br/>[0] => watermelon<br/>[COLOUR] => pink<br/>[1] => pink<br/>)<br/><br/>)<br/><br/>偶还想删/更新条数据。<br/>$count = $dbh->exec(”DELETE FROM fruit WHERE colour = ‘red’”);<br/>//$count就是删除的条数。相当于mysql_affected_rows<br/>//也可用PDOStatement::rowCount<br/><br/>偶忘了偶用啥数据库了。。。。<br/>if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == ‘mysql’) &#123;<br/>echo “Running on mysql; doing something mysql specific here&#92;n”;<br/>&#125;<br/><br/>偶插入数据的时候要用mysql_escape_string.现在？<br/><br/>print “Unquoted string: $string&#92;n”;<br/>print “Quoted string: ” . $conn->quote($string) . “&#92;n”;<br/>得到：<br/>Unquoted string: Nice<br/>Quoted string: ‘Nice’<br/>//你看现在连引号都自动加了。。。。<br/>//注意在不同的数据库中结果不同，比如有的’ => ‘’,有的’ => &#92;’，&#92; => &#92;&#92;<br/>//现在没顾虑了，全自动。<br/><br/>//最后偶要关闭它了<br/>$conn = null; //fcicq和这个数据库连接要说再见了。。。。<br/>//但是！你可以：<br/>$dbh = new PDO(’odbc:SAMPLE’, ‘db2inst1′, ‘ibmdb2′,<br/>array(PDO_ATTR_PERSISTENT => true)); //保持连接<br/><br/>很简单的不是？<br/><br/>附：特别简单的特殊调用方法：<br/>$stmt = $dbh->prepare(”SELECT * FROM REGISTRY where name = ?”);<br/>if ($stmt->execute(array($_GET[’name’]))) &#123; //你怕啥？自动quote!<br/>while ($row = $stmt->fetch()) &#123;<br/>print_r($row);<br/>&#125;<br/>&#125;<br/><br/>也可以：<br/>$stmt->bindParam(1, $id);<br/>$stmt->bindParam(2, $_FILES[’file’][’type’]);<br/>$stmt->bindParam(3, $fp, PDO::PARAM_LOB);<br/><br/>这么好的功能，哪里可以找到？php5.1以上在扩展里，php5在pecl里，php4?你别想了，没有。<br/>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 先展望php6(当然也可能是php5.2之类，暂未确定)]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>