Zend Framework:推送数组中的值

时间:2012-08-23 12:47:21

标签: arrays zend-framework

那是我的阵列:

$rows = $this->fetchAll($a)->toArray();

如何推送此exp。 'type'=> $ rows中的所有数组中的1?

1 个答案:

答案 0 :(得分:1)

使用foreach循环结果的每一行并按下该值。这是非常基本的数组操作,你可以找到所有地方的例子。

或者,跳过代码中的循环,将类型= 1的移植到SELECT语句中。

$this->select()
     ->from(array(
         't' => 'fooTable'
     ), array(
         'type' => new Zend_Db_Expr($db->quote('1')), 
         'id'   => 't.id'
         'col1'   => 't.someothercolumn'
         'col2'   => 't.someothercolumn2'
     )
);