Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 带有where子句的ZF2内部联接返回空结果_Mysql_Join_Zend Framework2_Where - Fatal编程技术网

Mysql 带有where子句的ZF2内部联接返回空结果

Mysql 带有where子句的ZF2内部联接返回空结果,mysql,join,zend-framework2,where,Mysql,Join,Zend Framework2,Where,当我在send中尝试followmysql查询时,我只得到一个空的结果集(谁支持填充) 我在mysql工作台中尝试了以下查询(返回结果) 我的ZF2应用程序中的这个(空结果集) 调试结果: SELECT "websites".*, "s"."website_id" AS "websites.id" FROM "websites" INNER JOIN "websites_statistics" AS "s" ON "s"."website_id" = "websites"."id" WH

当我在send中尝试followmysql查询时,我只得到一个空的结果集(谁支持填充)

我在mysql工作台中尝试了以下查询(返回结果)

我的ZF2应用程序中的这个(空结果集)

调试结果:

SELECT "websites".*, 
"s"."website_id" AS "websites.id" 
FROM "websites" 
INNER JOIN "websites_statistics" AS "s" ON "s"."website_id" = "websites"."id" 
WHERE "websites"."website" = 'google.com'
(!更新)查询稍微简单一点,这样更容易。我认为在第一刻出现了一些问题,因为我认为“s”。“website\u id”作为“websites.id”必须向另一个方向翻转。。“websites.id”为“s”。“website\u id”我需要websites.id从websites\u统计表中按website\u id进行记录

提前谢谢


尼克

我成功了。问题不在于质疑,而在于自我。我必须将第二个表的字段(我加入的表)添加到第一个表的模型(exchangeArray)中!这就成功了。谢谢大家。

要查看Zend select的结果,您可以使用print$select->\uuu toString();用OutputHx更新了帖子我也遇到了同样的问题
$sql = new Sql($this->tableGateway->getAdapter());

    $select = $sql->select();
    $select->from('websites')
           ->join(array('s' => 'websites_statistics'), 's.website_id = websites.id', array('websites.id' => 'website_id'), \Zend\Db\Sql\Select::JOIN_INNER)
           ->where(array('websites.website' => 'google.com'));

    $resultSet = $this->tableGateway->selectWith($select);

    echo $select->getSqlString();

    return $resultSet;
SELECT "websites".*, 
"s"."website_id" AS "websites.id" 
FROM "websites" 
INNER JOIN "websites_statistics" AS "s" ON "s"."website_id" = "websites"."id" 
WHERE "websites"."website" = 'google.com'