I'm sure we all agree writing plain SQL can be a pain and nothing can compare to it in flexibility. I've been playing around with some stuff, and I guess I have two alternatives I'd like to run by you guys:
Code: Select all
$query = new Query();
$query->select ()
->from ('table1')
->innerJoin ('table2')
->on ('table1.id = table2.table_id')->or ('table2.color', $color)
->where ('num > :num', $num)
->limit ('20')
->orderBy ('id', 'asc')
->execute();
$query = new Query();
$query->insert->into ('table1')->set($fields)->execute();or
Code: Select all
$query = new Query ('SELECT * FROM table1')
->append ('LEFT JOIN table2 ON :conditions');
$conditions = new Query ('table1.id = table2.table OR table2.color = :color');
$conditions->bind (':color', $color);
$query->bind (':conditions', $conditions)
-> append ('WHERE num > :num LIMIT :limit ORDER BY :order_by ASC')
-> bind (':num', $num)
-> bind (':limit', 20)
-> bind (':order_by', 'id')
-> execute();
$query = new query ('INSERT INTO table1 SET :fields')
-> bind (':fields, $fields)
-> execute();