don*_*ias 4 php mysql database pdo
我曾经做过 :
$resource = mysql_query("SELECT * FROM table WHERE id = " . $id);
$user = mysql_fetch_assoc($resource);
echo "Hello User, your number is" . $user['number'];
我读过mysql语句都已弃用,不应该使用.
我怎么能用PDO做到这一点?
第一行是:
$stmt = $db->prepare("SELECT * FROM table WHERE id = " . $id); // there was an aditional double quote in here.
$stmt->execute(array(':id' => $id));
mysql_fetch_assoc()函数怎么样?
我正在使用PHP
你可以使用(PDO::FETCH_ASSOC)常量
用法将 
 while ($res = $stmt->fetch(PDO::FETCH_ASSOC)){
....
}
这里的参考文献(精确的文档):http://www.php.net/manual/en/pdostatement.fetch.php
| 归档时间: | 
 | 
| 查看次数: | 22823 次 | 
| 最近记录: |