Query with doctrine 1

I try to make the following sql query from phpMyAdmin who works perfectly and return 1 result with doctrine 1 but i get an exception :

SQLSTATE[42S22]: Column not found: 1054 Champ ‘MOY1100’ inconnu dans
where clause. Failing Query: “select id_au FROM acteur_unite WHERE
code_unite = MOY1100 LIMIT 1”

Here the sql query who work on phpMyAdmin :

SELECT id_au FROM acteur_unite WHERE code_unite = ‘MOY1100’ LIMIT 1

Here my query with doctrine :

 public function getId($code_unite) {

        $con = Doctrine_Manager::getInstance()->connection();

        $st = $con->execute("select id_au FROM acteur_unite
            WHERE code_unite = $code_unite LIMIT 1");

        $id = null;
        // fetch query result
        $data = $st->fetch(PDO::FETCH_ASSOC);
        $id = $data['id_au'];
        return $id;
    }

Where i’m wrong ?

Thanks a lot in advance

Source: Symfony1 Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *