I am trying to get data from several tables and I ended up with this error: SQL: SQLSTATE [42S22]: Column not found: 1054 Unknown column "p.firstname" in the "list of fields"
$criteria = new CDbCriteria; $criteria->select = 'ohu_id, hash, p.firstname, p.surname, p.city, u.email AS Email'; $criteria->join = 'LEFT JOIN `profiles` p ON p.user_id = user_id'; $criteria->join = 'LEFT JOIN users u ON user_id = u.id'; $criteria->condition = 'offer_id = :oID'; $criteria->params = array(':oID' => $_GET['id']); $model = MyModel::model()->findAll($criteria);
Does anyone know what I'm doing wrong? Or is there a better way to get related data?
source share