[Vtigercrm-developers] Right way to check result of ADO Insert/Update
Stencel, Maciej
m.stencel at opensaas.pl
Sun Jul 13 21:08:17 GMT 2014
Hi Alan,
I'm not sure if You're asking specificly about this but:
Successfull update:
$database->getAffectedRowCount( $result ); // returns number of affected
rows in last INSERT, UPDATE, REPLACE or DELETE
If it's above zero then some records were changed (if query was successfull
but didnt change any records then it will return zero). But still You can
be sure that query went ok.
If You want to check if the record was inserted then You can try to get the
ID of newly inserted record. When it is valid You can be sure that You
inserted records to db.
$database->getLastInsertID();
And You can use in your query variable that will breake script if query
will fail, set second/third parameter as true;
$database->query( $sql, true )
$database->pquery( $sql, $params, true )
Applies to Vt 6.0 and 6.1.
*Z poważaniem / Best regards*
*Maciej Stencel*
*Tel: +48 884-997-123*
*m.stencel at opensaas.pl <m.stencel at opensaas.pl>*
*skype: **ms.opensaas*
*www.OpenSaaS.pl <http://www.opensaas.pl/>*
2014-07-13 18:33 GMT+02:00 Joe Bordes <joe at tsolucio.com>:
> Looking at adodb library this structure seems to be used frequently:
>
> if (!$rs->EOF)
>
> and I think I have seen some of that in vtiger crm itself also.
>
>
>
> El 13/07/14 18:22, Alan Lord (News) escribió:
>
>> I know, i've been developing on vtiger for *years* but I've never really
>> been sure how to check for a successful INSERT or UPDATE query?
>>
>>
>> The ADO_recordset result object is empty and has EOF = 1.
>>
>> What is the "right" way to test for a successful save and what would the
>> recordset look like if it had failed?
>>
>> Thanks
>>
>> Al
>>
>>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140713/cb2e3394/attachment.html>
More information about the vtigercrm-developers
mailing list