2009年7月8日星期三

Re: [fw-db] Zend_Db question

Just like in your example you manipulate the update function to add some custom stuff and then call the parent::update function, you can do the same thing with fetchRow for your Billing class.

I am thinking something like (bare with me I haven't tested this)

function fetchRow($query)
{
    $result = parent::fetchRow($query);
    $result->price = 135;
    return $result;
}

I hope this helps.


On Wed, Jul 8, 2009 at 23:14, milesap <milesap@gmail.com> wrote:

Hello Everyone,

I was wondering if there is a way to alter the values returned from MySQL
within the Zend_Db_Table_Abstract class. Bear with me, I'll give you an
example of what I mean! I fetch rows like this:

$billing = new Billing(); //(Zend_Db_Table_Abstract class)
$getRow = $billing->fetchRow($billing->select()->where('id = ?', 1));


The above returns all columns in my billing table, say transaction and price
where id = 1, good so far. Now is it possible to alter, say price, in the
Zend_Db_Table_Abstract class? I know how to alter data for update and insert
in Zend_Db_Table_Abstract:

public function update(array $data)
{
  $data['price'] = '$10';
  return parent::update($data);
}


but not sure how to do this for data that's retrieved from the database. Can
anyone point me in the right direction or have a solution, I just can't
figure it out. Thanks in advance!
--
View this message in context: http://www.nabble.com/Zend_Db-question-tp24403008p24403008.html
Sent from the Zend DB mailing list archive at Nabble.com.




--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.

没有评论: