ZF-4141: Zend_View_Helper_PartialLoop forces objects to array conversion when object exposes toArray()

Issue Type: Bug Created: 2008-08-31T13:24:31.000+0000 Last Updated: 2008-10-11T09:06:48.000+0000 Status: Resolved Fix version(s): Reporter: Julien SERDARU (jserdaru) Assignee: Jon Whitcraft (sidhighwind) Tags: - Zend_View

Related issues: - ZF-3285



I would like to use the ability exposed in the partialLoop helper to access a Zend_Db_Table_Rowset_Abstract as an object.

Unfortunately, if an object exposes toArray() as one of it's method (which is the case here for Zend_Db_Table_Rowset_Abstract) , then it is automatically converted to an array, instead of offering the possibility to use it as an object instance.

Sample code:

     echo $this->partialLoop('my_partial_view',$rowset_data);

Make sure that $rowset_data is of type Zend_Db_Table_Rowset_Abstract


Posted by Jon Whitcraft (sidhighwind) on 2008-10-08T19:11:11.000+0000

I just tested this against svn and it works just fine.

Have you tried using 1.6.1 to see if this problem is fixed.

My Test Table Object

<pre class="highlight">
require_once ('Zend/Db/Table/Abstract.php');

class Test extends Zend_Db_Table_Abstract
    protected $_name = 'test';

Here is what I have in my controller file

<pre class="highlight"> 
$db = Zend_Db::factory('mysqli', array('host' => 'localhost', 'username' => 'my_user', 'password' => 'my_passwod', 'dbname' => 'test_db'));
        $test = new Test(array(
            'db' => $db

        $this->view->results = $test->fetchAll();

Here is what I have in my view:

<pre class="highlight">
echo $this->partialLoop('index/_pl.phtml', $this->results);

here is what is in my _pl.phtml file

<pre class="highlight">
$name = $this->object->name;
print "Name: " . $name . "<br></br>";

Posted by Jon Whitcraft (sidhighwind) on 2008-10-09T10:39:09.000+0000

This was fixed here: […]

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.