I was doing something similar until some of the kind folks on this list
pointed out that I was essentially duplicating the Zend_Db_Table_Row.
If all you're doing is setting the values, then you can do something
like the following:
$news = new Zend_Db_Table('News');
$newsItem = $news->createRow();
$newsItem->name = $this->getRequest()->getPost('name')
$newsItem->save();
That said, it would certainly appear easier to insert the array as you
are doing. Take a look at Table_Row and see if might be some help, though.
-Brad
On 8/19/2010 7:20 AM, Rodrigo Ferrari wrote:
>
> Hello my friends.
>
> I´m developing an application to use for my graduation here in Brazil.
>
> I was thinking in some idea to use the $db->insert($data) in a better way.
>
> Nowadays I´m used to do this:
>
> Zend_Loader::loadClass('News');
> $db = new News();
>
> $data = array('name' => $this->getRequest()->getPost('name'));
>
> $db->insert($data);
>
> Well, it works very fine, BUT, I created a stdclass() and set the database
> values like public vars, like this:
> public $name;
>
> Can I just do it?
>
> $db->insert($this);
>
> To save all the content just one, without hading to mount the array like the
> previous code?
>
> Thanks and best regard´s
没有评论:
发表评论