Tuesday, August 20, 2013, 6:08:19 PM, Jonas wrote:
> On 08/20/2013 06:03 PM, Gergo Csibra wrote:
>> Tuesday, August 20, 2013, 5:47:24 PM, Gareth wrote:
>>
>>> On 20/08/13 14:53, Jonas Kellens wrote:
>>>> Hello,
>>>>
>>>> how can I obtain the "inserted ID" after having inserted a row with
>>>> MySQL in the dialplan ?
>>>>
>>>> exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO myTable SET
>>>> C1="${ARG1}", C2="${ARG2}",
>>>> timestamp="${STRFTIME(${EPOCH},,%Y-%m-%d_%H:%M:%S)}")
>>>>
>>>> I need to know the ID of the newly inserted row.
>>> You could write an AGI script in something like php or perl and get it
>>> to write to the mysql database instead. It can then set a variable which
>>> the dialplan can pick up.
>> meh...
>>
>> SELECT LAST_INSERT_ID()
>>
> Hello,
> can I echo this variable ?
Like : exten =>> s,n,NoOp(${LAST_INSERT_ID()})
No, this is a mysql query, so:
exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO myTable SET
C1="${ARG1}", C2="${ARG2}",
timestamp="${STRFTIME(${EPOCH},,%Y-%m-%d_%H:%M:%S)}")
exten => s,n,MYSQL(Query resultid ${connid} SELECT LAST_INSERT_ID())
exten =>> s,n,NoOp(${resultid})
first is your original insert query, next you must read the
last_insert_id() mysql function with an other query, then you can
echo the resultid variable which contains the last inserted id.
--
Best regards,
Gergo mailto:[email protected]
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users