I need to convert the following from old mysql_ style connections to new pdo style connections.
function getRecords(){
$this->res = mysql_query("select * from cusbuilder_sites");
if(mysql_num_rows($this->res)){
while($this->row = mysql_fetch_assoc($this->res)){
$record = array_map('stripslashes', $this->row);
$this->records[] = $record;
}
return $this->records;
}
//else echo "No records found";
}
I am still learning pdo but was trying to replace as follows, but i am completely lost:
$stmt=$db->prepare('SELECT *, COUNT(*) AS cnt FROM cusbuilder_sites ORDER BY id');
$stmt->execute();
$row = $stmt->fetchAll();
if ($row['cnt'] > $row[id]) {
...
At this point I really have no idea what to change. Looking for some assistance or perhaps a better and more correct way to achieve this.