Runtime error when DBSimpleQuery SQL Sentence includes single quotes

VictorUlloa, Wed Jun 23 2021, 10:20PM

STEPS To reproduce:

Put a cDBSimpleQuery in any form.  Set the SQL property to any query containing a constant string, like this:

select 'X' as hilera

Run the form.

Error message
:Parse error: syntax error, unexpected 'X' (T_STRING) in C:PHsPeedxampphtdocsgestionit_libstest2_dbsquery_1.php on line 12

The generated file looks like this:

class test2_dbsquery_1 extends spdbsimplequery {
   public function __construct($app, $form) {
      parent::__construct('test2_dbsquery_1');
      $this->app=$app;
      $this->sql='select 'X' as hilera';
}

This does not happens if I use a cDBQuery, because the assignment to the sql property is enclosed in double quotes:
(taken from another, cDBQuery component generated file)

...
$this->selectSQL="select pkCasa,nombreCasa,'X' as hilera ".
...

 

Re: Runtime error when DBSimpleQuery SQL Sentence includes single quotes
administrator, Thu Jun 24 2021, 07:13PM

Issue is fixed. See link