Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 而在zend框架中_Php_Zend Framework_While Loop - Fatal编程技术网

Php 而在zend框架中

Php 而在zend框架中,php,zend-framework,while-loop,Php,Zend Framework,While Loop,大家早上好,我尝试使用zend framework对以下表单进行查询,但我不能,我想使用,因为foreach已经这样做了,请留下我的代码以查看我的错误: Model.php <?php class Application_Model_Datas { public function listar() { $db = Zend_Db_Table::getDefaultAdapter(); $select = $db->select()

大家早上好,我尝试使用zend framework对以下表单进行查询,但我不能,我想使用,因为foreach已经这样做了,请留下我的代码以查看我的错误:

Model.php

<?php

class Application_Model_Datas 
{



    public function listar()
    {
$db = Zend_Db_Table::getDefaultAdapter();

$select = $db->select()
             ->from('album');

return $db->fetchAll($select);

    }
}

Controller.php

    <?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
                     $table = new Application_Model_Datas(); 

                     $this->view->datos = $table->listar();
    }


}

您的代码没有意义/效果

<?php

//And your view looks like this.
while ($select = $this->datos){
   print_r($results); //Normally you get in an infinite loop
}

?>

您只需迭代一个简单数组:

$i = 0;

while($i < count($this->datos)) {
    print_r($this->datos[$i++]); //Getting current element, and incremeting counter
}
$i=0;
而($idatos)){
print_r($this->datos[$i++]);//获取当前元素并递增计数器
}

希望能有所帮助。

非常感谢你的朋友,他正努力做到这一点!问候语!
$i = 0;

while($i < count($this->datos)) {
    print_r($this->datos[$i++]); //Getting current element, and incremeting counter
}