本文整理匯總了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));
}