public object where(string $columns, mixed $value [, string $operator = '='])
数据库字段名称
字段的值
支持的操作符 =, !=, <, > , 默认值 =
操作成功返回 Object, 失败返回 false
<?php use Asf\Db\QueryBuilder\Select; $select = new Select(); $select->cols() ->from('test1') ->where('id', '100', '>') ->where('status', 2) ->unionAll() ->select() ->cols() ->from('test1') ->where('id', '50', '<'); // string(132) "[SQL] SELECT * FROM `test1` WHERE `id` > ? AND `status` = ? UNION ALL SELECT * FROM `test1` WHERE `id` < ? [BVALUES] 100 , 2 , 50" var_dump($select->show()); $select->clear(); $select->cols('id, user') ->from('test1', 'a') ->where('sid', 1) ->limit(0, 1); // string(78) "[SQL] SELECT id, user FROM `test1` a WHERE `sid` = ? LIMIT 0, 1 [BVALUES] 1" var_dump($select->show());
<?php use Asf\Db; $select = Db::QBS(); $select->cols() ->from('test1') ->where('id', '100', '>') ->where('status', 2) ->unionAll() ->select() ->cols() ->from('test1') ->where('id', '50', '<'); // string(132) "[SQL] SELECT * FROM `test1` WHERE `id` > ? AND `status` = ? UNION ALL SELECT * FROM `test1` WHERE `id` < ? [BVALUES] 100 , 2 , 50" var_dump($select->show()); $select->clear(); $select->cols('id, user') ->from('test1', 'a') ->where('sid', 1) ->limit(0, 1); // string(78) "[SQL] SELECT id, user FROM `test1` a WHERE `sid` = ? LIMIT 0, 1 [BVALUES] 1" var_dump($select->show());