I'm updating a site from pear DB to MDB2, I've managed to get quite far but I've come unstuck on a query I'm not sure what they are trying to achieve here.
Can anyone explain.
Here it is
$bookRes = $mdb2->query(("SELECT * FROM book WHERE (".join(' OR ', $sqlParams).") $categorySQL ORDER BY title"), $sqlValues);
while ($row = $bookRes->fetchRow()) {
$row['type'] = 'book';
$booksPossibles[] = $row;
}
I would need to see a bit more of the code to be sure, but this appears to be a simple dynamic generation of a SELECT statement where various criteria, with placeholders, stored in the $sqlParams array are being added to the WHERE clause and the values for those criteria are specified in the $sqlValues variable, again presumably an array.
so $sqlParams and $sqlValues might look like:
$sqlParams = array("val1 > ?", "val2 = ?");
$sqlValues = array(2, 4);
(It helps to know that the join keyword in PHP is just an alias for implode.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.