Hi all, I am trying to query a relationship between two tables in my database. I am matching a user_id in a table called property with the user_id in the user table. The SQL command should be SELECT COUNT() FROM tbl_property
WHERE user_id=. I am getting an error of the following: 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 1. The SQL statement executed was: SELECT COUNT() FROM tbl_property
t
WHERE user_id=
Posted below is my code:
Property Model:
public function getUserAssignedProperty()
{
return new CActiveDataProvider($this, array(
'criteria'=>array(
'condition'=>'user_id='.Yii::app()->user->getState('user_id'),
'order'=>'property_id DESC'
),
));
}
Hand Receipt View:
<?php
$this->beginWidget('bootstrap.widgets.TbBox', array(
'title' => 'Hand Receipt',
'headerIcon' => 'icon-home',
'htmlOptions' => array('class'=>'bootstrap-widget-table'),
)); ?>
<?php echo $this->renderPartial('_handReceipt',array('model'=>$model, 'provider'=>$model->getUserAssignedProperty())) ?>
<?php $this->endWidget();?>
Right now I don’t have anything in _handReceipt as it isn’t making it that far. Any help would be awesome. Thanks.