<?php
$sql_1 = $GLOBALS['dbh']->query('SELECT * from ogrlice WHERE izdvojen = 1');
$i = 0;
foreach ($sql_1 as $row) {
$i++;
if ($i > 4) {
break;
}
$GLOBALS['logger']->write("MySQL: Fetching..."); ?>
/* ECHOING STUFFS */
<?php }
$MySQL->close();
?>
这是我的代码,这是我的问题。
$sql_1 = $GLOBALS['dbh']->query('SELECT * from ogrlice WHERE izdvojen = 1');
此查询工作正常,但这是失败的。
$sql_1 = $GLOBALS['dbh']->query('SELECT * from ogrlice, brosevi WHERE izdvojen = 1');
但是,这很好。
$sql_1 = $GLOBALS['dbh']->query('SELECT * from ogrlice');
并返回整个未过滤的表格。
我使用PDO。
答案 0 :(得分:0)
$sql_1 = $GLOBALS['dbh']->query('SELECT * from ogrlice, brosevi WHERE izdvojen = 1');
返回交叉产品,因为您错过了连接部分:
$sql_1 = $GLOBALS['dbh']->query('SELECT * from ogrlice, brosevi WHERE ogrlice.id = brosevi.ogrlice_id and izdvojen = 1');