Sql Query:
SELECT test.* FROM test JOIN test_shares
WHERE test.test_id = test_shares.test_id
AND test_shares.email_address = '$email'
AND test.url is NOT NULL ORDER BY title ASC;
重写为Zend_Db_Select
声明。
$select = $db->select ()
->from ( 'test', 'test.*' )
->join ( 'test_shares', array () )
->where ( 'test.test_id = test_shares.test_id')
->where ( 'test_shares.email_address = ?', '$email')
->where ( 'test.url is NOT NULL')
->order ( 'title' );
echo $select;
输出:
SELECT test.* FROM test JOIN test_shares ON Array
WHERE test.test_id = test_shares.test_id
AND test_shares.email_address = '$email'
AND test.url is NOT NULL ORDER BY title ASC
请说明为什么会出现'ON Array'。
答案 0 :(得分:2)
试试这个:
$select = $db ->select ()
->from ( 'movie', 'movie.*' )
->join(array('movie_shares'), 'movie.movie_id = movie_shares.movie_id');
->where ( 'movie_shares.email_address = ?', '$email')
->where ( 'movie.url is NOT NULL')
->order ( 'title' );
echo $select;
您正在提供一个数组,其中ON子句需要一个字符串,因此PHP实际上打印array()
而不是字符串。