fluentpdo
fluentpdo copied to clipboard
Excessive a.* clause
$query = new \Envms\FluentPDO\Query($this->pdo);
$query = $query
->from('articles AS a')
->select("a.id, a.title, a.cdate")
->where("a.s_hidden = 0")
->where("a.s_draft = 0")
->leftJoin("articles_keys AS ak ON ak.aid = a.id")
->orderBy("a.cdate DESC")
->groupBy("a.id");
var_dumo( $query->getQuery() );
Have a result:
SELECT a.*, a.id, a.title, a.cdate
FROM articles AS a
LEFT JOIN articles_keys AS ak ON ak.aid = a.id
WHERE a.s_hidden = 0
AND a.s_draft = 0
GROUP BY a.id
ORDER BY a.cdate DESC
@KarelWintersky Just add second argument overrideDefault to select()
->select("a.id, a.title, a.cdate", true)
... and no any info at readme... :-(
If you don't want everything from the table, use ->select(null)
, this was documented in the past.
$query = new \Envms\FluentPDO\Query($this->pdo);
$query = $query
->from('articles AS a')
->select(null)
->select("a.id, a.title, a.cdate")
->where("a.s_hidden = 0")
->where("a.s_draft = 0")
->leftJoin("articles_keys AS ak ON ak.aid = a.id")
->orderBy("a.cdate DESC")
->groupBy("a.id");
var_dumo( $query->getQuery() );