Cdbcommand Failed To Execute The Sql Statement: Sqlstate[42000]: Syntax Error Or Access Violation:

Everything works fine on localhost but after i have uploaded to host i get 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 '' at line 3. The SQL statement executed was: SELECT *

FROM `Image`

WHERE

It looks like its not recognizing the where parameters, but why it does locally but not once I have uploaded to a host

Here is the code that i have in my view that is generating the error




<?php

 $rows = Yii::app()->db->createCommand()

    ->from("Image")

    ->where(array("types = admin"))

    ->queryAll();

foreach($rows as $row)

{


    $imghtml=CHtml::image(Yii::app()->request->baseUrl.'/images/thumb/'.$row['image']);

    echo '<a class = "image" href="'.Yii::app()->request->baseUrl.'/generator/create?image='.$row['image'].'">'.$imghtml.'</a>   ';


}


?>



It’s interesting it worked at all. The signature of CDbCommand.where( is quite different from the way you invoke it. I’m also not quite sure where that ‘admin’ string comes from. IMHO, this should work a lot better:




<?php

 $rows = Yii::app()->db->createCommand()

    ->from("Image")

    ->where("types = 'admin'")

    ->queryAll();



And while we’re at it: You should really pass the href-part of your generated links through CHtml::encode().