简体   繁体   English

从Pear DB更新到Pear MDB2-开发人员试图在查询中做什么?

[英]Updating from Pear DB to Pear MDB2 - what is the developer trying to do in the query?

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. 我正在将网站从pear DB更新到MDB2,我已经设法做到了很多,但是我对查询感到困惑,我不确定他们在这里想要实现什么。

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. 我需要确定更多代码,但这似乎是SELECT语句的简单动态生成,其中将存储在$ sqlParams数组中的各种条件(带有占位符)添加到WHERE子句中,并且这些条件的值在$ sqlValues变量中指定,该变量还是一个数组。

so $sqlParams and $sqlValues might look like: 因此$ sqlParams和$ sqlValues可能看起来像:

$sqlParams = array("val1 > ?", "val2 = ?");
$sqlValues = array(2, 4);

(It helps to know that the join keyword in PHP is just an alias for implode.) (这有助于了解PHP中的join关键字只是implode的别名。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM