本文整理汇总了PHP中QueryBuilder::from方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::from方法的具体用法?PHP QueryBuilder::from怎么用?PHP QueryBuilder::from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::from方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWhereWithNull
function testWhereWithNull()
{
$builder = QueryBuilder::from('users')->where('email', null);
$expected = 'SELECT * FROM users WHERE email IS NULL';
$this->assertEquals($expected, $builder->toSql());
}
示例2: define
require_once 'config.php';
require_once 'libs/Bootstrap.php';
require_once 'libs/QueryBuilder.php';
// Authentication token
$token = $peregrine->session->getUsername('username') . $peregrine->server->getRaw('REMOTE_ADDR');
if (!$auth->checkToken($token, $peregrine->session->getRaw('token'))) {
exit;
}
if (!defined('MYSQL_PREFIX')) {
define('MYSQL_PREFIX', 'prism_');
// Old config files may not have the constant defined yet.
}
// Build query
$qb = new QueryBuilder();
$qb->select('id, epoch, action, player, world, x, y, z, block_id, block_subid, old_block_id, old_block_subid, data');
$qb->from(MYSQL_PREFIX . 'data', 'd');
$qb->join('INNER JOIN ' . MYSQL_PREFIX . 'players p ON p.player_id = d.player_id');
$qb->join('INNER JOIN ' . MYSQL_PREFIX . 'actions a ON a.action_id = d.action_id');
$qb->join('INNER JOIN ' . MYSQL_PREFIX . 'worlds w ON w.world_id = d.world_id');
$qb->join('LEFT JOIN ' . MYSQL_PREFIX . 'data_extra ex ON ex.data_id = d.id');
// World
if (!$peregrine->post->isEmpty('world')) {
$world = explode(",", $peregrine->post->getUsername('world'));
$qb->where(QueryBuilder::buildOrQuery('w.world', $world));
}
// Coordinates
if (!$peregrine->post->isEmpty('x', false, false) && !$peregrine->post->isInt('y', false, false) && !$peregrine->post->isInt('z', false, false)) {
$x = $peregrine->post->getInt('x');
$y = $peregrine->post->getInt('y');
$z = $peregrine->post->getInt('z');
if (!$peregrine->post->isInt('radius', false, false)) {