cakephp上的模型返回给我Array

时间:2014-02-20 18:18:17

标签: php arrays cakephp

我正在使用这种方法在cakephp的模型中工作

public function updateUserStatus($uus){
  if(isset($calor["valor1"])){

    $query1= $this->query("SELECT time from users where time = "'.$valor["valor1"].'";");        

    return "test".$query1;

  }

}

但是当我return "test".$query1 ;时,视图会显示testArray 我的问题是如何从查询中获取价值时间? 谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

这是因为你将一个字符串与一个数组连接在一起,PHP会将数组更改为一个字符串,它将是Array$query1是一个包含数据的数组,所以只需执行:

return $query1;

使用将存储返回值的变量访问您的字段。

如果您希望'test'$query1相关联,那么最好:

return array('test' => $query1);