-- ViShap <[EMAIL PROTECTED]> wrote
(on Tuesday, 23 October 2007, 06:07 PM +0200):
> I can't see how to update (sorry, my mistake, not select *doh* ;) ) this?
> In the Manual I can't find a part, where it is described, how to do this?
>
> How should I do this:
>
> Table User: | Table Info
> ID | user_ID
> Nick | information
>
> Now let´s say classes are named like the tables, all Relationships have been
> entered.
>
> How can I now do an Update like this:
>
> $Info->update() doing the following:
>
> Update "Info.information" where "Info.user_ID" is the to "user.Nick"
> corresponding "user.ID" ?
First off, the above is not valid SQL, so it's hard to have a good idea
of what you're attempting. My best guess is that you want to set
Info.information for a given Info.user_ID; I'm not sure what User.Nick
has to do with it other than it relates to Info.user_ID. Regardless,
you're simply updating a single table.
> For example: User "dummy" has ID 23.
> Now I want to update Info.information only knowing the dummy!
>
> Sorry, I don´t understand how it should work.
>
> Best regards and thanks for the help
Zend_Db_Table_Abstract::update() has the following signature:
update(array($params), $where = '')
$params should be a set of key/value pairs that you want set, and $where
should be a valid WHERE clause. So, for example:
$Info->update(array('information' => $info),
$Info->getAdapter()->quoteInto('user_ID = ?', $id));
If using just a Zend_Db_Adapter, the signature is:
update($tableName, array $bind, $where = '')
where $bind is analogous to $params above -- the only real difference is
the addition of the $tableName argument.
> -----Original Message-----
> From: Matthew Weier O'Phinney [mailto:[EMAIL PROTECTED]
> Sent: Montag, 22. Oktober 2007 21:50
> To: [email protected]
> Subject: Re: [fw-general] Zend_Db_Table_Ralationships and select()
>
> -- ViShap <[EMAIL PROTECTED]> wrote
> (on Monday, 22 October 2007, 08:34 PM +0200):
> > I have the following Problem:
> >
> > How can I write this statement using $db->select() ?
> >
> >
> >
> > UPDATE `register`,`users`
>
> You can't. Zend_Db_Select only does SELECT statements, not UPDATE or
> DELETE.
>
> Now, that said, there are ways to make this easier. Take a look at the
> Zend_Db_Adapter_Abstract::insert() and update() methods, as well as the
> related methods in Zend_Db_Table_Abstract.
>
> <snip>
>
> > Another thing: Today I looked at Zend_Db_Table and
> > Zend_Db_Table_Relationships
> >
> > But there I had the same question. Can I achieve this Query using the
> > Zend_Db_able_Relationships – without using multiple querys?
>
> You *can* do it with Zend_Db_Table. Again, look at the update() method;
> the 'where' clause can refer to another table.
>
> --
> Matthew Weier O'Phinney
> PHP Developer | [EMAIL PROTECTED]
> Zend - The PHP Company | http://www.zend.com/
>
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/