Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Db_Table_Row_Abstract Extended Row Class Not Functioning
    primarykey
    data
    text
    <p>I'm using the Zend_Db framework, and I've run into a snag. I'm trying to add custom handling to the column naming at the row level, but it's failing to invoke my function for some reason.</p> <p>I've stripped down the problem to simply try and figure out if the underlying "Row" class is ever even created. From what I can tell, it isn't.</p> <p>Here's what I've got:</p> <pre><code>// this class functions correctly; I get "table" written to my output class DHR_Table extends Zend_Db_Table_Abstract { protected $_rowClass = 'DHR_Row'; function __construct(){ echo "table"; parent::__construct(); } } // this class never gets called, at least not that is evident from the constructor echo class DHR_Row extends Zend_Db_Table_Row_Abstract { protected $inflector = null; function __construct(){ echo "row"; parent::__construct(); } } // this is the actual implementation class that uses these two: class Application_Model_DbTable_Applicants extends DHR_Table { protected $_name = 'applicants'; } </code></pre> <p>My output includes some data (excluded from this post, but part of the "Applicants" class) and "table", but no "row". Any ideas why this might be happening? Version 1.11.11 of the Zend framework.</p> <p>[Edit] Here's the usage:</p> <pre><code>class ApplicantsController extends DHR_RestController { public function indexAction() { $applicants = new Application_Model_DbTable_Applicants(); $result = $applicants-&gt;fetchAll(); $this-&gt;success($result); } protected function success($data, $code = 200) { if(is_a($data, 'Zend_Db_Table_Rowset')){ // we could do some pagination work here $data = $data-&gt;toArray(); } $this-&gt;setResponseCode($code)-&gt;appendBody(Zend_Json::encode(array( 'success'=&gt;true, 'data' =&gt; $data ))); } } </code></pre> <p>I would expect to at least have some method on the row class invoked when returning the serialized results...</p> <p><strong>[Update]</strong> If I use "fetchRow" everything works as expected; fetchAll simply does't do the conversion to the underlying object type.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload