Posts RSS Comments RSS

Delphi for PHP - INSERT with QUERY

If you don’t know very well the VCL for PHP and you try to insert a new record using a Query component, you will likely get this error:
Application raised an exception class ADODB_Exception with message ‘mysql error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LIMIT 0,10′ at line …
A workaround for this is to disable the LIMIT command at runtime or design-time by setting LimitStart and LimitCount to ‘-1′;
An example how to disable this at runtime:

$query = “INSERT INTO table (field1,field2) VALUES(’” . $value1 . “‘,’” . value2 . “‘)”;

$this->Query1->close();
$this->Query1->LimitStart = ‘-1′;
$this->Query1->LimitCount = ‘-1′;
$this->Query1->SQL = $query;
$this->Query1->open();

I got this solution after studying the ECommerce sample project.

Trackback this post | Feed on Comments to this post

Leave a Reply