2009年9月21日星期一

Re: [fw-db] How to get date from a Zend_Db_Table_Row class

Hi there

I think in this instance you would just add:

  $articleRow->where('id = ?', $id); // $id would be passed via the request object as a parameter or you can get it from $_GET
  $article = $articleTb->fetchRow($articleRow);

$articleRow isn't really an appropriate name, because it's referencing a Zend_Db_Table_Select object and not a Zend_Db_Table_Row object.

- Neil

On Mon, Sep 21, 2009 at 9:02 AM, neobeacon <neobeacon@gmail.com> wrote:

This is my Db table structuer.
http://www.nabble.com/file/p25530196/articlek.jpg

I create ArticleRow class by extending Zend_Db_Table_Row_Abstract for get
section and category names instead of section_id and category_id ,And user
names instead of author_id and modified_by from Article Zend_Db_Table class.

I add "protected $_rowClass = 'ArticleRow';" to Article class and for init()
method of ArticleRow(Zend_Db_Table_Row) I add

               $articleTb= new App_Model_Article();
               $articleRow=$articleTb->select();
               $articleRow->from( 'article');

$articleRow->join('section','section_id=section.id',array('section_name'=>'section.title'));
$articleRow->join('category','category_id=category.id',array('category_name'=>'category.title'));

$articleRow->join('user','author_id=user.id',array('author_name'=>'user.name'));

But I don't know how to get a the data of a specific row by passing id value
from a controller.
Please help me.Thank you.

--
View this message in context: http://www.nabble.com/How-to-get-date-from-a-Zend_Db_Table_Row-class-tp25530196p25530196.html
Sent from the Zend DB mailing list archive at Nabble.com.


没有评论: