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.

2 Responses to “Delphi for PHP - INSERT with QUERY”

  1. on 06 Sep 2008 at 5:31 pmRichard Rodriquez

    “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.”

    GREAT COMMENT! I am two days into using the 30 trial of delphi for php. So far I love delphi for php except for that fact that there are no books or useful tutorials out there. Database connectivity is so easy in delphi for php. The only thing is that is missing in this example is that the VCL query has to be connected to registered database.

    1.) In your project window on the upper right side click the “Data Explorer” tab.

    2.) I am using MySQL. Drill down to the MySQL database and right click it.

    3.) In the dialog box that appears click Register Database.

    4.) Put the appropriate information for the database connectivity, like server name, database name, user name and password. Once you have made a valid connection you will see your database in the “Data Explorer”;

    5.) Drag that database onto your form, application, or whatever you are working on.

    6.) Drag the VCL query icon from the “Tool Palette” onto your project and in the VCL sql objects properties set the “Database” to database you dragged onto your project.

    Now the above example I am commenting on should make a little more sense to us noobies.

    It took me a minute to figure this one out. I am a noobie so I hope this helps someone out there.

  2. on 04 Oct 2009 at 12:50 ammursalim hsd

    thanks for your great comment. It took me a minute to figure this one out. I am a newbie also so I thanksfull for your post.

Trackback this post | Feed on Comments to this post

Leave a Reply