本文整理匯總了PHP中Doctrine_Table::enumIndex方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Table::enumIndex方法的具體用法?PHP Doctrine_Table::enumIndex怎麽用?PHP Doctrine_Table::enumIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine_Table
的用法示例。
在下文中一共展示了Doctrine_Table::enumIndex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseValue
public function parseValue($value, Doctrine_Table $table = null, $field = null)
{
if (substr($value, 0, 1) == '(') {
// trim brackets
$trimmed = $this->_tokenizer->bracketTrim($value);
if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') {
// subquery found
$q = new Doctrine_Query();
$value = '(' . $this->query->createSubquery()->parseQuery($trimmed, false)->getQuery() . ')';
} elseif (substr($trimmed, 0, 4) == 'SQL:') {
$value = '(' . substr($trimmed, 4) . ')';
} else {
// simple in expression found
$e = $this->_tokenizer->sqlExplode($trimmed, ',');
$value = array();
$index = false;
foreach ($e as $part) {
if (isset($table) && isset($field)) {
$index = $table->enumIndex($field, trim($part, "'"));
}
if ($index !== false) {
$value[] = $index;
} else {
$value[] = $this->parseLiteralValue($part);
}
}
$value = '(' . implode(', ', $value) . ')';
}
} else {
if (substr($value, 0, 1) == ':' || $value === '?') {
// placeholder found
if (isset($table) && isset($field) && $table->getTypeOf($field) == 'enum') {
$this->query->addEnumParam($value, $table, $field);
} else {
$this->query->addEnumParam($value, null, null);
}
} else {
$enumIndex = false;
if (isset($table) && isset($field)) {
// check if value is enumerated value
$enumIndex = $table->enumIndex($field, trim($value, "'"));
}
if ($enumIndex !== false) {
$value = $enumIndex;
} else {
$value = $this->parseLiteralValue($value);
}
}
}
return $value;
}