本文整理汇总了PHP中SelectQuery::parameters方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::parameters方法的具体用法?PHP SelectQuery::parameters怎么用?PHP SelectQuery::parameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::parameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSelectSomeFromOneTable
public function testSelectSomeFromOneTable()
{
$q = new SelectQuery(array('test'));
$q->setWhere(new Condition('=', new Field('somefield'), 35));
$q->setLimit(10, 2);
$this->assertEquals('SELECT `t0`.* FROM `test` AS `t0` WHERE `t0`.`somefield` = :p1 LIMIT 10 OFFSET 2', $q->sql());
$params = $q->parameters();
$this->assertEquals(35, $params[':p1']);
}
示例2: testSqlFunctions
public function testSqlFunctions()
{
$f = new SqlFunction('substring', array(new Field('name'), 5, 2));
$params = array();
$this->assertEquals('SUBSTRING(`t0`.`name`, 5, 2)', $f->getSql($params));
$this->assertEquals('substring', $f->getName());
try {
$f = new SqlFunction('there_is_no_such_function', new Field('name'));
$this->fail();
} catch (InvalidArgumentException $e) {
}
try {
$f = new SqlFunction('substring', new AndOp(array()));
$this->fail('wrong value accepted');
} catch (InvalidArgumentException $e) {
}
$q = new SelectQuery('test');
$q->setWhere(new Condition('>', new SqlFunction('length', new Field('foo')), 5));
$params = array();
$this->assertEquals('SELECT `t0`.* FROM `test` AS `t0` WHERE LENGTH(`t0`.`foo`) > :p1', $q->sql());
$parameters = $q->parameters();
$this->assertEquals('5', $parameters[':p1']);
}