Yii Framework Forum: mysql error with query builder - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

mysql error with query builder DAO, query builder, table prefix Rate Topic: -----

#1 User is offline   kiennguyen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 28-August 11

Posted 08 May 2012 - 12:53 PM

I'm trying to build a custom sql query with query builder. However, I've got a problem with it.

$sql = "SELECT m.* FROM tbl_messages m LEFT JOIN tbl_bids b ON (m.message_id = b.message_id) WHERE m.project_id=:project_id AND b.bid_id is null";
        $command = Yii::app()->db->createCommand($sql);
        $command->bindParam(':project_id',$project_id,  PDO::PARAM_INT);
        $messages = $command->queryAll();

-> work

$sql = "SELECT m.* FROM {{messages}} m LEFT JOIN {{bids}} b ON (m.message_id = b.message_id) WHERE m.project_id=:project_id AND b.bid_id is null";       

-> generate 1064 error

        $sql = "SELECT m.* FROM `{{messages}}` m LEFT JOIN `{{bids}}` b ON (m.message_id = b.message_id) WHERE m.project_id=:project_id AND b.bid_id is null";

-> error: Base table or view not found: 1146 Table {{messages}} doesn't exist.


Can anyone please explain to me why this is happening?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users