CDbCommand failed to execute the SQL statement

I am getting this error when I am trying to get data


CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 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 '14 LIMIT 10' at line 1. The SQL statement executed was: 14 LIMIT 10 

What does it indicate?

What is the generated SQL or at least the code that generates this?

Found The problem I was using queryscalar for my command which was returning 14 in cActivedataprovider

I am now getting the following error




CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or 

access violation: 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 'Array LIMIT 10' at line 1. The SQL 

statement executed was: Array LIMIT 10 


 

print_r($dataProvider); provides me the following




CSqlDataProvider Object ( [db] => [sql] => Array ( [id] => 14 [member] => fghdfgfd )

[params] => Array ( ) 

[keyField] => id [_id:CDataProvider:private] => [_data:CDataProvider:private] => 

[_keys:CDataProvider:private] => [_totalItemCount:CDataProvider:private] => 

[_sort:CDataProvider:private] => [_pagination:CDataProvider:private] => CPagination

Object ( [pageVar] => page [route] => [params] => [validateCurrentPage] => 1 

[_pageSize:CPagination:private] => 10 [_itemCount:CPagination:private] => 0 

[_currentPage:CPagination:private] => [_e:CComponent:private] => 

[_m:CComponent:private] => ) [_e:CComponent:private] => [_m:CComponent:private] => )

 

what is the code you use?




$rowx = Yii::app()->db->createCommand($sqlx)->queryAll();

 $this->render('results',array('model'=>$rowx));



Where


 $sqlx= "select `dob`, `id` from `details` where `dob` >'".$agelow."' and `dob` <'".$agehigh."'  ";

where agelow and agehigh are properly got from the form

This seems OK… the error is fired somewhere else… as there is no LIMIT applied…

use BETWEEN

Thanks

I a am now getting this error


Fatal error: Call to a member function getData() on a non-object in C:\wamp\www\yii\framework\zii\widgets\CBaseListView.php on line 105

any ideas?

In your #4 post it looked like you fed the result from a DAO query to a CSqlDataProvider. The current error message indicates you don’t pass a valid dataprovider instance (IDataProvider implementation) to the view.

BTW did you try to use the original SQL string with a CSqlDataProvider?

/Tommy

Yes I had tried that also same error

I got error like


CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe près de 'VARCHAR, 20)' à la ligne 1. The SQL statement executed was: INSERT INTO form1 (lable ,field ,type, size) VALUES (firstname, fname, VARCHAR, 20);

at where my sql stetment is


$sql1="INSERT INTO form1 (lable ,field ,type, size) VALUES ($my1Inputs[$i], $my2Inputs[$i], $my3Inputs[$i], $my4Inputs[$i]);";

$list1= Yii::app()->db->createCommand($sql1)->execute();

values are coming dynamically and right but statement can’t execute.

please help me for solve it.