phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

[BUG] wrong SQL statements #1631

Closed le51 closed 9 years ago

le51 commented 10 years ago

Vols::find(array("columns"=>array("cdt_de_bord_id","cdt_de_bord"), "order"=>"cdt_de_bord ASC","distinct"=>"cdt_de_bord_id"))

and

$query = $this->modelsManager->createQuery("SELECT DISTINCT cdt_de_bord_id, cdt_de_bord FROM Vols ORDER BY cdt_de_bord"); $cdb = $query->execute();

result this Postgresql log:

`exécute pdo_stmt_0000000a: SELECT "vols"."cdt_de_bord_id" AS "cdt_de_bord_id", "vols"."cdt_de_bord" AS "cdt_de_bord" FROM "public"."vols" ORDER BY "vols"."cdt_de_bord" ASC

is there something wrong ?

Postgresal & phalcon 1.3

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

le51 commented 10 years ago

Workaround with :

$pilotes = $this->db->fetchAll("SELECT DISTINCT cdt_de_bord_id, cdt_de_bord FROM vols ORDER BY cdt_de_bord", Phalcon\Db::FETCH_NUM); //this give the correct response $this->view->setVar('pilotes',$pilotes);

and in view:

``

but it seems that modelManager doesn't translate correctly the request and escape the DISTINCT keyword.

andresgutierrez commented 9 years ago

Can you please try again using Phalcon 2 or close this issue?