简体   繁体   中英

Zend select DB with no get column

I have a problem with zend when I select data from DB. In my query I don't want select any column from table that I join with another table. I use array() in third parameter. But when I do this:

$sql = $db->select();
    $sql->from( "message", "message.message_id" )

        ->->join("network_users","message.network_id = network_users.network_id and message.user_id = network_users.user_id","network_users.network_id") //no get column
        ->join("users","message.user_id = users.user_id",array()) //no get column
        ->where( "message.network_id = :network_id" )
        ->where( "message.del_flg = 0" )
        ->where( "network_users.del_flg = 0" )
        ->where( "users.del_flg = 0" )
        ->order( "message.regist_date DESC" );

 $ary[':network_id']   = $network_id;
 $ret = $db->fetchAll($sql, $ary);

return empty($ret[0]["user_id"]) ? array():$ret;

I always get result is array(0) {}

When I get least one column in each table, it response correct result.

Any idea for my problem????

Thanks for any help.

Use null instead of array()

So it would look like this: ->join("users","message.user_id = users.user_id",null)

I found the problem, problem is I used return empty($ret[0]["user_id"]) ? array():$ret; return empty($ret[0]["user_id"]) ? array():$ret; instead of return empty($ret[0]["message_id"]) ? array():$ret; return empty($ret[0]["message_id"]) ? array():$ret; .

That is reason I always receive array(0) {} .

Thanks for help. ^_^

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.

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