Welcome Guest, Not a member yet? Register   Sign In
advanced UPDATE call
#1

[eluser]Unknown[/eluser]
I am trying to do a more complicated UPDATE which I think I cannot do using the built in ActiveRecord update() function.
But when I try the "manual" method (the specific tables and joins are not relevant, the issue appears to be that a query() call that does not have a SELECT does not produce something I can call result() on:

$this->db
->query( "UPDATE participants p
JOIN contactIsUserAlias ciua ON ciua.contactID=p.contactID
SET status = ?
WHERE ciua.userID=?
AND p.eventID=?
AND p.userID=?",
array( $status, $userID, $eventID, $organizer_userID ) )
->result();

I get this php error:
Call to a member function result() on a non-object

Can anybody suggest a solution ?
Is *just* calling query - without the call to result() - already enough, i.e. will it actually execute the update statement ?

Thanks in advance
Robert
#2

[eluser]Unknown[/eluser]
Forgive me for answering my own question, but a bit of experimentation determined that indeed the query() call alone will execute the mysql update statement. So just taking away the result() call fixed this problem.
#3

[eluser]CI_avatar[/eluser]
i happy you figured it out. $this->db->result() is used to get result from queried data.




Theme © iAndrew 2016 - Forum software by © MyBB