Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update multiple fields at same time to different t

Author  Topic 

el.severo
Starting Member

3 Posts

Posted - 2009-02-08 : 10:44:16
Hi there,
I`m trying to perform an multiple update in the same time using J 1.5


$_CB_database->setQuery( "UPDATE #__comprofiler SET avatar = " . $_CB_database->Quote( 'gallery/' . $newAvatar )
. ", avatarapproved=1, lastupdatedate = " . $_CB_database->Quote( date('Y-m-d H:i:s') )
. " WHERE id = " . (int) $row->id);
$_CB_database->setQuery( "UPDATE #__mycom SET avatar = " . $_CB_database->Quote( 'gallery/' . $newAvatar )
. " WHERE user_id = " . (int) $row->id);


Right now it performs only to the second table #__mycom [ jos_mycom ].

Please help & Thank you!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-08 : 10:55:12
You can only perform one query at a time in a single thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tonymorell10
Yak Posting Veteran

90 Posts

Posted - 2009-02-08 : 11:01:50
You should be able to concatenate the two statements together into a single query and run both as a unit.


$_CB_database->setQuery( "UPDATE #__comprofiler SET avatar = " . $_CB_database->Quote( 'gallery/' . $newAvatar )
. ", avatarapproved=1, lastupdatedate = " . $_CB_database->Quote( date('Y-m-d H:i:s') )
. " WHERE id = " . (int) $row->id
. "; UPDATE #__mycom SET avatar = " . $_CB_database->Quote( 'gallery/' . $newAvatar )
. " WHERE user_id = " . (int) $row->id
.";")
Go to Top of Page

el.severo
Starting Member

3 Posts

Posted - 2009-02-08 : 16:01:25
Hi tonymorell10!,

Thank you for your post but I don`t know why it doesn't work and I've changed how you've done in the previous post, here is it:


$_CB_database->setQuery( "UPDATE #__comprofiler SET avatar = " . $_CB_database->Quote( 'gallery/' . $newAvatar )
. ", avatarapproved=1, lastupdatedate = " . $_CB_database->Quote( date('Y-m-d H:i:s') )
. " WHERE id = " . (int) $row->id
. "; UPDATE #__mycom SET avatar = " . $_CB_database->Quote( 'gallery/' . $newAvatar )
. " WHERE user_id = " . (int) $row->id
.";");
if( ! $_CB_database->query() ) {
$msg = _UE_USER_PROFILE_NOT;
}

Go to Top of Page

el.severo
Starting Member

3 Posts

Posted - 2009-02-09 : 17:16:43
how should I write it to work?
Go to Top of Page
   

- Advertisement -