Php 而在zend框架中
大家早上好,我尝试使用zend framework对以下表单进行查询,但我不能,我想使用,因为foreach已经这样做了,请留下我的代码以查看我的错误: Model.phpPhp 而在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()
<?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
}