-- ViShap <[EMAIL PROTECTED]> wrote
(on Tuesday, 23 October 2007, 08:42 PM +0200):
> And where is my advantage doing this?
>
> I fire another totally useless query (to get the structure of the table) and
> have to use a subquery inside my code.
>
> Doing this makes Hardcoded solutions better and faster?!
>
> Is there no way simply doing this by $info->update($fields, ‘users.nick =
> ‘fooBar’ AND users.nick = users_ID’) or similar (leaving the users. ?)
Okay, only *now* have you indicated what you were trying to accomplish.
And yes, you can do this:
$adapter = $Info->getAdapter();
$where = $adapter->quoteInto('users.nick = ?', 'fooBar')
. ' AND users.nick = users_ID';
$Info->update($fields, $where);
>
> From: Bryce Lohr [mailto:[EMAIL PROTECTED]
> Sent: Dienstag, 23. Oktober 2007 19:39
> To: ViShap
> Cc: [email protected]
> Subject: Re: [fw-general] Zend_Db_Table_Ralationships and select()
>
>
>
> It appears you're trying to do this:
>
> $info->update($fields, "user_id = (SELECT id FROM users WHERE nick = ?)" =>
> $userNick);
>
> As long as your nicks are unique, this will work. Note that this will produce
> an error on MS SQL due to a PHP bug.
>
> Regards,
> Bryce Lohr
>
> ViShap wrote:
>
> 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" ?
>
>
>
> 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
>
> ViShap
>
>
>
> -----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/