CDbCommand->bindValue/Param width query();

Hi, I have serious problem to use bindParam/Value together with SELECT statments using query(), it works fine with INSERT using execute().

Why is that? :-\

What is the problem? More details on how to reproduce it?

This one works perfect:

            $sql = "INSERT INTO BibleVerses_BibleVerseIndex(BibleVersesID, BibleVerseIndexID) VALUES(:BibleVersesID, :BibleVerseIndexID)";

            foreach($bverse as $v)

            $verses["{$v['book']} {$v['chapter']} {$v['verse']}"] = $v['id'];

            foreach($bvindex as $v)

            $verseindex["{$v['book']} {$v['chapter']} {$v['verse']}"] = $v['id'];

            foreach($verses as $key => $value)

                if(array_key_exists($key, $verseindex))


                    $bverse = $db->createCommand($sql);





This doesn't work:

        $sql = <<<EOD

SELECT bvi.Book AS book, bvi.Chapter AS chapter, bvi.Verse AS verse, bv.Text AS text

FROM BibleVerseIndex bvi


  BibleVerses_BibleVerseIndex bvbvi,

  BibleVerses bv,

  BibleTranslations bt)


  bvi.BibleVerseIndexID = bvbvi.BibleVerseIndexID AND

  bvbvi.BibleVersesID = bv.BibleVersesID AND

  bv.BibleTranslationsID = bt.BibleTranslationsID)


  bt.Translation = ':translation' AND

  bvi.Book = ':book'


        $command = Yii::app()->db->createCommand($sql);

        $command->bindParam(':translation', $this->_translation, PDO::PARAM_STR);

        $command->bindParam(':book', $book, PDO::PARAM_STR);

        return $command->query();

You should remove those quotes around the parameter placeholders.


Works, thanks

I meet the same problem, thanks, it works well now.