本文整理汇总了PHP中Doctrine\ODM\MongoDB\Types\Type::convertPHPToDatabaseValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::convertPHPToDatabaseValue方法的具体用法?PHP Type::convertPHPToDatabaseValue怎么用?PHP Type::convertPHPToDatabaseValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\Types\Type
的用法示例。
在下文中一共展示了Type::convertPHPToDatabaseValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ensureArray
/**
* @param mixed|self $expression
* @return mixed
*/
protected function ensureArray($expression)
{
// Convert field names in expressions
if (is_string($expression) && substr($expression, 0, 1) === '$') {
return '$' . $this->getDocumentPersister()->prepareFieldName(substr($expression, 1));
}
// Convert PHP types to MongoDB types for everything else
return Type::convertPHPToDatabaseValue(parent::ensureArray($expression));
}
示例2: prepareQueryOrNewObj
/**
* Prepares the query criteria or new document object.
*
* PHP field names and types will be converted to those used by MongoDB.
*
* @param array $query
* @return array
*/
public function prepareQueryOrNewObj(array $query)
{
$preparedQuery = array();
foreach ($query as $key => $value) {
// Recursively prepare logical query clauses
if (in_array($key, array('$and', '$or', '$nor')) && is_array($value)) {
foreach ($value as $k2 => $v2) {
$preparedQuery[$key][$k2] = $this->prepareQueryOrNewObj($v2);
}
continue;
}
if (isset($key[0]) && $key[0] === '$' && is_array($value)) {
$preparedQuery[$key] = $this->prepareQueryOrNewObj($value);
continue;
}
list($key, $value) = $this->prepareQueryElement($key, $value, null, true);
$preparedQuery[$key] = is_array($value) ? array_map('\\Doctrine\\ODM\\MongoDB\\Types\\Type::convertPHPToDatabaseValue', $value) : Type::convertPHPToDatabaseValue($value);
}
return $preparedQuery;
}
示例3: testConvertImmutableDate
public function testConvertImmutableDate()
{
$date = new \DateTimeImmutable('now');
$this->assertInstanceOf('\\MongoDate', Type::convertPHPToDatabaseValue($date));
}