Hi Simon, Art & friends,
Thanks to Art's awesome debugging prowess (I.e. he saw something that I
didn't) it turns out that this entire problem was due to a typo in
Zend_Db_Table_Abstract. The fix follows:
GOTO: Line 582
FIND CODE BLOCK:
$data = array(
'table' => $this,
'data' => $this->_fetch('All', $where, $order, $count,
$offset),
'rowclass' => $this->_rowClass
);
REPLACE WITH:
$data = array(
'table' => $this,
'data' => $this->_fetch('All', $where, $order, $count,
$offset),
'rowClass' => $this->_rowClass
);
Commit at your leisure.
I have tested this initially and it seems to work for me. I will continue to
advise as I use.
Simon, Art, thanks for your help!
-Ryan
PS: Simon, I'll look into getting some unit tests going.
-----Original Message-----
From: Art Hundiak [mailto:[EMAIL PROTECTED]
Sent: March 19, 2007 3:18 PM
To: Ryan Brooks
Cc: 'Simon Mundy'; [email protected]
Subject: RE: [fw-general] $db->setRowClass & $db->setRowsetClass
In Zend_Db_Table_Abstract::fetchAll() we have
$data = array(
'table' => $this,
'data' => $this->_fetch('All', $where, $order, $count,
$offset),
'rowclass' => $this->_rowClass
);
return new $this->_rowsetClass($data);
And in Zend_Db_Table_Rowset_Abstract::__construct() we have:
if (isset($config['rowClass'])) {
$this->_rowClass = $config['rowClass'];
}
Almost as though the code was released without testing. Which I guess is
consistent with the fact that there are no DB_Table/Row tests in the
delivered version.
> Hi Simon,
>
>
>
> Yup, setting protected $_rowClass = 'Account'; does work. However, I plan
> on
> lazy loading a lot of my definitions so I can do something like:
>
>
>
> class Accounts extends Custom_Db_Table_Which_Extends_Zend_Db_Table
> implements Custom_Action_Insert_Delete_Authorize
>
> {
>
> public function _setup($config = array())
>
> {
>
> $this->_name = __CLASS__;
>
> $this->setRowClass(
>
> Utility_String_Ucfirst::returnString(
>
>
> Utility_String_Inflector_Singularize::returnString(
>
>
$this->_name)));
>
> parent::_setup($config);
>
> }
>
> }
>
>
>
> Really it's six in one and half a dozen in the other, just a personal
> preference, seeing how far I can push ZF. Unfortunately, this method
> didn't
> work from my initial tests, bringing us to the problem at hand.
>
>
>
> Alas, I do need the custom rowset. I have some methods on the entire
> resultset that I'd like to use in the future. (For instance, pagination
> utilizing view helpers).
>
>
>
> I'd really like if you (or someone) can poke around and see what's going
> wrong, if anything. Otherwise my experience during my upgrade has been
> very
> positive.
>
>
>
> Thanks! Hope to hear from you soon!
>
>
>
> -Ryan
>
>
>
> _____
>
> From: Simon Mundy [mailto:[EMAIL PROTECTED]
> Sent: March 19, 2007 2:35 PM
> To: Ryan Brooks
> Cc: [email protected]
> Subject: Re: [fw-general] $db->setRowClass & $db->setRowsetClass
>
>
>
> Hi Ryan
>
>
>
> I had a quick look at your table/row definitions.
>
>
>
> This will work:-
>
>
>
> class Accounts extends Zend_Db_Table
>
> {
>
> protected $_name = 'accounts';
>
> protected $_rowClass = 'Account';
>
> }
>
>
>
> You don't need the extra Rowset definition if there's no specific
> functionality you need to add - in most cases the default rowSet class is
> adequate.
>
>
>
> What puzzles me is that your '$this->setRowClass('Account')' _should_ have
> worked. I'll do some digging later to see if anything is awry and post a
> JIRA issue if it turns out to be the case.
>
>
>
> Cheers
>
>
>
> Update:
>
>
>
> Now I know I've missed something.
>
>
>
> In my debugging process, here's what I did.
>
>
>
> Open: Zend/DB/Table/Rowset/Abstract.php
>
> Goto Line: 71
>
> Replace Value of: protected $_rowClass = 'Zend_Db_Table_Row'
>
> With: protected $_rowClass = 'Account'
>
>
>
> Have access to Account->helloWorld();
>
>
>
> I'll keep digging, I seem to be missing a step along the way.
>
>
>
> -Ryan
>
>
>
> PS: Undo changes, save. ;)
>
>
>
>
>
>
>
> --
>
>
>
> Simon Mundy | Director | PEPTOLAB
>
>
>
> """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
>
> 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
>
> Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
>
> http://www.peptolab.com
>
>
>
>
>
>
>
>