本文整理汇总了PHP中Propel\Runtime\ActiveQuery\ModelCriteria::getFormatter方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelCriteria::getFormatter方法的具体用法?PHP ModelCriteria::getFormatter怎么用?PHP ModelCriteria::getFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\ModelCriteria
的用法示例。
在下文中一共展示了ModelCriteria::getFormatter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFormatter
public function testFormatter()
{
$c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
$this->assertTrue($c->getFormatter() instanceof AbstractFormatter, 'getFormatter() returns a PropelFormatter instance');
$c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
$c->setFormatter(ModelCriteria::FORMAT_STATEMENT);
$this->assertTrue($c->getFormatter() instanceof StatementFormatter, 'setFormatter() accepts the name of a AbstractFormatter class');
try {
$c->setFormatter('Propel\\Tests\\Bookstore\\Book');
$this->fail('setFormatter() throws an exception when passed the name of a class not extending AbstractFormatter');
} catch (InvalidArgumentException $e) {
$this->assertTrue(true, 'setFormatter() throws an exception when passed the name of a class not extending AbstractFormatter');
}
$c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
$formatter = new StatementFormatter();
$c->setFormatter($formatter);
$this->assertTrue($c->getFormatter() instanceof StatementFormatter, 'setFormatter() accepts a AbstractFormatter instance');
try {
$formatter = new Book();
$c->setFormatter($formatter);
$this->fail('setFormatter() throws an exception when passed an object not extending AbstractFormatter');
} catch (InvalidArgumentException $e) {
$this->assertTrue(true, 'setFormatter() throws an exception when passed an object not extending AbstractFormatter');
}
}
示例2: testFormatterWithSelect
public function testFormatterWithSelect()
{
$c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
$c->keepQuery(false);
// just for this test's purpose
$c->setFormatter(ModelCriteria::FORMAT_ON_DEMAND);
$c->select(array('Id', 'Title'));
$rows = $c->find($this->con);
$this->assertTrue($c->getFormatter() instanceof \Propel\Runtime\Formatter\OnDemandFormatter, 'The formatter is preserved');
}