mysql - Converting this DB Queries to php PDO -
need help 2 queries in pdo
php code:
if($who!="") { $sql = "select id, title, itemurl iwbf_vault uid='".$who."' order pudt desc limit $limit_start, $items_per_page"; }else{ $sql = "select id, title, itemurl, uid iwbf_vault order pudt desc limit $limit_start, $items_per_page"; }
i write way:
// may have set before $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); $values = array(); $sql = "select id, title, itemurl iwbf_vault true"; if ($who) { $sql .= " , uid = ?"; $values[] = $who; } $sql .= " order pudt desc limit ?, ?"; $values[] = $limit_start; $values[] = $items_per_page; $stmt = $pdo->prepare($sql); $stmt->execute($values);
php mysql pdo
No comments:
Post a Comment