How do I get insert id after using R::exec

69 views
Skip to first unread message

Ramadhan Amizudin

unread,
Mar 5, 2015, 1:58:38 PM3/5/15
to redbe...@googlegroups.com
Hi, for the odd reason I had to use R::exec function to insert new data.
The problem is, how do I get insert id after doing R::exec?

Thanks.

gabor

unread,
Mar 7, 2015, 5:48:34 AM3/7/15
to redbe...@googlegroups.com

R::$adapter->getInsertID()

or in 4.2 beta 3:

R::getInsertID()

cheers
Gabor

Will Blackamoor

unread,
Jan 20, 2016, 3:19:27 PM1/20/16
to redbeanphp
Hi Gabor, rather than open a new thread i thought i would rather ask here. Is there a method for getting the affected rows from an Atomic/Conditional Update Query. Since its conditional i had to Use exec, but i haven't been able to find any information about it so far on google.

gabor

unread,
Jan 20, 2016, 3:27:19 PM1/20/16
to redbeanphp

Hi,

R::exec will return the number of affected rows.

R::setup();
R
::store(R::dispense('bean')->setAttr('xname','beanie'));
$x
= R::exec('UPDATE bean SET xname = 1234 WHERE id < 2');
var_dump
($x);




Outputs: 1

cheers
Gabor
Reply all
Reply to author
Forward
0 new messages