本文整理汇总了PHP中Cake\Database\Query::defaultTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::defaultTypes方法的具体用法?PHP Query::defaultTypes怎么用?PHP Query::defaultTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Database\Query
的用法示例。
在下文中一共展示了Query::defaultTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDefaultTypes
/**
* Tests that default types are passed to functions accepting a $types param
*
* @return void
*/
public function testDefaultTypes()
{
$query = new Query($this->connection);
$this->assertEquals([], $query->defaultTypes());
$types = ['id' => 'integer', 'created' => 'datetime'];
$this->assertSame($query, $query->defaultTypes($types));
$this->assertSame($types, $query->defaultTypes());
$results = $query->select(['id', 'comment'])->from('comments')->where(['created >=' => new \DateTime('2007-03-18 10:55:00')])->execute();
$expected = [['id' => '6', 'comment' => 'Second Comment for Second Article']];
$this->assertEquals($expected, $results->fetchAll('assoc'));
// Now test default can be overridden
$types = ['created' => 'date'];
$results = $query->where(['created >=' => new \DateTime('2007-03-18 10:50:00')], $types, true)->execute();
$this->assertCount(6, $results, 'All 6 rows should match.');
}