我使用 zend_db_select 来连接 3 个表,并且在结果集数组中,当我期望看到带有别名的列名时,它返回一个数组,其中的键没有别名。
$dbSelect = $db->select()->from(array("pp"=>"products_photos"),array())
->joinInner(array("ph"=>"photos"), "pp.photo_id=ph.photo_id","ph.photo_id")
->joinInner(array('pr'=>'products'),"pr.product_id=pp.product_id","pr.product_id")
->where("pr.product_id=$row->product_id");
$photoJoinRowSet = $db->fetchAll($dbSelect);
var_dump($photoJoinRowSet);die();
结果喜欢:
array(2) { [0]=> array(3) { ["product_id"]=> string(1) "1" ["photo_id"]=> string(1) "4" }}
虽然我期待:
array(2) { [0]=> array(3) { ["pr.product_id"]=> string(1) "1" ["ph.photo_id"]=> string(1) "4" }}
......即使用列别名。
有谁知道为什么会这样??谢谢。