我以前做的:mysql_fetch_assoc()的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
第一行是'$语句= $ DB->准备( “SELECT * FROM表WHERE ID =:ID”);'作为将用户数据在你的查询中使用字符串连接是**危险**。 – tadman 2013-05-03 16:43:07
我知道,我做了一个编辑,以表明我只需要mysql_fetch_assoc()函数 – donparalias 2013-05-03 16:43:52