[Vtigercrm-developers] Right way to check result of ADO Insert/Update
Alan Lord (News)
alanslists at gmail.com
Mon Jul 14 07:17:22 GMT 2014
Thanks all,
very helpful information.
Al
On 13/07/14 22:08, Stencel, Maciej wrote:
> 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
> <mailto: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
> <mailto: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/
>
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>
--
Libertus Solutions
http://www.libertus.co.uk
More information about the vtigercrm-developers
mailing list