本文整理汇总了PHP中Propel\Generator\Model\Column::getCamelCaseName方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::getCamelCaseName方法的具体用法?PHP Column::getCamelCaseName怎么用?PHP Column::getCamelCaseName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Column
的用法示例。
在下文中一共展示了Column::getCamelCaseName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFilterByArrayCol
/**
* Adds the singular filterByCol method for an Array column.
* @param string &$script The script will be modified in this method.
* @param Column $col
*/
protected function addFilterByArrayCol(&$script, Column $col)
{
$colPhpName = $col->getPhpName();
$singularPhpName = $col->getPhpSingularName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
$qualifiedName = $this->getColumnConstant($col);
$script .= "\n /**\n * Filter the query on the {$colName} column\n * @param mixed \${$variableName} The value to use as filter\n * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::CONTAINS_ALL\n *\n * @return \$this|" . $this->getQueryClassName() . " The current query, for fluid interface\n */\n public function filterBy{$singularPhpName}(\${$variableName} = null, \$comparison = null)\n {\n if (null === \$comparison || \$comparison == Criteria::CONTAINS_ALL) {\n if (is_scalar(\${$variableName})) {\n \${$variableName} = '%| ' . \${$variableName} . ' |%';\n \$comparison = Criteria::LIKE;\n }\n } elseif (\$comparison == Criteria::CONTAINS_NONE) {\n \${$variableName} = '%| ' . \${$variableName} . ' |%';\n \$comparison = Criteria::NOT_LIKE;\n \$key = \$this->getAliasedColName({$qualifiedName});\n if (\$this->containsKey(\$key)) {\n \$this->addAnd(\$key, \${$variableName}, \$comparison);\n } else {\n \$this->addAnd(\$key, \${$variableName}, \$comparison);\n }\n \$this->addOr(\$key, null, Criteria::ISNULL);\n\n return \$this;\n }\n\n return \$this->addUsingAlias({$qualifiedName}, \${$variableName}, \$comparison);\n }\n";
}
示例2: getBooleanAccessorName
/**
* Returns the name to be used as boolean accessor name
*
* @param Column $column
* @return string
*/
protected static function getBooleanAccessorName(Column $column)
{
$name = $column->getCamelCaseName();
if (!preg_match('/^(?:is|has)(?=[A-Z])/', $name)) {
$name = 'is' . ucfirst($name);
}
return $name;
}
示例3: addBooleanAccessorOpen
/**
* Adds the function declaration for a boolean accessor.
*
* @param string &$script
* @param Column $column
*/
public function addBooleanAccessorOpen(&$script, Column $column)
{
$name = $column->getCamelCaseName();
if (!preg_match('/^(?:is|has)(?=[A-Z])/', $name)) {
$name = 'is' . ucfirst($name);
}
$visibility = $column->getAccessorVisibility();
$script .= "\n " . $visibility . " function {$name}(";
if ($column->isLazyLoad()) {
$script .= "ConnectionInterface \$con = null";
}
$script .= ")\n {";
}
示例4: addFilterBySetCol
/**
* Adds the singular filterByCol method for an Array column.
*
* @param string &$script The script will be modified in this method.
* @param Column $col
*/
protected function addFilterBySetCol(&$script, Column $col)
{
$colPhpName = $col->getPhpName();
$singularPhpName = $col->getPhpSingularName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
$script .= "\n /**\n * Filter the query on the {$colName} column\n * @param mixed \${$variableName} The value to use as filter\n * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::CONTAINS_ALL\n *\n * @return \$this|" . $this->getQueryClassName() . " The current query, for fluid interface\n */\n public function filterBy{$singularPhpName}(\${$variableName} = null, \$comparison = null)\n {\n return \$this->filterBy{$colPhpName}(\${$variableName}, \$comparison);\n }\n";
}
示例5: testSetCustomPhpName
public function testSetCustomPhpName()
{
$column = new Column('created_at');
$column->setPhpName('CreatedAt');
$this->assertSame('CreatedAt', $column->getPhpName());
$this->assertSame('createdAt', $column->getCamelCaseName());
}
示例6: addFilterByCol
/**
* Adds the filterByCol method for this object.
*
* @param string &$script The script will be modified in this method.
* @param \Propel\Generator\Model\Column $col
*
* @return void
*/
protected function addFilterByCol(&$script, Column $col)
{
$allowedArrayFilters = $this->getAllowedArrayFilters();
$implodedArrayComparisons = implode(', ', $allowedArrayFilters);
$this->declareClass('Spryker\\Zed\\Propel\\Business\\Exception\\AmbiguousComparisonException');
$this->declareClass('Spryker\\Zed\\Propel\\Business\\Runtime\\ActiveQuery\\Criteria', 'Spryker');
$colPhpName = $col->getPhpName();
$colName = $col->getName();
$variableName = $col->getCamelCaseName();
$qualifiedName = $this->getColumnConstant($col);
$script .= $this->addFilterByColBetween($col);
$script .= $this->addFilterByColIn($col);
$script .= $this->addFilterByColLike($col);
$script .= "\n /**\n * Filter the query on the {$colName} column\n *";
if ($col->isNumericType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}(1234); // WHERE {$colName} = 1234\n * \$query->filterBy{$colPhpName}(array(12, 34), Criteria::IN); // WHERE {$colName} IN (12, 34)\n * \$query->filterBy{$colPhpName}(array('min' => 12), SprykerCriteria::BETWEEN); // WHERE {$colName} > 12\n * </code>";
if ($col->isForeignKey()) {
foreach ($col->getForeignKeys() as $fk) {
$script .= "\n *\n * @see filterBy" . $this->getFKPhpNameAffix($fk) . "()";
}
}
$script .= "\n *\n * @param mixed \${$variableName} The value to use as filter.\n * Use scalar values for equality.\n * Use array values for in_array() equivalent. Add Criteria::IN explicitly.\n * Use associative array('min' => \$minValue, 'max' => \$maxValue) for intervals. Add SprykerCriteria::BETWEEN explicitly.";
} elseif ($col->isTemporalType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}('2011-03-14'); // WHERE {$colName} = '2011-03-14'\n * \$query->filterBy{$colPhpName}('now'); // WHERE {$colName} = '2011-03-14'\n * \$query->filterBy{$colPhpName}(array('max' => 'yesterday'), SprykerCriteria::BETWEEN); // WHERE {$colName} > '2011-03-13'\n * </code>\n *\n * @param mixed \${$variableName} The value to use as filter.\n * Values can be integers (unix timestamps), DateTime objects, or strings.\n * Empty strings are treated as NULL.\n * Use scalar values for equality.\n * Use array values for in_array() equivalent. Add Criteria::IN explicitly.\n * Use associative array('min' => \$minValue, 'max' => \$maxValue) for intervals. Add SprykerCriteria::BETWEEN explicitly.";
} elseif ($col->getType() == PropelTypes::PHP_ARRAY) {
$script .= "\n * @param array \${$variableName} The values to use as filter. Use Criteria::LIKE to enable like matching of array values.";
} elseif ($col->isTextType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}('fooValue'); // WHERE {$colName} = 'fooValue'\n * \$query->filterBy{$colPhpName}('%fooValue%', Criteria::LIKE); // WHERE {$colName} LIKE '%fooValue%'\n * </code>\n *\n * @param string \${$variableName} The value to use as filter.\n * Accepts wildcards (* and % trigger a LIKE). Add Criteria::LIKE explicitly.";
} elseif ($col->isBooleanType()) {
$script .= "\n * Example usage:\n * <code>\n * \$query->filterBy{$colPhpName}(true); // WHERE {$colName} = true\n * \$query->filterBy{$colPhpName}('yes'); // WHERE {$colName} = true\n * </code>\n *\n * @param boolean|string \${$variableName} The value to use as filter.\n * Non-boolean arguments are converted using the following rules:\n * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true\n * * 0, '0', 'false', 'off', and 'no' are converted to boolean false\n * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').";
} else {
$script .= "\n * @param mixed \${$variableName} The value to use as filter";
}
$script .= "\n * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::EQUAL\n *\n * @return \$this|" . $this->getQueryClassName() . " The current query, for fluid interface\n *\n * @throws \\Spryker\\Zed\\Propel\\Business\\Exception\\AmbiguousComparisonException\n */\n public function filterBy{$colPhpName}(\${$variableName} = null, \$comparison = Criteria::EQUAL)\n {";
if ($col->isNumericType() || $col->isTemporalType()) {
$script .= "\n\n if (is_array(\${$variableName})) {\n \$useMinMax = false;\n if (isset(\${$variableName}['min'])) {\n if (\$comparison != SprykerCriteria::BETWEEN && \$comparison != Criteria::GREATER_EQUAL) {\n throw new AmbiguousComparisonException('\\'min\\' requires explicit Criteria::GREATER_EQUAL or SprykerCriteria::BETWEEN when \\'max\\' is also needed as comparison criteria.');\n }\n \$this->addUsingAlias({$qualifiedName}, \${$variableName}['min'], Criteria::GREATER_EQUAL);\n \$useMinMax = true;\n }\n if (isset(\${$variableName}['max'])) {\n if (\$comparison != SprykerCriteria::BETWEEN && \$comparison != Criteria::LESS_EQUAL) {\n throw new AmbiguousComparisonException('\\'max\\' requires explicit Criteria::LESS_EQUAL or SprykerCriteria::BETWEEN when \\'min\\' is also needed as comparison criteria.');\n }\n \$this->addUsingAlias({$qualifiedName}, \${$variableName}['max'], Criteria::LESS_EQUAL);\n \$useMinMax = true;\n }\n if (\$useMinMax) {\n return \$this;\n }\n\n if (!in_array(\$comparison, [{$implodedArrayComparisons}])) {\n throw new AmbiguousComparisonException('\${$variableName} of type array requires one of [{$implodedArrayComparisons}] as comparison criteria.');\n }\n }";
} elseif ($col->getType() == PropelTypes::OBJECT) {
$script .= "\n if (is_object(\${$variableName})) {\n \${$variableName} = serialize(\${$variableName});\n }";
} elseif ($col->getType() == PropelTypes::PHP_ARRAY) {
$script .= "\n \$key = \$this->getAliasedColName({$qualifiedName});\n if (null === \$comparison || \$comparison == Criteria::CONTAINS_ALL) {\n foreach (\${$variableName} as \$value) {\n \$value = '%| ' . \$value . ' |%';\n if (\$this->containsKey(\$key)) {\n \$this->addAnd(\$key, \$value, Criteria::LIKE);\n } else {\n \$this->add(\$key, \$value, Criteria::LIKE);\n }\n }\n\n return \$this;\n } elseif (\$comparison == Criteria::CONTAINS_SOME) {\n foreach (\${$variableName} as \$value) {\n \$value = '%| ' . \$value . ' |%';\n if (\$this->containsKey(\$key)) {\n \$this->addOr(\$key, \$value, Criteria::LIKE);\n } else {\n \$this->add(\$key, \$value, Criteria::LIKE);\n }\n }\n\n return \$this;\n } elseif (\$comparison == Criteria::CONTAINS_NONE) {\n foreach (\${$variableName} as \$value) {\n \$value = '%| ' . \$value . ' |%';\n if (\$this->containsKey(\$key)) {\n \$this->addAnd(\$key, \$value, Criteria::NOT_LIKE);\n } else {\n \$this->add(\$key, \$value, Criteria::NOT_LIKE);\n }\n }\n \$this->addOr(\$key, null, Criteria::ISNULL);\n\n return \$this;\n }";
} elseif ($col->getType() == PropelTypes::ENUM) {
$script .= "\n \$valueSet = " . $this->getTableMapClassName() . "::getValueSet(" . $this->getColumnConstant($col) . ");\n if (is_scalar(\${$variableName})) {\n if (!in_array(\${$variableName}, \$valueSet)) {\n throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \${$variableName}));\n }\n \${$variableName} = array_search(\${$variableName}, \$valueSet);\n } elseif (is_array(\${$variableName})) {\n if (!in_array(\$comparison, [{$implodedArrayComparisons}])) {\n throw new AmbiguousComparisonException('array requires one of [{$implodedArrayComparisons}] as comparison criteria.');\n }\n \$convertedValues = array();\n foreach (\${$variableName} as \$value) {\n if (!in_array(\$value, \$valueSet)) {\n throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$value));\n }\n \$convertedValues []= array_search(\$value, \$valueSet);\n }\n \${$variableName} = \$convertedValues;\n }";
} elseif ($col->isTextType()) {
$script .= "\n if (\$comparison == Criteria::LIKE) {\n \${$variableName} = str_replace('*', '%', \${$variableName});\n }\n\n if (is_array(\${$variableName}) && !in_array(\$comparison, [{$implodedArrayComparisons}])) {\n throw new AmbiguousComparisonException('\${$variableName} of type array requires one of [{$implodedArrayComparisons}] as comparison criteria.');\n }";
} elseif ($col->isBooleanType()) {
$script .= "\n if (is_string(\${$variableName})) {\n \${$variableName} = in_array(strtolower(\${$variableName}), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;\n }";
}
$script .= "\n\n return \$this->addUsingAlias({$qualifiedName}, \${$variableName}, \$comparison);\n }\n";
}