malenki/desbaies

一些类,用于创建无需SQL代码的SQL查询。

0.1.0 2013-04-23 21:30 UTC

This package is not auto-updated.

Last update: 2024-09-23 11:54:18 UTC


README

一些类,用于创建无需SQL代码的SQL查询。也允许执行,但没有ORM层。

简单示例

use \Malenki\DesBaies;

$db = new DesBaies();
$db->select->add('foo');
$db->from->add('bar');

give

SELECT `foo`
FROM `bar`;

更复杂示例

use \Malenki\DesBaies;

$db = new DesBaies();
$db->select->add('foo', 'b')->add('foo2', 'b2');
$db->from->add('bar', 'b');
$db->from->add('bar2', 'b2');
$db->order->by('foo', 'b')->desc->by('foo2', 'b2');

give

SELECT `b`.`foo`, `b2`.`foo2`
FROM `bar` AS `b`, `bar2` AS `b2`
ORDER BY `b`.`foo` DESC, `b2`.`foo2` ASC;