function testWhereWithNull() { $builder = QueryBuilder::from('users')->where('email', null); $expected = 'SELECT * FROM users WHERE email IS NULL'; $this->assertEquals($expected, $builder->toSql()); }
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)) {