repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
propelorm/Propel | generator/lib/builder/om/QueryBuilder.php | QueryBuilder.addUseFkQuery | protected function addUseFkQuery(&$script, $fk)
{
$table = $this->getTable();
$fkTable = $this->getForeignTable($fk);
$fkQueryBuilder = $this->getNewStubQueryBuilder($fkTable);
$queryClass = $fkQueryBuilder->getClassname();
if ($namespace = $fkQueryBuilder->getNamespace()) {
$queryClass = '\\' . $namespace . '\\' . $queryClass;
}
$relationName = $this->getFKPhpNameAffix($fk);
$joinType = $this->getJoinType($fk);
$this->addUseRelatedQuery($script, $fkTable, $queryClass, $relationName, $joinType);
} | php | protected function addUseFkQuery(&$script, $fk)
{
$table = $this->getTable();
$fkTable = $this->getForeignTable($fk);
$fkQueryBuilder = $this->getNewStubQueryBuilder($fkTable);
$queryClass = $fkQueryBuilder->getClassname();
if ($namespace = $fkQueryBuilder->getNamespace()) {
$queryClass = '\\' . $namespace . '\\' . $queryClass;
}
$relationName = $this->getFKPhpNameAffix($fk);
$joinType = $this->getJoinType($fk);
$this->addUseRelatedQuery($script, $fkTable, $queryClass, $relationName, $joinType);
} | [
"protected",
"function",
"addUseFkQuery",
"(",
"&",
"$",
"script",
",",
"$",
"fk",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"fkTable",
"=",
"$",
"this",
"->",
"getForeignTable",
"(",
"$",
"fk",
")",
";",
"$",
"fkQueryBuilder",
"=",
"$",
"this",
"->",
"getNewStubQueryBuilder",
"(",
"$",
"fkTable",
")",
";",
"$",
"queryClass",
"=",
"$",
"fkQueryBuilder",
"->",
"getClassname",
"(",
")",
";",
"if",
"(",
"$",
"namespace",
"=",
"$",
"fkQueryBuilder",
"->",
"getNamespace",
"(",
")",
")",
"{",
"$",
"queryClass",
"=",
"'\\\\'",
".",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"queryClass",
";",
"}",
"$",
"relationName",
"=",
"$",
"this",
"->",
"getFKPhpNameAffix",
"(",
"$",
"fk",
")",
";",
"$",
"joinType",
"=",
"$",
"this",
"->",
"getJoinType",
"(",
"$",
"fk",
")",
";",
"$",
"this",
"->",
"addUseRelatedQuery",
"(",
"$",
"script",
",",
"$",
"fkTable",
",",
"$",
"queryClass",
",",
"$",
"relationName",
",",
"$",
"joinType",
")",
";",
"}"
] | Adds the useFkQuery method for this object.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"useFkQuery",
"method",
"for",
"this",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryBuilder.php#L1208-L1220 |
propelorm/Propel | generator/lib/builder/om/QueryBuilder.php | QueryBuilder.addUseRefFkQuery | protected function addUseRefFkQuery(&$script, $fk)
{
$table = $this->getTable();
$fkTable = $this->getTable()->getDatabase()->getTable($fk->getTableName());
$fkQueryBuilder = $this->getNewStubQueryBuilder($fkTable);
$queryClass = $fkQueryBuilder->getClassname();
if ($namespace = $fkQueryBuilder->getNamespace()) {
$queryClass = '\\' . $namespace . '\\' . $queryClass;
}
$relationName = $this->getRefFKPhpNameAffix($fk);
$joinType = $this->getJoinType($fk);
$this->addUseRelatedQuery($script, $fkTable, $queryClass, $relationName, $joinType);
} | php | protected function addUseRefFkQuery(&$script, $fk)
{
$table = $this->getTable();
$fkTable = $this->getTable()->getDatabase()->getTable($fk->getTableName());
$fkQueryBuilder = $this->getNewStubQueryBuilder($fkTable);
$queryClass = $fkQueryBuilder->getClassname();
if ($namespace = $fkQueryBuilder->getNamespace()) {
$queryClass = '\\' . $namespace . '\\' . $queryClass;
}
$relationName = $this->getRefFKPhpNameAffix($fk);
$joinType = $this->getJoinType($fk);
$this->addUseRelatedQuery($script, $fkTable, $queryClass, $relationName, $joinType);
} | [
"protected",
"function",
"addUseRefFkQuery",
"(",
"&",
"$",
"script",
",",
"$",
"fk",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"fkTable",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getTable",
"(",
"$",
"fk",
"->",
"getTableName",
"(",
")",
")",
";",
"$",
"fkQueryBuilder",
"=",
"$",
"this",
"->",
"getNewStubQueryBuilder",
"(",
"$",
"fkTable",
")",
";",
"$",
"queryClass",
"=",
"$",
"fkQueryBuilder",
"->",
"getClassname",
"(",
")",
";",
"if",
"(",
"$",
"namespace",
"=",
"$",
"fkQueryBuilder",
"->",
"getNamespace",
"(",
")",
")",
"{",
"$",
"queryClass",
"=",
"'\\\\'",
".",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"queryClass",
";",
"}",
"$",
"relationName",
"=",
"$",
"this",
"->",
"getRefFKPhpNameAffix",
"(",
"$",
"fk",
")",
";",
"$",
"joinType",
"=",
"$",
"this",
"->",
"getJoinType",
"(",
"$",
"fk",
")",
";",
"$",
"this",
"->",
"addUseRelatedQuery",
"(",
"$",
"script",
",",
"$",
"fkTable",
",",
"$",
"queryClass",
",",
"$",
"relationName",
",",
"$",
"joinType",
")",
";",
"}"
] | Adds the useFkQuery method for this object.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"useFkQuery",
"method",
"for",
"this",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryBuilder.php#L1227-L1239 |
propelorm/Propel | generator/lib/builder/om/QueryBuilder.php | QueryBuilder.addUseRelatedQuery | protected function addUseRelatedQuery(&$script, $fkTable, $queryClass, $relationName, $joinType)
{
$script .= "
/**
* Use the $relationName relation " . $fkTable->getPhpName() . " object
*
* @see useQuery()
*
* @param string \$relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return $queryClass A secondary query class using the current class as primary query
*/
public function use" . $relationName . "Query(\$relationAlias = null, \$joinType = " . $joinType . ")
{
return \$this
->join" . $relationName . "(\$relationAlias, \$joinType)
->useQuery(\$relationAlias ? \$relationAlias : '$relationName', '$queryClass');
}
";
} | php | protected function addUseRelatedQuery(&$script, $fkTable, $queryClass, $relationName, $joinType)
{
$script .= "
/**
* Use the $relationName relation " . $fkTable->getPhpName() . " object
*
* @see useQuery()
*
* @param string \$relationAlias optional alias for the relation,
* to be used as main alias in the secondary query
* @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
* @return $queryClass A secondary query class using the current class as primary query
*/
public function use" . $relationName . "Query(\$relationAlias = null, \$joinType = " . $joinType . ")
{
return \$this
->join" . $relationName . "(\$relationAlias, \$joinType)
->useQuery(\$relationAlias ? \$relationAlias : '$relationName', '$queryClass');
}
";
} | [
"protected",
"function",
"addUseRelatedQuery",
"(",
"&",
"$",
"script",
",",
"$",
"fkTable",
",",
"$",
"queryClass",
",",
"$",
"relationName",
",",
"$",
"joinType",
")",
"{",
"$",
"script",
".=",
"\"\n /**\n * Use the $relationName relation \"",
".",
"$",
"fkTable",
"->",
"getPhpName",
"(",
")",
".",
"\" object\n *\n * @see useQuery()\n *\n * @param string \\$relationAlias optional alias for the relation,\n * to be used as main alias in the secondary query\n * @param string \\$joinType Accepted values are null, 'left join', 'right join', 'inner join'\n *\n * @return $queryClass A secondary query class using the current class as primary query\n */\n public function use\"",
".",
"$",
"relationName",
".",
"\"Query(\\$relationAlias = null, \\$joinType = \"",
".",
"$",
"joinType",
".",
"\")\n {\n return \\$this\n ->join\"",
".",
"$",
"relationName",
".",
"\"(\\$relationAlias, \\$joinType)\n ->useQuery(\\$relationAlias ? \\$relationAlias : '$relationName', '$queryClass');\n }\n\"",
";",
"}"
] | Adds a useRelatedQuery method for this object.
@param string &$script The script will be modified in this method. | [
"Adds",
"a",
"useRelatedQuery",
"method",
"for",
"this",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryBuilder.php#L1246-L1267 |
propelorm/Propel | generator/lib/builder/om/QueryBuilder.php | QueryBuilder.addPrune | protected function addPrune(&$script)
{
$table = $this->getTable();
$class = $this->getStubObjectBuilder()->getClassname();
$objectName = '$' . $table->getStudlyPhpName();
$script .= "
/**
* Exclude object from result
*
* @param $class $objectName Object to remove from the list of results
*
* @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
*/
public function prune($objectName = null)
{
if ($objectName) {";
$pks = $table->getPrimaryKey();
if (count($pks) > 1) {
$i = 0;
$conditions = array();
foreach ($pks as $col) {
$const = $this->getColumnConstant($col);
$condName = "'pruneCond" . $i . "'";
$conditions[] = $condName;
$script .= "
\$this->addCond(" . $condName . ", \$this->getAliasedColName($const), " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);";
$i++;
}
$conditionsString = implode(', ', $conditions);
$script .= "
\$this->combine(array(" . $conditionsString . "), Criteria::LOGICAL_OR);";
} else {
$col = $pks[0];
$const = $this->getColumnConstant($col);
$script .= "
\$this->addUsingAlias($const, " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);";
}
$script .= "
}
return \$this;
}
";
} | php | protected function addPrune(&$script)
{
$table = $this->getTable();
$class = $this->getStubObjectBuilder()->getClassname();
$objectName = '$' . $table->getStudlyPhpName();
$script .= "
/**
* Exclude object from result
*
* @param $class $objectName Object to remove from the list of results
*
* @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
*/
public function prune($objectName = null)
{
if ($objectName) {";
$pks = $table->getPrimaryKey();
if (count($pks) > 1) {
$i = 0;
$conditions = array();
foreach ($pks as $col) {
$const = $this->getColumnConstant($col);
$condName = "'pruneCond" . $i . "'";
$conditions[] = $condName;
$script .= "
\$this->addCond(" . $condName . ", \$this->getAliasedColName($const), " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);";
$i++;
}
$conditionsString = implode(', ', $conditions);
$script .= "
\$this->combine(array(" . $conditionsString . "), Criteria::LOGICAL_OR);";
} else {
$col = $pks[0];
$const = $this->getColumnConstant($col);
$script .= "
\$this->addUsingAlias($const, " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);";
}
$script .= "
}
return \$this;
}
";
} | [
"protected",
"function",
"addPrune",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getStubObjectBuilder",
"(",
")",
"->",
"getClassname",
"(",
")",
";",
"$",
"objectName",
"=",
"'$'",
".",
"$",
"table",
"->",
"getStudlyPhpName",
"(",
")",
";",
"$",
"script",
".=",
"\"\n /**\n * Exclude object from result\n *\n * @param $class $objectName Object to remove from the list of results\n *\n * @return \"",
".",
"$",
"this",
"->",
"getStubQueryBuilder",
"(",
")",
"->",
"getClassname",
"(",
")",
".",
"\" The current query, for fluid interface\n */\n public function prune($objectName = null)\n {\n if ($objectName) {\"",
";",
"$",
"pks",
"=",
"$",
"table",
"->",
"getPrimaryKey",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"pks",
")",
">",
"1",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"conditions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"pks",
"as",
"$",
"col",
")",
"{",
"$",
"const",
"=",
"$",
"this",
"->",
"getColumnConstant",
"(",
"$",
"col",
")",
";",
"$",
"condName",
"=",
"\"'pruneCond\"",
".",
"$",
"i",
".",
"\"'\"",
";",
"$",
"conditions",
"[",
"]",
"=",
"$",
"condName",
";",
"$",
"script",
".=",
"\"\n \\$this->addCond(\"",
".",
"$",
"condName",
".",
"\", \\$this->getAliasedColName($const), \"",
".",
"$",
"objectName",
".",
"\"->get\"",
".",
"$",
"col",
"->",
"getPhpName",
"(",
")",
".",
"\"(), Criteria::NOT_EQUAL);\"",
";",
"$",
"i",
"++",
";",
"}",
"$",
"conditionsString",
"=",
"implode",
"(",
"', '",
",",
"$",
"conditions",
")",
";",
"$",
"script",
".=",
"\"\n \\$this->combine(array(\"",
".",
"$",
"conditionsString",
".",
"\"), Criteria::LOGICAL_OR);\"",
";",
"}",
"else",
"{",
"$",
"col",
"=",
"$",
"pks",
"[",
"0",
"]",
";",
"$",
"const",
"=",
"$",
"this",
"->",
"getColumnConstant",
"(",
"$",
"col",
")",
";",
"$",
"script",
".=",
"\"\n \\$this->addUsingAlias($const, \"",
".",
"$",
"objectName",
".",
"\"->get\"",
".",
"$",
"col",
"->",
"getPhpName",
"(",
")",
".",
"\"(), Criteria::NOT_EQUAL);\"",
";",
"}",
"$",
"script",
".=",
"\"\n }\n\n return \\$this;\n }\n\"",
";",
"}"
] | Adds the prune method for this object.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"prune",
"method",
"for",
"this",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryBuilder.php#L1305-L1348 |
propelorm/Propel | generator/lib/builder/util/PropelTemplate.php | PropelTemplate.render | public function render($vars = array())
{
if (null === $this->templateFile && null === $this->template) {
throw new InvalidArgumentException('You must set a template or a template file before rendering');
}
extract($vars);
ob_start();
ob_implicit_flush(0);
try {
if (null !== $this->templateFile) {
require($this->templateFile);
} else {
eval('?>' . $this->template . '<?php ');
}
} catch (Exception $e) {
// need to end output buffering before throwing the exception #7596
ob_end_clean();
throw $e;
}
return ob_get_clean();
} | php | public function render($vars = array())
{
if (null === $this->templateFile && null === $this->template) {
throw new InvalidArgumentException('You must set a template or a template file before rendering');
}
extract($vars);
ob_start();
ob_implicit_flush(0);
try {
if (null !== $this->templateFile) {
require($this->templateFile);
} else {
eval('?>' . $this->template . '<?php ');
}
} catch (Exception $e) {
// need to end output buffering before throwing the exception #7596
ob_end_clean();
throw $e;
}
return ob_get_clean();
} | [
"public",
"function",
"render",
"(",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"templateFile",
"&&",
"null",
"===",
"$",
"this",
"->",
"template",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'You must set a template or a template file before rendering'",
")",
";",
"}",
"extract",
"(",
"$",
"vars",
")",
";",
"ob_start",
"(",
")",
";",
"ob_implicit_flush",
"(",
"0",
")",
";",
"try",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"templateFile",
")",
"{",
"require",
"(",
"$",
"this",
"->",
"templateFile",
")",
";",
"}",
"else",
"{",
"eval",
"(",
"'?>'",
".",
"$",
"this",
"->",
"template",
".",
"'<?php '",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// need to end output buffering before throwing the exception #7596",
"ob_end_clean",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] | Render the template using the variable provided as arguments.
<code>
$template = new PropelTemplate();
$template->setTemplate('This is <?php echo $name ?>');
echo $template->render(array('name' => 'Mike'));
// This is Mike
</code>
@param array $vars An associative array of arguments to be rendered
@return string The rendered template
@throws InvalidArgumentException
@throws Exception | [
"Render",
"the",
"template",
"using",
"the",
"variable",
"provided",
"as",
"arguments",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/util/PropelTemplate.php#L68-L91 |
propelorm/Propel | generator/lib/behavior/i18n/I18nBehavior.php | I18nBehavior.moveI18nColumns | protected function moveI18nColumns()
{
$table = $this->getTable();
$i18nTable = $this->i18nTable;
foreach ($this->getI18nColumnNamesFromConfig() as $columnName) {
if (!$i18nTable->hasColumn($columnName)) {
if (!$table->hasColumn($columnName)) {
throw new EngineException(sprintf('No column named %s found in table %s', $columnName, $table->getName()));
}
$column = $table->getColumn($columnName);
// add the column
$i18nColumn = $i18nTable->addColumn(clone $column);
// add related validators
if ($validator = $column->getValidator()) {
$i18nValidator = $i18nTable->addValidator(clone $validator);
}
// FIXME: also move FKs, and indices on this column
}
if ($table->hasColumn($columnName)) {
$table->removeColumn($columnName);
$table->removeValidatorForColumn($columnName);
}
}
} | php | protected function moveI18nColumns()
{
$table = $this->getTable();
$i18nTable = $this->i18nTable;
foreach ($this->getI18nColumnNamesFromConfig() as $columnName) {
if (!$i18nTable->hasColumn($columnName)) {
if (!$table->hasColumn($columnName)) {
throw new EngineException(sprintf('No column named %s found in table %s', $columnName, $table->getName()));
}
$column = $table->getColumn($columnName);
// add the column
$i18nColumn = $i18nTable->addColumn(clone $column);
// add related validators
if ($validator = $column->getValidator()) {
$i18nValidator = $i18nTable->addValidator(clone $validator);
}
// FIXME: also move FKs, and indices on this column
}
if ($table->hasColumn($columnName)) {
$table->removeColumn($columnName);
$table->removeValidatorForColumn($columnName);
}
}
} | [
"protected",
"function",
"moveI18nColumns",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"i18nTable",
"=",
"$",
"this",
"->",
"i18nTable",
";",
"foreach",
"(",
"$",
"this",
"->",
"getI18nColumnNamesFromConfig",
"(",
")",
"as",
"$",
"columnName",
")",
"{",
"if",
"(",
"!",
"$",
"i18nTable",
"->",
"hasColumn",
"(",
"$",
"columnName",
")",
")",
"{",
"if",
"(",
"!",
"$",
"table",
"->",
"hasColumn",
"(",
"$",
"columnName",
")",
")",
"{",
"throw",
"new",
"EngineException",
"(",
"sprintf",
"(",
"'No column named %s found in table %s'",
",",
"$",
"columnName",
",",
"$",
"table",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"column",
"=",
"$",
"table",
"->",
"getColumn",
"(",
"$",
"columnName",
")",
";",
"// add the column",
"$",
"i18nColumn",
"=",
"$",
"i18nTable",
"->",
"addColumn",
"(",
"clone",
"$",
"column",
")",
";",
"// add related validators",
"if",
"(",
"$",
"validator",
"=",
"$",
"column",
"->",
"getValidator",
"(",
")",
")",
"{",
"$",
"i18nValidator",
"=",
"$",
"i18nTable",
"->",
"addValidator",
"(",
"clone",
"$",
"validator",
")",
";",
"}",
"// FIXME: also move FKs, and indices on this column",
"}",
"if",
"(",
"$",
"table",
"->",
"hasColumn",
"(",
"$",
"columnName",
")",
")",
"{",
"$",
"table",
"->",
"removeColumn",
"(",
"$",
"columnName",
")",
";",
"$",
"table",
"->",
"removeValidatorForColumn",
"(",
"$",
"columnName",
")",
";",
"}",
"}",
"}"
] | Moves i18n columns from the main table to the i18n table | [
"Moves",
"i18n",
"columns",
"from",
"the",
"main",
"table",
"to",
"the",
"i18n",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/i18n/I18nBehavior.php#L141-L164 |
propelorm/Propel | generator/lib/builder/om/PHP5NestedSetPeerBuilder.php | PHP5NestedSetPeerBuilder.addClassBody | protected function addClassBody(&$script)
{
$table = $this->getTable();
// FIXME
// - Probably the build needs to be customized for supporting
// tables that are "aliases". -- definitely a fringe usecase, though.
$this->addConstants($script);
$this->addCreateRoot($script);
$this->addRetrieveRoot($script);
$this->addInsertAsFirstChildOf($script);
$this->addInsertAsLastChildOf($script);
$this->addInsertAsPrevSiblingOf($script);
$this->addInsertAsNextSiblingOf($script);
$this->addInsertAsParentOf($script);
$this->addInsertRoot($script);
$this->addInsertParent($script);
$this->addDeleteRoot($script);
$this->addDeleteNode($script);
$this->addMoveToFirstChildOf($script);
$this->addMoveToLastChildOf($script);
$this->addMoveToPrevSiblingOf($script);
$this->addMoveToNextSiblingOf($script);
$this->addRetrieveFirstChild($script);
$this->addRetrieveLastChild($script);
$this->addRetrievePrevSibling($script);
$this->addRetrieveNextSibling($script);
$this->addRetrieveTree($script);
$this->addRetrieveBranch($script);
$this->addRetrieveChildren($script);
$this->addRetrieveDescendants($script);
$this->addRetrieveSiblings($script);
$this->addRetrieveParent($script);
$this->addGetLevel($script);
$this->addGetNumberOfChildren($script);
$this->addGetNumberOfDescendants($script);
$this->addGetPath($script);
$this->addIsValid($script);
$this->addIsRoot($script);
$this->addIsLeaf($script);
$this->addIsChildOf($script);
$this->addIsChildOfOrSiblingTo($script);
$this->addIsEqualTo($script);
$this->addHasParent($script);
$this->addHasPrevSibling($script);
$this->addHasNextSibling($script);
$this->addHasChildren($script);
$this->addDeleteDescendants($script);
$this->addGetNode($script);
$this->addHydrateDescendants($script);
$this->addHydrateChildren($script);
$this->addShiftRParent($script);
$this->addUpdateLoadedNode($script);
$this->addUpdateDBNode($script);
$this->addShiftRLValues($script);
$this->addShiftRLRange($script);
} | php | protected function addClassBody(&$script)
{
$table = $this->getTable();
// FIXME
// - Probably the build needs to be customized for supporting
// tables that are "aliases". -- definitely a fringe usecase, though.
$this->addConstants($script);
$this->addCreateRoot($script);
$this->addRetrieveRoot($script);
$this->addInsertAsFirstChildOf($script);
$this->addInsertAsLastChildOf($script);
$this->addInsertAsPrevSiblingOf($script);
$this->addInsertAsNextSiblingOf($script);
$this->addInsertAsParentOf($script);
$this->addInsertRoot($script);
$this->addInsertParent($script);
$this->addDeleteRoot($script);
$this->addDeleteNode($script);
$this->addMoveToFirstChildOf($script);
$this->addMoveToLastChildOf($script);
$this->addMoveToPrevSiblingOf($script);
$this->addMoveToNextSiblingOf($script);
$this->addRetrieveFirstChild($script);
$this->addRetrieveLastChild($script);
$this->addRetrievePrevSibling($script);
$this->addRetrieveNextSibling($script);
$this->addRetrieveTree($script);
$this->addRetrieveBranch($script);
$this->addRetrieveChildren($script);
$this->addRetrieveDescendants($script);
$this->addRetrieveSiblings($script);
$this->addRetrieveParent($script);
$this->addGetLevel($script);
$this->addGetNumberOfChildren($script);
$this->addGetNumberOfDescendants($script);
$this->addGetPath($script);
$this->addIsValid($script);
$this->addIsRoot($script);
$this->addIsLeaf($script);
$this->addIsChildOf($script);
$this->addIsChildOfOrSiblingTo($script);
$this->addIsEqualTo($script);
$this->addHasParent($script);
$this->addHasPrevSibling($script);
$this->addHasNextSibling($script);
$this->addHasChildren($script);
$this->addDeleteDescendants($script);
$this->addGetNode($script);
$this->addHydrateDescendants($script);
$this->addHydrateChildren($script);
$this->addShiftRParent($script);
$this->addUpdateLoadedNode($script);
$this->addUpdateDBNode($script);
$this->addShiftRLValues($script);
$this->addShiftRLRange($script);
} | [
"protected",
"function",
"addClassBody",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"// FIXME",
"// - Probably the build needs to be customized for supporting",
"// tables that are \"aliases\". -- definitely a fringe usecase, though.",
"$",
"this",
"->",
"addConstants",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addCreateRoot",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveRoot",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertAsFirstChildOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertAsLastChildOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertAsPrevSiblingOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertAsNextSiblingOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertAsParentOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertRoot",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInsertParent",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDeleteRoot",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDeleteNode",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addMoveToFirstChildOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addMoveToLastChildOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addMoveToPrevSiblingOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addMoveToNextSiblingOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveFirstChild",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveLastChild",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrievePrevSibling",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveNextSibling",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveTree",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveBranch",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveChildren",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveDescendants",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveSiblings",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveParent",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetLevel",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetNumberOfChildren",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetNumberOfDescendants",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetPath",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addIsValid",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addIsRoot",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addIsLeaf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addIsChildOf",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addIsChildOfOrSiblingTo",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addIsEqualTo",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addHasParent",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addHasPrevSibling",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addHasNextSibling",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addHasChildren",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDeleteDescendants",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetNode",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addHydrateDescendants",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addHydrateChildren",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addShiftRParent",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addUpdateLoadedNode",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addUpdateDBNode",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addShiftRLValues",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addShiftRLRange",
"(",
"$",
"script",
")",
";",
"}"
] | Specifies the methods that are added as part of the basic OM class.
This can be overridden by subclasses that wish to add more methods.
@see ObjectBuilder::addClassBody() | [
"Specifies",
"the",
"methods",
"that",
"are",
"added",
"as",
"part",
"of",
"the",
"basic",
"OM",
"class",
".",
"This",
"can",
"be",
"overridden",
"by",
"subclasses",
"that",
"wish",
"to",
"add",
"more",
"methods",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5NestedSetPeerBuilder.php#L97-L170 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.isLob | public function isLob()
{
return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY);
} | php | public function isLob()
{
return ($this->type == PropelColumnTypes::BLOB || $this->type == PropelColumnTypes::VARBINARY || $this->type == PropelColumnTypes::LONGVARBINARY);
} | [
"public",
"function",
"isLob",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"BLOB",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"VARBINARY",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"LONGVARBINARY",
")",
";",
"}"
] | Whether this is a BLOB, LONGVARBINARY, or VARBINARY.
@return boolean | [
"Whether",
"this",
"is",
"a",
"BLOB",
"LONGVARBINARY",
"or",
"VARBINARY",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L179-L182 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.isTemporal | public function isTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP);
} | php | public function isTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP);
} | [
"public",
"function",
"isTemporal",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"TIMESTAMP",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"DATE",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"TIME",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"BU_DATE",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"BU_TIMESTAMP",
")",
";",
"}"
] | Whether this is a DATE/TIME/TIMESTAMP column.
@return boolean
@since 1.3 | [
"Whether",
"this",
"is",
"a",
"DATE",
"/",
"TIME",
"/",
"TIMESTAMP",
"column",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L190-L193 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.isEpochTemporal | public function isEpochTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME);
} | php | public function isEpochTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME);
} | [
"public",
"function",
"isEpochTemporal",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"TIMESTAMP",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"DATE",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"TIME",
")",
";",
"}"
] | Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970).
PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate
between epoch and pre-epoch timestamps.
@return boolean
@deprecated Propel supports non-epoch dates | [
"Whether",
"this",
"is",
"a",
"DATE",
"/",
"TIME",
"/",
"TIMESTAMP",
"column",
"that",
"is",
"post",
"-",
"epoch",
"(",
"1970",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L204-L207 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.isNumeric | public function isNumeric()
{
return ($this->type == PropelColumnTypes::NUMERIC || $this->type == PropelColumnTypes::DECIMAL || $this->type == PropelColumnTypes::TINYINT || $this->type == PropelColumnTypes::SMALLINT || $this->type == PropelColumnTypes::INTEGER || $this->type == PropelColumnTypes::BIGINT || $this->type == PropelColumnTypes::REAL || $this->type == PropelColumnTypes::FLOAT || $this->type == PropelColumnTypes::DOUBLE);
} | php | public function isNumeric()
{
return ($this->type == PropelColumnTypes::NUMERIC || $this->type == PropelColumnTypes::DECIMAL || $this->type == PropelColumnTypes::TINYINT || $this->type == PropelColumnTypes::SMALLINT || $this->type == PropelColumnTypes::INTEGER || $this->type == PropelColumnTypes::BIGINT || $this->type == PropelColumnTypes::REAL || $this->type == PropelColumnTypes::FLOAT || $this->type == PropelColumnTypes::DOUBLE);
} | [
"public",
"function",
"isNumeric",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"NUMERIC",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"DECIMAL",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"TINYINT",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"SMALLINT",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"INTEGER",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"BIGINT",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"REAL",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"FLOAT",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"DOUBLE",
")",
";",
"}"
] | Whether this column is numeric (int, decimal, bigint etc).
@return boolean | [
"Whether",
"this",
"column",
"is",
"numeric",
"(",
"int",
"decimal",
"bigint",
"etc",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L214-L217 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.isText | public function isText()
{
return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR);
} | php | public function isText()
{
return ($this->type == PropelColumnTypes::VARCHAR || $this->type == PropelColumnTypes::LONGVARCHAR || $this->type == PropelColumnTypes::CHAR);
} | [
"public",
"function",
"isText",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"VARCHAR",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"LONGVARCHAR",
"||",
"$",
"this",
"->",
"type",
"==",
"PropelColumnTypes",
"::",
"CHAR",
")",
";",
"}"
] | Whether this column is a text column (varchar, char, longvarchar).
@return boolean | [
"Whether",
"this",
"column",
"is",
"a",
"text",
"column",
"(",
"varchar",
"char",
"longvarchar",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L234-L237 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.setForeignKey | public function setForeignKey($tableName, $columnName)
{
if ($tableName && $columnName) {
$this->relatedTableName = $tableName;
$this->relatedColumnName = $columnName;
} else {
$this->relatedTableName = "";
$this->relatedColumnName = "";
}
} | php | public function setForeignKey($tableName, $columnName)
{
if ($tableName && $columnName) {
$this->relatedTableName = $tableName;
$this->relatedColumnName = $columnName;
} else {
$this->relatedTableName = "";
$this->relatedColumnName = "";
}
} | [
"public",
"function",
"setForeignKey",
"(",
"$",
"tableName",
",",
"$",
"columnName",
")",
"{",
"if",
"(",
"$",
"tableName",
"&&",
"$",
"columnName",
")",
"{",
"$",
"this",
"->",
"relatedTableName",
"=",
"$",
"tableName",
";",
"$",
"this",
"->",
"relatedColumnName",
"=",
"$",
"columnName",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"relatedTableName",
"=",
"\"\"",
";",
"$",
"this",
"->",
"relatedColumnName",
"=",
"\"\"",
";",
"}",
"}"
] | Set the foreign key for this column.
@param string tableName The name of the table that is foreign.
@param string columnName The name of the column that is foreign.
@return void | [
"Set",
"the",
"foreign",
"key",
"for",
"this",
"column",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L335-L344 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.getRelation | public function getRelation()
{
if (!$this->relatedTableName) {
return null;
}
foreach ($this->getTable()->getRelations() as $name => $relation) {
if ($relation->getType() == RelationMap::MANY_TO_ONE) {
if ($relation->getForeignTable()->getName() == $this->getRelatedTableName() && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) {
return $relation;
}
}
}
} | php | public function getRelation()
{
if (!$this->relatedTableName) {
return null;
}
foreach ($this->getTable()->getRelations() as $name => $relation) {
if ($relation->getType() == RelationMap::MANY_TO_ONE) {
if ($relation->getForeignTable()->getName() == $this->getRelatedTableName() && array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings())) {
return $relation;
}
}
}
} | [
"public",
"function",
"getRelation",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"relatedTableName",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getRelations",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"relation",
")",
"{",
"if",
"(",
"$",
"relation",
"->",
"getType",
"(",
")",
"==",
"RelationMap",
"::",
"MANY_TO_ONE",
")",
"{",
"if",
"(",
"$",
"relation",
"->",
"getForeignTable",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"$",
"this",
"->",
"getRelatedTableName",
"(",
")",
"&&",
"array_key_exists",
"(",
"$",
"this",
"->",
"getFullyQualifiedName",
"(",
")",
",",
"$",
"relation",
"->",
"getColumnMappings",
"(",
")",
")",
")",
"{",
"return",
"$",
"relation",
";",
"}",
"}",
"}",
"}"
] | Get the RelationMap object for this foreign key
@return RelationMap|null | [
"Get",
"the",
"RelationMap",
"object",
"for",
"this",
"foreign",
"key"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L365-L377 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.getRelatedTable | public function getRelatedTable()
{
if ($this->relatedTableName) {
return $this->table->getDatabaseMap()->getTable($this->relatedTableName);
} else {
throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName);
}
} | php | public function getRelatedTable()
{
if ($this->relatedTableName) {
return $this->table->getDatabaseMap()->getTable($this->relatedTableName);
} else {
throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName);
}
} | [
"public",
"function",
"getRelatedTable",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relatedTableName",
")",
"{",
"return",
"$",
"this",
"->",
"table",
"->",
"getDatabaseMap",
"(",
")",
"->",
"getTable",
"(",
"$",
"this",
"->",
"relatedTableName",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot fetch RelatedTable for column with no foreign key: \"",
".",
"$",
"this",
"->",
"columnName",
")",
";",
"}",
"}"
] | Get the TableMap object that this column is related to.
@return TableMap The related TableMap object
@throws PropelException when called on a column with no foreign key | [
"Get",
"the",
"TableMap",
"object",
"that",
"this",
"column",
"is",
"related",
"to",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L415-L422 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.ignoreCase | public function ignoreCase($str, DBAdapter $db)
{
if ($this->isText()) {
return $db->ignoreCase($str);
} else {
return $str;
}
} | php | public function ignoreCase($str, DBAdapter $db)
{
if ($this->isText()) {
return $db->ignoreCase($str);
} else {
return $str;
}
} | [
"public",
"function",
"ignoreCase",
"(",
"$",
"str",
",",
"DBAdapter",
"$",
"db",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isText",
"(",
")",
")",
"{",
"return",
"$",
"db",
"->",
"ignoreCase",
"(",
"$",
"str",
")",
";",
"}",
"else",
"{",
"return",
"$",
"str",
";",
"}",
"}"
] | Performs DB-specific ignore case, but only if the column type necessitates it.
@param string $str The expression we want to apply the ignore case formatting to (e.g. the column name).
@param DBAdapter $db
@return string | [
"Performs",
"DB",
"-",
"specific",
"ignore",
"case",
"but",
"only",
"if",
"the",
"column",
"type",
"necessitates",
"it",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L488-L495 |
propelorm/Propel | runtime/lib/map/ColumnMap.php | ColumnMap.normalizeName | public static function normalizeName($name)
{
if (false !== ($pos = strrpos($name, '.'))) {
$name = substr($name, $pos + 1);
}
return $name;
} | php | public static function normalizeName($name)
{
if (false !== ($pos = strrpos($name, '.'))) {
$name = substr($name, $pos + 1);
}
return $name;
} | [
"public",
"static",
"function",
"normalizeName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"name",
",",
"'.'",
")",
")",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"$",
"pos",
"+",
"1",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Normalizes the column name, removing table prefix and uppercasing.
article.first_name becomes first_name
@param string $name
@return string Normalized column name. | [
"Normalizes",
"the",
"column",
"name",
"removing",
"table",
"prefix",
"and",
"uppercasing",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/ColumnMap.php#L506-L513 |
propelorm/Propel | generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php | PHP5MultiExtendObjectBuilder.getParentClasspath | protected function getParentClasspath()
{
if ($this->getChild()->getAncestor()) {
return $this->getChild()->getAncestor();
} else {
return $this->getObjectBuilder()->getClasspath();
}
} | php | protected function getParentClasspath()
{
if ($this->getChild()->getAncestor()) {
return $this->getChild()->getAncestor();
} else {
return $this->getObjectBuilder()->getClasspath();
}
} | [
"protected",
"function",
"getParentClasspath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getChild",
"(",
")",
"->",
"getAncestor",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getChild",
"(",
")",
"->",
"getAncestor",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getObjectBuilder",
"(",
")",
"->",
"getClasspath",
"(",
")",
";",
"}",
"}"
] | Returns classpath to parent class.
@return string | [
"Returns",
"classpath",
"to",
"parent",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php#L80-L87 |
propelorm/Propel | generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php | PHP5MultiExtendObjectBuilder.addClassOpen | protected function addClassOpen(&$script)
{
if ($this->getChild()->getAncestor()) {
$ancestorClassName = $this->getChild()->getAncestor();
if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) {
$this->declareClassFromBuilder($this->getNewStubObjectBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName)));
} else {
$this->declareClassNamespace($ancestorClassName, $this->getNamespace());
}
} else {
$this->declareClassFromBuilder($this->getObjectBuilder());
}
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$baseClassname = $this->getObjectBuilder()->getClassname();
$script .= "
/**
* Skeleton subclass for representing a row from one of the subclasses of the '$tableName' table.
*
* $tableDesc
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
}
$script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator." . $this->getPackage() . "
*/
class " . $this->getClassname() . " extends " . $this->getParentClassname() . " {
";
} | php | protected function addClassOpen(&$script)
{
if ($this->getChild()->getAncestor()) {
$ancestorClassName = $this->getChild()->getAncestor();
if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) {
$this->declareClassFromBuilder($this->getNewStubObjectBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName)));
} else {
$this->declareClassNamespace($ancestorClassName, $this->getNamespace());
}
} else {
$this->declareClassFromBuilder($this->getObjectBuilder());
}
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$baseClassname = $this->getObjectBuilder()->getClassname();
$script .= "
/**
* Skeleton subclass for representing a row from one of the subclasses of the '$tableName' table.
*
* $tableDesc
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
}
$script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator." . $this->getPackage() . "
*/
class " . $this->getClassname() . " extends " . $this->getParentClassname() . " {
";
} | [
"protected",
"function",
"addClassOpen",
"(",
"&",
"$",
"script",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getChild",
"(",
")",
"->",
"getAncestor",
"(",
")",
")",
"{",
"$",
"ancestorClassName",
"=",
"$",
"this",
"->",
"getChild",
"(",
")",
"->",
"getAncestor",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"hasTableByPhpName",
"(",
"$",
"ancestorClassName",
")",
")",
"{",
"$",
"this",
"->",
"declareClassFromBuilder",
"(",
"$",
"this",
"->",
"getNewStubObjectBuilder",
"(",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getTableByPhpName",
"(",
"$",
"ancestorClassName",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"declareClassNamespace",
"(",
"$",
"ancestorClassName",
",",
"$",
"this",
"->",
"getNamespace",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"declareClassFromBuilder",
"(",
"$",
"this",
"->",
"getObjectBuilder",
"(",
")",
")",
";",
"}",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"tableName",
"=",
"$",
"table",
"->",
"getName",
"(",
")",
";",
"$",
"tableDesc",
"=",
"$",
"table",
"->",
"getDescription",
"(",
")",
";",
"$",
"baseClassname",
"=",
"$",
"this",
"->",
"getObjectBuilder",
"(",
")",
"->",
"getClassname",
"(",
")",
";",
"$",
"script",
".=",
"\"\n\n/**\n * Skeleton subclass for representing a row from one of the subclasses of the '$tableName' table.\n *\n * $tableDesc\n *\"",
";",
"if",
"(",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'addTimeStamp'",
")",
")",
"{",
"$",
"now",
"=",
"strftime",
"(",
"'%c'",
")",
";",
"$",
"script",
".=",
"\"\n * This class was autogenerated by Propel \"",
".",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'version'",
")",
".",
"\" on:\n *\n * $now\n *\"",
";",
"}",
"$",
"script",
".=",
"\"\n * You should add additional methods to this class to meet the\n * application requirements. This class will only be generated as\n * long as it does not already exist in the output directory.\n *\n * @package propel.generator.\"",
".",
"$",
"this",
"->",
"getPackage",
"(",
")",
".",
"\"\n */\nclass \"",
".",
"$",
"this",
"->",
"getClassname",
"(",
")",
".",
"\" extends \"",
".",
"$",
"this",
"->",
"getParentClassname",
"(",
")",
".",
"\" {\n\"",
";",
"}"
] | Adds class phpdoc comment and opening of class.
@param string &$script The script will be modified in this method. | [
"Adds",
"class",
"phpdoc",
"comment",
"and",
"opening",
"of",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php#L123-L165 |
propelorm/Propel | generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php | PHP5MultiExtendObjectBuilder.addClassBody | protected function addClassBody(&$script)
{
$this->declareClassFromBuilder($this->getStubPeerBuilder());
$child = $this->getChild();
$col = $child->getColumn();
$cfc = $col->getPhpName();
$const = "CLASSKEY_" . strtoupper($child->getKey());
$script .= "
/**
* Constructs a new " . $this->getChild()->getClassname() . " class, setting the " . $col->getName() . " column to " . $this->getPeerClassname() . "::$const.
*/
public function __construct()
{";
$script .= "
parent::__construct();
\$this->set$cfc(" . $this->getPeerClassname() . "::CLASSKEY_" . strtoupper($child->getKey()) . ");
}
";
} | php | protected function addClassBody(&$script)
{
$this->declareClassFromBuilder($this->getStubPeerBuilder());
$child = $this->getChild();
$col = $child->getColumn();
$cfc = $col->getPhpName();
$const = "CLASSKEY_" . strtoupper($child->getKey());
$script .= "
/**
* Constructs a new " . $this->getChild()->getClassname() . " class, setting the " . $col->getName() . " column to " . $this->getPeerClassname() . "::$const.
*/
public function __construct()
{";
$script .= "
parent::__construct();
\$this->set$cfc(" . $this->getPeerClassname() . "::CLASSKEY_" . strtoupper($child->getKey()) . ");
}
";
} | [
"protected",
"function",
"addClassBody",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"this",
"->",
"declareClassFromBuilder",
"(",
"$",
"this",
"->",
"getStubPeerBuilder",
"(",
")",
")",
";",
"$",
"child",
"=",
"$",
"this",
"->",
"getChild",
"(",
")",
";",
"$",
"col",
"=",
"$",
"child",
"->",
"getColumn",
"(",
")",
";",
"$",
"cfc",
"=",
"$",
"col",
"->",
"getPhpName",
"(",
")",
";",
"$",
"const",
"=",
"\"CLASSKEY_\"",
".",
"strtoupper",
"(",
"$",
"child",
"->",
"getKey",
"(",
")",
")",
";",
"$",
"script",
".=",
"\"\n /**\n * Constructs a new \"",
".",
"$",
"this",
"->",
"getChild",
"(",
")",
"->",
"getClassname",
"(",
")",
".",
"\" class, setting the \"",
".",
"$",
"col",
"->",
"getName",
"(",
")",
".",
"\" column to \"",
".",
"$",
"this",
"->",
"getPeerClassname",
"(",
")",
".",
"\"::$const.\n */\n public function __construct()\n {\"",
";",
"$",
"script",
".=",
"\"\n parent::__construct();\n \\$this->set$cfc(\"",
".",
"$",
"this",
"->",
"getPeerClassname",
"(",
")",
".",
"\"::CLASSKEY_\"",
".",
"strtoupper",
"(",
"$",
"child",
"->",
"getKey",
"(",
")",
")",
".",
"\");\n }\n\"",
";",
"}"
] | Specifies the methods that are added as part of the stub object class.
By default there are no methods for the empty stub classes; override this method
if you want to change that behavior.
@see ObjectBuilder::addClassBody() | [
"Specifies",
"the",
"methods",
"that",
"are",
"added",
"as",
"part",
"of",
"the",
"stub",
"object",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5MultiExtendObjectBuilder.php#L175-L195 |
propelorm/Propel | runtime/lib/formatter/PropelObjectFormatter.php | PropelObjectFormatter.getAllObjectsFromRow | public function getAllObjectsFromRow($row)
{
// get the main object
list($obj, $col) = call_user_func(array($this->peer, 'populateObject'), $row);
if (null !== $this->mainObject) {
$obj = $this->mainObject;
}
// related objects added using with()
foreach ($this->getWith() as $modelWith) {
list($endObject, $col) = call_user_func(array($modelWith->getModelPeerName(), 'populateObject'), $row, $col);
if (null !== $modelWith->getLeftPhpName() && !isset($hydrationChain[$modelWith->getLeftPhpName()])) {
continue;
}
if ($modelWith->isPrimary()) {
$startObject = $obj;
} elseif (isset($hydrationChain)) {
$startObject = $hydrationChain[$modelWith->getLeftPhpName()];
} else {
continue;
}
// as we may be in a left join, the endObject may be empty
// in which case it should not be related to the previous object
if (null === $endObject || $endObject->isPrimaryKeyNull()) {
if ($modelWith->isAdd()) {
call_user_func(array($startObject, $modelWith->getInitMethod()), false);
}
continue;
}
if (isset($hydrationChain)) {
$hydrationChain[$modelWith->getRightPhpName()] = $endObject;
} else {
$hydrationChain = array($modelWith->getRightPhpName() => $endObject);
}
call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject);
if ($modelWith->isAdd()) {
call_user_func(array($startObject, $modelWith->getResetPartialMethod()), false);
}
}
// columns added using withColumn()
foreach ($this->getAsColumns() as $alias => $clause) {
$obj->setVirtualColumn($alias, $row[$col]);
$col++;
}
return $obj;
} | php | public function getAllObjectsFromRow($row)
{
// get the main object
list($obj, $col) = call_user_func(array($this->peer, 'populateObject'), $row);
if (null !== $this->mainObject) {
$obj = $this->mainObject;
}
// related objects added using with()
foreach ($this->getWith() as $modelWith) {
list($endObject, $col) = call_user_func(array($modelWith->getModelPeerName(), 'populateObject'), $row, $col);
if (null !== $modelWith->getLeftPhpName() && !isset($hydrationChain[$modelWith->getLeftPhpName()])) {
continue;
}
if ($modelWith->isPrimary()) {
$startObject = $obj;
} elseif (isset($hydrationChain)) {
$startObject = $hydrationChain[$modelWith->getLeftPhpName()];
} else {
continue;
}
// as we may be in a left join, the endObject may be empty
// in which case it should not be related to the previous object
if (null === $endObject || $endObject->isPrimaryKeyNull()) {
if ($modelWith->isAdd()) {
call_user_func(array($startObject, $modelWith->getInitMethod()), false);
}
continue;
}
if (isset($hydrationChain)) {
$hydrationChain[$modelWith->getRightPhpName()] = $endObject;
} else {
$hydrationChain = array($modelWith->getRightPhpName() => $endObject);
}
call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject);
if ($modelWith->isAdd()) {
call_user_func(array($startObject, $modelWith->getResetPartialMethod()), false);
}
}
// columns added using withColumn()
foreach ($this->getAsColumns() as $alias => $clause) {
$obj->setVirtualColumn($alias, $row[$col]);
$col++;
}
return $obj;
} | [
"public",
"function",
"getAllObjectsFromRow",
"(",
"$",
"row",
")",
"{",
"// get the main object",
"list",
"(",
"$",
"obj",
",",
"$",
"col",
")",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"peer",
",",
"'populateObject'",
")",
",",
"$",
"row",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"mainObject",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"mainObject",
";",
"}",
"// related objects added using with()",
"foreach",
"(",
"$",
"this",
"->",
"getWith",
"(",
")",
"as",
"$",
"modelWith",
")",
"{",
"list",
"(",
"$",
"endObject",
",",
"$",
"col",
")",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"modelWith",
"->",
"getModelPeerName",
"(",
")",
",",
"'populateObject'",
")",
",",
"$",
"row",
",",
"$",
"col",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"modelWith",
"->",
"getLeftPhpName",
"(",
")",
"&&",
"!",
"isset",
"(",
"$",
"hydrationChain",
"[",
"$",
"modelWith",
"->",
"getLeftPhpName",
"(",
")",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"modelWith",
"->",
"isPrimary",
"(",
")",
")",
"{",
"$",
"startObject",
"=",
"$",
"obj",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"hydrationChain",
")",
")",
"{",
"$",
"startObject",
"=",
"$",
"hydrationChain",
"[",
"$",
"modelWith",
"->",
"getLeftPhpName",
"(",
")",
"]",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"// as we may be in a left join, the endObject may be empty",
"// in which case it should not be related to the previous object",
"if",
"(",
"null",
"===",
"$",
"endObject",
"||",
"$",
"endObject",
"->",
"isPrimaryKeyNull",
"(",
")",
")",
"{",
"if",
"(",
"$",
"modelWith",
"->",
"isAdd",
"(",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"startObject",
",",
"$",
"modelWith",
"->",
"getInitMethod",
"(",
")",
")",
",",
"false",
")",
";",
"}",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"hydrationChain",
")",
")",
"{",
"$",
"hydrationChain",
"[",
"$",
"modelWith",
"->",
"getRightPhpName",
"(",
")",
"]",
"=",
"$",
"endObject",
";",
"}",
"else",
"{",
"$",
"hydrationChain",
"=",
"array",
"(",
"$",
"modelWith",
"->",
"getRightPhpName",
"(",
")",
"=>",
"$",
"endObject",
")",
";",
"}",
"call_user_func",
"(",
"array",
"(",
"$",
"startObject",
",",
"$",
"modelWith",
"->",
"getRelationMethod",
"(",
")",
")",
",",
"$",
"endObject",
")",
";",
"if",
"(",
"$",
"modelWith",
"->",
"isAdd",
"(",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"startObject",
",",
"$",
"modelWith",
"->",
"getResetPartialMethod",
"(",
")",
")",
",",
"false",
")",
";",
"}",
"}",
"// columns added using withColumn()",
"foreach",
"(",
"$",
"this",
"->",
"getAsColumns",
"(",
")",
"as",
"$",
"alias",
"=>",
"$",
"clause",
")",
"{",
"$",
"obj",
"->",
"setVirtualColumn",
"(",
"$",
"alias",
",",
"$",
"row",
"[",
"$",
"col",
"]",
")",
";",
"$",
"col",
"++",
";",
"}",
"return",
"$",
"obj",
";",
"}"
] | Hydrates a series of objects from a result row
The first object to hydrate is the model of the Criteria
The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one
@param array $row associative array indexed by column number,
as returned by PDOStatement::fetch(PDO::FETCH_NUM)
@return BaseObject | [
"Hydrates",
"a",
"series",
"of",
"objects",
"from",
"a",
"result",
"row",
"The",
"first",
"object",
"to",
"hydrate",
"is",
"the",
"model",
"of",
"the",
"Criteria",
"The",
"following",
"objects",
"(",
"the",
"ones",
"added",
"by",
"way",
"of",
"ModelCriteria",
"::",
"with",
"()",
")",
"are",
"linked",
"to",
"the",
"first",
"one"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/formatter/PropelObjectFormatter.php#L100-L152 |
propelorm/Propel | runtime/lib/parser/yaml/sfYamlDumper.php | sfYamlDumper.dump | public function dump($input, $inline = 0, $indent = 0)
{
$output = '';
$prefix = $indent ? str_repeat(' ', $indent) : '';
if ($inline <= 0 || !is_array($input) || empty($input)) {
$output .= $prefix.sfYamlInline::dump($input);
} else {
$isAHash = array_keys($input) !== range(0, count($input) - 1);
foreach ($input as $key => $value) {
$willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);
$output .= sprintf('%s%s%s%s',
$prefix,
$isAHash ? sfYamlInline::dump($key).':' : '-',
$willBeInlined ? ' ' : "\n",
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2)
).($willBeInlined ? "\n" : '');
}
}
return $output;
} | php | public function dump($input, $inline = 0, $indent = 0)
{
$output = '';
$prefix = $indent ? str_repeat(' ', $indent) : '';
if ($inline <= 0 || !is_array($input) || empty($input)) {
$output .= $prefix.sfYamlInline::dump($input);
} else {
$isAHash = array_keys($input) !== range(0, count($input) - 1);
foreach ($input as $key => $value) {
$willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value);
$output .= sprintf('%s%s%s%s',
$prefix,
$isAHash ? sfYamlInline::dump($key).':' : '-',
$willBeInlined ? ' ' : "\n",
$this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + 2)
).($willBeInlined ? "\n" : '');
}
}
return $output;
} | [
"public",
"function",
"dump",
"(",
"$",
"input",
",",
"$",
"inline",
"=",
"0",
",",
"$",
"indent",
"=",
"0",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"prefix",
"=",
"$",
"indent",
"?",
"str_repeat",
"(",
"' '",
",",
"$",
"indent",
")",
":",
"''",
";",
"if",
"(",
"$",
"inline",
"<=",
"0",
"||",
"!",
"is_array",
"(",
"$",
"input",
")",
"||",
"empty",
"(",
"$",
"input",
")",
")",
"{",
"$",
"output",
".=",
"$",
"prefix",
".",
"sfYamlInline",
"::",
"dump",
"(",
"$",
"input",
")",
";",
"}",
"else",
"{",
"$",
"isAHash",
"=",
"array_keys",
"(",
"$",
"input",
")",
"!==",
"range",
"(",
"0",
",",
"count",
"(",
"$",
"input",
")",
"-",
"1",
")",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"willBeInlined",
"=",
"$",
"inline",
"-",
"1",
"<=",
"0",
"||",
"!",
"is_array",
"(",
"$",
"value",
")",
"||",
"empty",
"(",
"$",
"value",
")",
";",
"$",
"output",
".=",
"sprintf",
"(",
"'%s%s%s%s'",
",",
"$",
"prefix",
",",
"$",
"isAHash",
"?",
"sfYamlInline",
"::",
"dump",
"(",
"$",
"key",
")",
".",
"':'",
":",
"'-'",
",",
"$",
"willBeInlined",
"?",
"' '",
":",
"\"\\n\"",
",",
"$",
"this",
"->",
"dump",
"(",
"$",
"value",
",",
"$",
"inline",
"-",
"1",
",",
"$",
"willBeInlined",
"?",
"0",
":",
"$",
"indent",
"+",
"2",
")",
")",
".",
"(",
"$",
"willBeInlined",
"?",
"\"\\n\"",
":",
"''",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Dumps a PHP value to YAML.
@param mixed $input The PHP value
@param integer $inline The level where you switch to inline YAML
@param integer $indent The level o indentation indentation (used internally)
@return string The YAML representation of the PHP value | [
"Dumps",
"a",
"PHP",
"value",
"to",
"YAML",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlDumper.php#L32-L55 |
propelorm/Propel | generator/lib/builder/om/PeerBuilder.php | PeerBuilder.addSelectMethods | protected function addSelectMethods(&$script)
{
$this->addAddSelectColumns($script);
$this->addDoCount($script);
// consider refactoring the doSelect stuff
// into a top-level method
$this->addDoSelectOne($script);
$this->addDoSelect($script);
$this->addDoSelectStmt($script); // <-- there's PDO code in here
$this->addAddInstanceToPool($script);
$this->addRemoveInstanceFromPool($script);
$this->addGetInstanceFromPool($script);
$this->addClearInstancePool($script);
$this->addClearRelatedInstancePool($script);
$this->addGetPrimaryKeyHash($script);
$this->addGetPrimaryKeyFromRow($script);
$this->addPopulateObjects($script); // <-- there's PDO code in here
$this->addPopulateObject($script);
} | php | protected function addSelectMethods(&$script)
{
$this->addAddSelectColumns($script);
$this->addDoCount($script);
// consider refactoring the doSelect stuff
// into a top-level method
$this->addDoSelectOne($script);
$this->addDoSelect($script);
$this->addDoSelectStmt($script); // <-- there's PDO code in here
$this->addAddInstanceToPool($script);
$this->addRemoveInstanceFromPool($script);
$this->addGetInstanceFromPool($script);
$this->addClearInstancePool($script);
$this->addClearRelatedInstancePool($script);
$this->addGetPrimaryKeyHash($script);
$this->addGetPrimaryKeyFromRow($script);
$this->addPopulateObjects($script); // <-- there's PDO code in here
$this->addPopulateObject($script);
} | [
"protected",
"function",
"addSelectMethods",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"this",
"->",
"addAddSelectColumns",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoCount",
"(",
"$",
"script",
")",
";",
"// consider refactoring the doSelect stuff",
"// into a top-level method",
"$",
"this",
"->",
"addDoSelectOne",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoSelect",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoSelectStmt",
"(",
"$",
"script",
")",
";",
"// <-- there's PDO code in here",
"$",
"this",
"->",
"addAddInstanceToPool",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRemoveInstanceFromPool",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetInstanceFromPool",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addClearInstancePool",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addClearRelatedInstancePool",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetPrimaryKeyHash",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetPrimaryKeyFromRow",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addPopulateObjects",
"(",
"$",
"script",
")",
";",
"// <-- there's PDO code in here",
"$",
"this",
"->",
"addPopulateObject",
"(",
"$",
"script",
")",
";",
"}"
] | Adds the addSelectColumns(), doCount(), etc. methods.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"addSelectColumns",
"()",
"doCount",
"()",
"etc",
".",
"methods",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PeerBuilder.php#L48-L70 |
propelorm/Propel | generator/lib/builder/om/PeerBuilder.php | PeerBuilder.addUpdateMethods | protected function addUpdateMethods(&$script)
{
$this->addDoInsert($script);
$this->addDoUpdate($script);
$this->addDoDeleteAll($script);
$this->addDoDelete($script);
if ($this->isDeleteCascadeEmulationNeeded()) {
$this->addDoOnDeleteCascade($script);
}
if ($this->isDeleteSetNullEmulationNeeded()) {
$this->addDoOnDeleteSetNull($script);
}
$this->addDoValidate($script);
} | php | protected function addUpdateMethods(&$script)
{
$this->addDoInsert($script);
$this->addDoUpdate($script);
$this->addDoDeleteAll($script);
$this->addDoDelete($script);
if ($this->isDeleteCascadeEmulationNeeded()) {
$this->addDoOnDeleteCascade($script);
}
if ($this->isDeleteSetNullEmulationNeeded()) {
$this->addDoOnDeleteSetNull($script);
}
$this->addDoValidate($script);
} | [
"protected",
"function",
"addUpdateMethods",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"this",
"->",
"addDoInsert",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoUpdate",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoDeleteAll",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoDelete",
"(",
"$",
"script",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isDeleteCascadeEmulationNeeded",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addDoOnDeleteCascade",
"(",
"$",
"script",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isDeleteSetNullEmulationNeeded",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addDoOnDeleteSetNull",
"(",
"$",
"script",
")",
";",
"}",
"$",
"this",
"->",
"addDoValidate",
"(",
"$",
"script",
")",
";",
"}"
] | Adds the doInsert(), doUpdate(), doDeleteAll(), doValidate(), etc. methods.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"doInsert",
"()",
"doUpdate",
"()",
"doDeleteAll",
"()",
"doValidate",
"()",
"etc",
".",
"methods",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PeerBuilder.php#L96-L109 |
propelorm/Propel | generator/lib/builder/om/PeerBuilder.php | PeerBuilder.addRetrieveByPKMethods | protected function addRetrieveByPKMethods(&$script)
{
if (count($this->getTable()->getPrimaryKey()) === 1) {
$this->addRetrieveByPK_SinglePK($script);
$this->addRetrieveByPKs_SinglePK($script);
} else {
$this->addRetrieveByPK_MultiPK($script);
}
} | php | protected function addRetrieveByPKMethods(&$script)
{
if (count($this->getTable()->getPrimaryKey()) === 1) {
$this->addRetrieveByPK_SinglePK($script);
$this->addRetrieveByPKs_SinglePK($script);
} else {
$this->addRetrieveByPK_MultiPK($script);
}
} | [
"protected",
"function",
"addRetrieveByPKMethods",
"(",
"&",
"$",
"script",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
")",
"===",
"1",
")",
"{",
"$",
"this",
"->",
"addRetrieveByPK_SinglePK",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addRetrieveByPKs_SinglePK",
"(",
"$",
"script",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addRetrieveByPK_MultiPK",
"(",
"$",
"script",
")",
";",
"}",
"}"
] | Adds the retrieveByPK() (and possibly retrieveByPKs()) method(s) appropriate for this class.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"retrieveByPK",
"()",
"(",
"and",
"possibly",
"retrieveByPKs",
"()",
")",
"method",
"(",
"s",
")",
"appropriate",
"for",
"this",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PeerBuilder.php#L116-L124 |
propelorm/Propel | generator/lib/builder/om/PeerBuilder.php | PeerBuilder.addClassBody | protected function addClassBody(&$script)
{
$table = $this->getTable();
if (!$table->isAlias()) {
$this->addConstantsAndAttributes($script);
}
$this->addTranslateFieldName($script);
$this->addGetFieldNames($script);
if ($table->hasEnumColumns()) {
$this->addGetValueSets($script);
$this->addGetValueSet($script);
$this->addGetSqlValueForEnum($script);
}
if (!$table->isAlias()) {
$this->addAlias($script); // alias() utility method (deprecated?)
$this->addSelectMethods($script);
$this->addGetTableMap($script);
}
$this->addBuildTableMap($script);
$this->addGetOMClassMethod($script);
// add the insert, update, delete, validate etc. methods
if (!$table->isAlias() && !$table->isReadOnly()) {
$this->addUpdateMethods($script);
}
if (count($table->getPrimaryKey()) > 0) {
$this->addRetrieveByPKMethods($script);
}
} | php | protected function addClassBody(&$script)
{
$table = $this->getTable();
if (!$table->isAlias()) {
$this->addConstantsAndAttributes($script);
}
$this->addTranslateFieldName($script);
$this->addGetFieldNames($script);
if ($table->hasEnumColumns()) {
$this->addGetValueSets($script);
$this->addGetValueSet($script);
$this->addGetSqlValueForEnum($script);
}
if (!$table->isAlias()) {
$this->addAlias($script); // alias() utility method (deprecated?)
$this->addSelectMethods($script);
$this->addGetTableMap($script);
}
$this->addBuildTableMap($script);
$this->addGetOMClassMethod($script);
// add the insert, update, delete, validate etc. methods
if (!$table->isAlias() && !$table->isReadOnly()) {
$this->addUpdateMethods($script);
}
if (count($table->getPrimaryKey()) > 0) {
$this->addRetrieveByPKMethods($script);
}
} | [
"protected",
"function",
"addClassBody",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"table",
"->",
"isAlias",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addConstantsAndAttributes",
"(",
"$",
"script",
")",
";",
"}",
"$",
"this",
"->",
"addTranslateFieldName",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetFieldNames",
"(",
"$",
"script",
")",
";",
"if",
"(",
"$",
"table",
"->",
"hasEnumColumns",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addGetValueSets",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetValueSet",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetSqlValueForEnum",
"(",
"$",
"script",
")",
";",
"}",
"if",
"(",
"!",
"$",
"table",
"->",
"isAlias",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addAlias",
"(",
"$",
"script",
")",
";",
"// alias() utility method (deprecated?)",
"$",
"this",
"->",
"addSelectMethods",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetTableMap",
"(",
"$",
"script",
")",
";",
"}",
"$",
"this",
"->",
"addBuildTableMap",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetOMClassMethod",
"(",
"$",
"script",
")",
";",
"// add the insert, update, delete, validate etc. methods",
"if",
"(",
"!",
"$",
"table",
"->",
"isAlias",
"(",
")",
"&&",
"!",
"$",
"table",
"->",
"isReadOnly",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addUpdateMethods",
"(",
"$",
"script",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"table",
"->",
"getPrimaryKey",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"addRetrieveByPKMethods",
"(",
"$",
"script",
")",
";",
"}",
"}"
] | This method adds the contents of the generated class to the script.
This method contains the high-level logic that determines which methods
get generated.
Hint: Override this method in your subclass if you want to reorganize or
drastically change the contents of the generated peer class.
@param string &$script The script will be modified in this method. | [
"This",
"method",
"adds",
"the",
"contents",
"of",
"the",
"generated",
"class",
"to",
"the",
"script",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PeerBuilder.php#L137-L173 |
propelorm/Propel | generator/lib/builder/om/PeerBuilder.php | PeerBuilder.getRetrieveMethodName | public function getRetrieveMethodName()
{
if ($this->getTable()->isAlias()) {
$retrieveMethod = "retrieve" . $this->getTable()->getPhpName() . "ByPK";
} else {
$retrieveMethod = "retrieveByPK";
}
return $retrieveMethod;
} | php | public function getRetrieveMethodName()
{
if ($this->getTable()->isAlias()) {
$retrieveMethod = "retrieve" . $this->getTable()->getPhpName() . "ByPK";
} else {
$retrieveMethod = "retrieveByPK";
}
return $retrieveMethod;
} | [
"public",
"function",
"getRetrieveMethodName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"isAlias",
"(",
")",
")",
"{",
"$",
"retrieveMethod",
"=",
"\"retrieve\"",
".",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getPhpName",
"(",
")",
".",
"\"ByPK\"",
";",
"}",
"else",
"{",
"$",
"retrieveMethod",
"=",
"\"retrieveByPK\"",
";",
"}",
"return",
"$",
"retrieveMethod",
";",
"}"
] | Returns the retrieveByPK method name to use for this table.
If the table is an alias then the method name looks like "retrieveTablenameByPK"
otherwise simply "retrieveByPK".
@return string | [
"Returns",
"the",
"retrieveByPK",
"method",
"name",
"to",
"use",
"for",
"this",
"table",
".",
"If",
"the",
"table",
"is",
"an",
"alias",
"then",
"the",
"method",
"name",
"looks",
"like",
"retrieveTablenameByPK",
"otherwise",
"simply",
"retrieveByPK",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PeerBuilder.php#L248-L257 |
propelorm/Propel | generator/lib/builder/om/PeerBuilder.php | PeerBuilder.getColumnName | public static function getColumnName(Column $col, $phpName = null)
{
// was it overridden in schema.xml ?
if ($col->getPeerName()) {
$const = strtoupper($col->getPeerName());
} else {
$const = strtoupper($col->getName());
}
if ($phpName !== null) {
return $phpName . 'Peer::' . $const;
} else {
return $const;
}
} | php | public static function getColumnName(Column $col, $phpName = null)
{
// was it overridden in schema.xml ?
if ($col->getPeerName()) {
$const = strtoupper($col->getPeerName());
} else {
$const = strtoupper($col->getName());
}
if ($phpName !== null) {
return $phpName . 'Peer::' . $const;
} else {
return $const;
}
} | [
"public",
"static",
"function",
"getColumnName",
"(",
"Column",
"$",
"col",
",",
"$",
"phpName",
"=",
"null",
")",
"{",
"// was it overridden in schema.xml ?",
"if",
"(",
"$",
"col",
"->",
"getPeerName",
"(",
")",
")",
"{",
"$",
"const",
"=",
"strtoupper",
"(",
"$",
"col",
"->",
"getPeerName",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"const",
"=",
"strtoupper",
"(",
"$",
"col",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"phpName",
"!==",
"null",
")",
"{",
"return",
"$",
"phpName",
".",
"'Peer::'",
".",
"$",
"const",
";",
"}",
"else",
"{",
"return",
"$",
"const",
";",
"}",
"}"
] | COMPATIBILITY: Get the column constant name (e.g. PeerName::COLUMN_NAME).
This method exists simply because it belonged to the 'PeerBuilder' that this
class is replacing (because of name conflict more than actual functionality overlap).
When the new builder model is finished this method will be removed.
@param Column $col The column we need a name for.
@param string $phpName The PHP Name of the peer class. The 'Peer' is appended automatically.
@return string If $phpName is provided, then will return {$phpName}Peer::COLUMN_NAME; if not, just COLUMN_NAME.
@deprecated | [
"COMPATIBILITY",
":",
"Get",
"the",
"column",
"constant",
"name",
"(",
"e",
".",
"g",
".",
"PeerName",
"::",
"COLUMN_NAME",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PeerBuilder.php#L272-L285 |
propelorm/Propel | generator/lib/builder/om/ObjectBuilder.php | ObjectBuilder.addColumnAccessorMethods | protected function addColumnAccessorMethods(&$script)
{
$table = $this->getTable();
foreach ($table->getColumns() as $col) {
// if they're not using the DateTime class than we will generate "compatibility" accessor method
if ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) {
$this->addTemporalAccessor($script, $col);
} elseif ($col->getType() === PropelTypes::OBJECT) {
$this->addObjectAccessor($script, $col);
} elseif ($col->getType() === PropelTypes::PHP_ARRAY) {
$this->addArrayAccessor($script, $col);
if ($col->isNamePlural()) {
$this->addHasArrayElement($script, $col);
}
} elseif ($col->isEnumType()) {
$this->addEnumAccessor($script, $col);
} else {
$this->addDefaultAccessor($script, $col);
}
if ($col->isLazyLoad()) {
$this->addLazyLoader($script, $col);
}
}
} | php | protected function addColumnAccessorMethods(&$script)
{
$table = $this->getTable();
foreach ($table->getColumns() as $col) {
// if they're not using the DateTime class than we will generate "compatibility" accessor method
if ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) {
$this->addTemporalAccessor($script, $col);
} elseif ($col->getType() === PropelTypes::OBJECT) {
$this->addObjectAccessor($script, $col);
} elseif ($col->getType() === PropelTypes::PHP_ARRAY) {
$this->addArrayAccessor($script, $col);
if ($col->isNamePlural()) {
$this->addHasArrayElement($script, $col);
}
} elseif ($col->isEnumType()) {
$this->addEnumAccessor($script, $col);
} else {
$this->addDefaultAccessor($script, $col);
}
if ($col->isLazyLoad()) {
$this->addLazyLoader($script, $col);
}
}
} | [
"protected",
"function",
"addColumnAccessorMethods",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"// if they're not using the DateTime class than we will generate \"compatibility\" accessor method",
"if",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"DATE",
"||",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"TIME",
"||",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"TIMESTAMP",
")",
"{",
"$",
"this",
"->",
"addTemporalAccessor",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"elseif",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"OBJECT",
")",
"{",
"$",
"this",
"->",
"addObjectAccessor",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"elseif",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"PHP_ARRAY",
")",
"{",
"$",
"this",
"->",
"addArrayAccessor",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"if",
"(",
"$",
"col",
"->",
"isNamePlural",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addHasArrayElement",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"col",
"->",
"isEnumType",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addEnumAccessor",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addDefaultAccessor",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"if",
"(",
"$",
"col",
"->",
"isLazyLoad",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addLazyLoader",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"}",
"}"
] | Adds the getter methods for the column values.
This is here because it is probably generic enough to apply to templates being generated
in different languages (e.g. PHP4 and PHP5).
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"getter",
"methods",
"for",
"the",
"column",
"values",
".",
"This",
"is",
"here",
"because",
"it",
"is",
"probably",
"generic",
"enough",
"to",
"apply",
"to",
"templates",
"being",
"generated",
"in",
"different",
"languages",
"(",
"e",
".",
"g",
".",
"PHP4",
"and",
"PHP5",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/ObjectBuilder.php#L54-L80 |
propelorm/Propel | generator/lib/builder/om/ObjectBuilder.php | ObjectBuilder.addColumnMutatorMethods | protected function addColumnMutatorMethods(&$script)
{
foreach ($this->getTable()->getColumns() as $col) {
if ($col->isLobType()) {
$this->addLobMutator($script, $col);
} elseif ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) {
$this->addTemporalMutator($script, $col);
} elseif ($col->getType() === PropelTypes::OBJECT) {
$this->addObjectMutator($script, $col);
} elseif ($col->getType() === PropelTypes::PHP_ARRAY) {
$this->addArrayMutator($script, $col);
if ($col->isNamePlural()) {
$this->addAddArrayElement($script, $col);
$this->addRemoveArrayElement($script, $col);
}
} elseif ($col->isEnumType()) {
$this->addEnumMutator($script, $col);
} elseif ($col->isBooleanType()) {
$this->addBooleanMutator($script, $col);
} else {
$this->addDefaultMutator($script, $col);
}
}
} | php | protected function addColumnMutatorMethods(&$script)
{
foreach ($this->getTable()->getColumns() as $col) {
if ($col->isLobType()) {
$this->addLobMutator($script, $col);
} elseif ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) {
$this->addTemporalMutator($script, $col);
} elseif ($col->getType() === PropelTypes::OBJECT) {
$this->addObjectMutator($script, $col);
} elseif ($col->getType() === PropelTypes::PHP_ARRAY) {
$this->addArrayMutator($script, $col);
if ($col->isNamePlural()) {
$this->addAddArrayElement($script, $col);
$this->addRemoveArrayElement($script, $col);
}
} elseif ($col->isEnumType()) {
$this->addEnumMutator($script, $col);
} elseif ($col->isBooleanType()) {
$this->addBooleanMutator($script, $col);
} else {
$this->addDefaultMutator($script, $col);
}
}
} | [
"protected",
"function",
"addColumnMutatorMethods",
"(",
"&",
"$",
"script",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isLobType",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addLobMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"elseif",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"DATE",
"||",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"TIME",
"||",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"TIMESTAMP",
")",
"{",
"$",
"this",
"->",
"addTemporalMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"elseif",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"OBJECT",
")",
"{",
"$",
"this",
"->",
"addObjectMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"elseif",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
"===",
"PropelTypes",
"::",
"PHP_ARRAY",
")",
"{",
"$",
"this",
"->",
"addArrayMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"if",
"(",
"$",
"col",
"->",
"isNamePlural",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addAddArrayElement",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"$",
"this",
"->",
"addRemoveArrayElement",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"col",
"->",
"isEnumType",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addEnumMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"elseif",
"(",
"$",
"col",
"->",
"isBooleanType",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addBooleanMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addDefaultMutator",
"(",
"$",
"script",
",",
"$",
"col",
")",
";",
"}",
"}",
"}"
] | Adds the mutator (setter) methods for setting column values.
This is here because it is probably generic enough to apply to templates being generated
in different langauges (e.g. PHP4 and PHP5).
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"mutator",
"(",
"setter",
")",
"methods",
"for",
"setting",
"column",
"values",
".",
"This",
"is",
"here",
"because",
"it",
"is",
"probably",
"generic",
"enough",
"to",
"apply",
"to",
"templates",
"being",
"generated",
"in",
"different",
"langauges",
"(",
"e",
".",
"g",
".",
"PHP4",
"and",
"PHP5",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/ObjectBuilder.php#L89-L112 |
propelorm/Propel | generator/lib/model/Index.php | Index.getName | public function getName()
{
if ($this->indexName === null) {
try {
// generate an index name if we don't have a supplied one
$this->createName();
} catch (EngineException $e) {
// still no name
}
}
if ($database = $this->getTable()->getDatabase()) {
return substr($this->indexName, 0, $database->getPlatform()->getMaxColumnNameLength());
} else {
return $this->indexName;
}
} | php | public function getName()
{
if ($this->indexName === null) {
try {
// generate an index name if we don't have a supplied one
$this->createName();
} catch (EngineException $e) {
// still no name
}
}
if ($database = $this->getTable()->getDatabase()) {
return substr($this->indexName, 0, $database->getPlatform()->getMaxColumnNameLength());
} else {
return $this->indexName;
}
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"indexName",
"===",
"null",
")",
"{",
"try",
"{",
"// generate an index name if we don't have a supplied one",
"$",
"this",
"->",
"createName",
"(",
")",
";",
"}",
"catch",
"(",
"EngineException",
"$",
"e",
")",
"{",
"// still no name",
"}",
"}",
"if",
"(",
"$",
"database",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
")",
"{",
"return",
"substr",
"(",
"$",
"this",
"->",
"indexName",
",",
"0",
",",
"$",
"database",
"->",
"getPlatform",
"(",
")",
"->",
"getMaxColumnNameLength",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"indexName",
";",
"}",
"}"
] | Gets the name of this index. | [
"Gets",
"the",
"name",
"of",
"this",
"index",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Index.php#L111-L126 |
propelorm/Propel | generator/lib/model/Index.php | Index.addColumn | public function addColumn($data)
{
if ($data instanceof Column) {
$column = $data;
$this->indexColumns[] = $column->getName();
if ($column->getSize()) {
$this->indexColumnSizes[$column->getName()] = $column->getSize();
}
} else {
$attrib = $data;
$name = $attrib["name"];
$this->indexColumns[] = $name;
if (isset($attrib["size"])) {
$this->indexColumnSizes[$name] = $attrib["size"];
}
}
} | php | public function addColumn($data)
{
if ($data instanceof Column) {
$column = $data;
$this->indexColumns[] = $column->getName();
if ($column->getSize()) {
$this->indexColumnSizes[$column->getName()] = $column->getSize();
}
} else {
$attrib = $data;
$name = $attrib["name"];
$this->indexColumns[] = $name;
if (isset($attrib["size"])) {
$this->indexColumnSizes[$name] = $attrib["size"];
}
}
} | [
"public",
"function",
"addColumn",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Column",
")",
"{",
"$",
"column",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"indexColumns",
"[",
"]",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"column",
"->",
"getSize",
"(",
")",
")",
"{",
"$",
"this",
"->",
"indexColumnSizes",
"[",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"column",
"->",
"getSize",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"attrib",
"=",
"$",
"data",
";",
"$",
"name",
"=",
"$",
"attrib",
"[",
"\"name\"",
"]",
";",
"$",
"this",
"->",
"indexColumns",
"[",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"isset",
"(",
"$",
"attrib",
"[",
"\"size\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"indexColumnSizes",
"[",
"$",
"name",
"]",
"=",
"$",
"attrib",
"[",
"\"size\"",
"]",
";",
"}",
"}",
"}"
] | Adds a new column to an index.
@param mixed $data Column or attributes from XML. | [
"Adds",
"a",
"new",
"column",
"to",
"an",
"index",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Index.php#L174-L190 |
propelorm/Propel | generator/lib/model/Index.php | Index.setColumns | public function setColumns(array $indexColumns)
{
$this->indexColumns = array();
$this->indexColumnSizes = array();
foreach ($indexColumns as $col) {
$this->addColumn($col);
}
} | php | public function setColumns(array $indexColumns)
{
$this->indexColumns = array();
$this->indexColumnSizes = array();
foreach ($indexColumns as $col) {
$this->addColumn($col);
}
} | [
"public",
"function",
"setColumns",
"(",
"array",
"$",
"indexColumns",
")",
"{",
"$",
"this",
"->",
"indexColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"indexColumnSizes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"indexColumns",
"as",
"$",
"col",
")",
"{",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"col",
")",
";",
"}",
"}"
] | Sets array of columns to use for index.
@param array $indexColumns Column[] | [
"Sets",
"array",
"of",
"columns",
"to",
"use",
"for",
"index",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Index.php#L197-L204 |
propelorm/Propel | generator/lib/model/Index.php | Index.getColumnSize | public function getColumnSize($name)
{
if (isset($this->indexColumnSizes[$name])) {
return $this->indexColumnSizes[$name];
}
return null; // just to be explicit
} | php | public function getColumnSize($name)
{
if (isset($this->indexColumnSizes[$name])) {
return $this->indexColumnSizes[$name];
}
return null; // just to be explicit
} | [
"public",
"function",
"getColumnSize",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"indexColumnSizes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"indexColumnSizes",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"// just to be explicit",
"}"
] | Returns the size for the specified column, if given.
@param string $name
@return numeric The size or NULL | [
"Returns",
"the",
"size",
"for",
"the",
"specified",
"column",
"if",
"given",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Index.php#L225-L232 |
propelorm/Propel | generator/lib/model/Index.php | Index.hasColumnAtPosition | public function hasColumnAtPosition($pos, $name, $size = null, $caseInsensitive = false)
{
if (!isset($this->indexColumns[$pos])) {
return false;
}
$test = $caseInsensitive ?
strtolower($this->indexColumns[$pos]) != strtolower($name) :
$this->indexColumns[$pos] != $name;
if ($test) {
return false;
}
if (null !== $size && $this->indexColumnSizes[$name] != $size) {
return false;
}
return true;
} | php | public function hasColumnAtPosition($pos, $name, $size = null, $caseInsensitive = false)
{
if (!isset($this->indexColumns[$pos])) {
return false;
}
$test = $caseInsensitive ?
strtolower($this->indexColumns[$pos]) != strtolower($name) :
$this->indexColumns[$pos] != $name;
if ($test) {
return false;
}
if (null !== $size && $this->indexColumnSizes[$name] != $size) {
return false;
}
return true;
} | [
"public",
"function",
"hasColumnAtPosition",
"(",
"$",
"pos",
",",
"$",
"name",
",",
"$",
"size",
"=",
"null",
",",
"$",
"caseInsensitive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"indexColumns",
"[",
"$",
"pos",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"test",
"=",
"$",
"caseInsensitive",
"?",
"strtolower",
"(",
"$",
"this",
"->",
"indexColumns",
"[",
"$",
"pos",
"]",
")",
"!=",
"strtolower",
"(",
"$",
"name",
")",
":",
"$",
"this",
"->",
"indexColumns",
"[",
"$",
"pos",
"]",
"!=",
"$",
"name",
";",
"if",
"(",
"$",
"test",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"size",
"&&",
"$",
"this",
"->",
"indexColumnSizes",
"[",
"$",
"name",
"]",
"!=",
"$",
"size",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check whether this index has a given column at a given position
@param integer $pos Position in the column list
@param string $name Column name
@param integer $size optional size check
@param boolean $caseInsensitive Whether the comparison is case insensitive.
False by default.
@return boolean | [
"Check",
"whether",
"this",
"index",
"has",
"a",
"given",
"column",
"at",
"a",
"given",
"position"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Index.php#L281-L297 |
propelorm/Propel | runtime/lib/validator/MaxLengthValidator.php | MaxLengthValidator.isValid | public function isValid(ValidatorMap $map, $str)
{
$len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str);
return $len <= intval($map->getValue());
} | php | public function isValid(ValidatorMap $map, $str)
{
$len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str);
return $len <= intval($map->getValue());
} | [
"public",
"function",
"isValid",
"(",
"ValidatorMap",
"$",
"map",
",",
"$",
"str",
")",
"{",
"$",
"len",
"=",
"function_exists",
"(",
"'mb_strlen'",
")",
"?",
"mb_strlen",
"(",
"$",
"str",
")",
":",
"strlen",
"(",
"$",
"str",
")",
";",
"return",
"$",
"len",
"<=",
"intval",
"(",
"$",
"map",
"->",
"getValue",
"(",
")",
")",
";",
"}"
] | @param ValidatorMap $map
@param string $str
@return boolean | [
"@param",
"ValidatorMap",
"$map",
"@param",
"string",
"$str"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/validator/MaxLengthValidator.php#L40-L45 |
propelorm/Propel | generator/lib/model/Column.php | Column.makeList | public static function makeList($columns, PropelPlatformInterface $platform)
{
$list = array();
foreach ($columns as $col) {
if ($col instanceof Column) {
$col = $col->getName();
}
$list[] = $platform->quoteIdentifier($col);
}
return implode(", ", $list);
} | php | public static function makeList($columns, PropelPlatformInterface $platform)
{
$list = array();
foreach ($columns as $col) {
if ($col instanceof Column) {
$col = $col->getName();
}
$list[] = $platform->quoteIdentifier($col);
}
return implode(", ", $list);
} | [
"public",
"static",
"function",
"makeList",
"(",
"$",
"columns",
",",
"PropelPlatformInterface",
"$",
"platform",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"instanceof",
"Column",
")",
"{",
"$",
"col",
"=",
"$",
"col",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"list",
"[",
"]",
"=",
"$",
"platform",
"->",
"quoteIdentifier",
"(",
"$",
"col",
")",
";",
"}",
"return",
"implode",
"(",
"\", \"",
",",
"$",
"list",
")",
";",
"}"
] | Return a comma delimited string listing the specified columns.
@param Column[]|string[] $columns Either a list of <code>Column</code> objects, or a list of <code>string</code> with column names.
@deprecated Use the Platform::getColumnListDDL() method instead
@return string | [
"Return",
"a",
"comma",
"delimited",
"string",
"listing",
"the",
"specified",
"columns",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L125-L136 |
propelorm/Propel | generator/lib/model/Column.php | Column.setupObject | protected function setupObject()
{
try {
$dom = $this->getAttribute("domain");
if ($dom) {
$this->getDomain()->copy($this->getTable()->getDatabase()->getDomain($dom));
} else {
$type = strtoupper($this->getAttribute("type"));
if ($type) {
if ($platform = $this->getPlatform()) {
$this->getDomain()->copy($this->getPlatform()->getDomainForType($type));
} else {
// no platform - probably during tests
$this->setDomain(new Domain($type));
}
} else {
if ($platform = $this->getPlatform()) {
$this->getDomain()->copy($this->getPlatform()->getDomainForType(self::DEFAULT_TYPE));
} else {
// no platform - probably during tests
$this->setDomain(new Domain(self::DEFAULT_TYPE));
}
}
}
$this->name = $this->getAttribute("name");
$this->phpName = $this->getAttribute("phpName");
$this->phpType = $this->getAttribute("phpType");
if ($this->getAttribute("prefix", null) !== null) {
$this->namePrefix = $this->getAttribute("prefix");
} elseif ($this->getTable()->getAttribute('columnPrefix', null) !== null) {
$this->namePrefix = $this->getTable()->getAttribute('columnPrefix');
} else {
$this->namePrefix = '';
}
// Accessor visibility
if ($this->getAttribute('accessorVisibility', null) !== null) {
$this->setAccessorVisibility($this->getAttribute('accessorVisibility'));
} elseif ($this->getTable()->getAttribute('defaultAccessorVisibility', null) !== null) {
$this->setAccessorVisibility($this->getTable()->getAttribute('defaultAccessorVisibility'));
} elseif ($this->getTable()->getDatabase()->getAttribute('defaultAccessorVisibility', null) !== null) {
$this->setAccessorVisibility($this->getTable()->getDatabase()->getAttribute('defaultAccessorVisibility'));
} else {
$this->setAccessorVisibility(self::DEFAULT_VISIBILITY);
}
// Mutator visibility
if ($this->getAttribute('mutatorVisibility', null) !== null) {
$this->setMutatorVisibility($this->getAttribute('mutatorVisibility'));
} elseif ($this->getTable()->getAttribute('defaultMutatorVisibility', null) !== null) {
$this->setMutatorVisibility($this->getTable()->getAttribute('defaultMutatorVisibility'));
} elseif ($this->getTable()->getDatabase()->getAttribute('defaultMutatorVisibility', null) !== null) {
$this->setMutatorVisibility($this->getTable()->getDatabase()->getAttribute('defaultMutatorVisibility'));
} else {
$this->setMutatorVisibility(self::DEFAULT_VISIBILITY);
}
$this->peerName = $this->getAttribute("peerName");
// retrieves the method for converting from specified name to a PHP name, defaulting to parent tables default method
$this->phpNamingMethod = $this->getAttribute("phpNamingMethod", $this->parentTable->getDatabase()->getDefaultPhpNamingMethod());
$this->isPrimaryString = $this->booleanValue($this->getAttribute("primaryString"));
$this->isPrimaryKey = $this->booleanValue($this->getAttribute("primaryKey"));
$this->isNodeKey = $this->booleanValue($this->getAttribute("nodeKey"));
$this->nodeKeySep = $this->getAttribute("nodeKeySep", ".");
$this->isNestedSetLeftKey = $this->booleanValue($this->getAttribute("nestedSetLeftKey"));
$this->isNestedSetRightKey = $this->booleanValue($this->getAttribute("nestedSetRightKey"));
$this->isTreeScopeKey = $this->booleanValue($this->getAttribute("treeScopeKey"));
$this->isNotNull = ($this->booleanValue($this->getAttribute("required")) || $this->isPrimaryKey); // primary keys are required
//AutoIncrement/Sequences
$this->isAutoIncrement = $this->booleanValue($this->getAttribute("autoIncrement"));
$this->isLazyLoad = $this->booleanValue($this->getAttribute("lazyLoad"));
// Add type, size information to associated Domain object
$this->getDomain()->replaceSqlType($this->getAttribute("sqlType"));
if (!$this->getAttribute("size") && $this->getDomain()->getType() == 'VARCHAR' && $this->hasPlatform() && !$this->getAttribute("sqlType") && !$this->getPlatform()->supportsVarcharWithoutSize()) {
$size = 255;
} else {
$size = $this->getAttribute("size");
}
$this->getDomain()->replaceSize($size);
$this->getDomain()->replaceScale($this->getAttribute("scale"));
$defval = $this->getAttribute("defaultValue", $this->getAttribute("default"));
if ($defval !== null && strtolower($defval) !== 'null') {
$this->getDomain()->setDefaultValue(new ColumnDefaultValue($defval, ColumnDefaultValue::TYPE_VALUE));
} elseif ($this->getAttribute("defaultExpr") !== null) {
$this->getDomain()->setDefaultValue(new ColumnDefaultValue($this->getAttribute("defaultExpr"), ColumnDefaultValue::TYPE_EXPR));
}
if ($this->getAttribute('valueSet', null) !== null) {
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$valueSet = str_getcsv($this->getAttribute("valueSet"));
} else {
// unfortunately, no good fallback for PHP 5.2
$valueSet = explode(',', $this->getAttribute("valueSet"));
}
$valueSet = array_map('trim', $valueSet);
$this->valueSet = $valueSet;
} elseif (preg_match('/enum\((.*?)\)/i', $this->getAttribute('sqlType', ''), $matches)) {
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$valueSet = str_getcsv($matches['1'], ',', '\'');
} else {
// unfortunately, no good fallback for PHP 5.2
$valueSet = array();
foreach (explode(',', $matches['1']) as $value) {
$valueSet[] = trim($value, " '");
}
}
$this->valueSet = $valueSet;
}
$this->inheritanceType = $this->getAttribute("inheritance");
// here we are only checking for 'false', so don't use booleanValue()
$this->isInheritance = ($this->inheritanceType !== null && $this->inheritanceType !== "false");
$this->description = $this->getAttribute("description");
} catch (Exception $e) {
throw new EngineException("Error setting up column " . var_export($this->getAttribute("name"), true) . ": " . $e->getMessage());
}
} | php | protected function setupObject()
{
try {
$dom = $this->getAttribute("domain");
if ($dom) {
$this->getDomain()->copy($this->getTable()->getDatabase()->getDomain($dom));
} else {
$type = strtoupper($this->getAttribute("type"));
if ($type) {
if ($platform = $this->getPlatform()) {
$this->getDomain()->copy($this->getPlatform()->getDomainForType($type));
} else {
// no platform - probably during tests
$this->setDomain(new Domain($type));
}
} else {
if ($platform = $this->getPlatform()) {
$this->getDomain()->copy($this->getPlatform()->getDomainForType(self::DEFAULT_TYPE));
} else {
// no platform - probably during tests
$this->setDomain(new Domain(self::DEFAULT_TYPE));
}
}
}
$this->name = $this->getAttribute("name");
$this->phpName = $this->getAttribute("phpName");
$this->phpType = $this->getAttribute("phpType");
if ($this->getAttribute("prefix", null) !== null) {
$this->namePrefix = $this->getAttribute("prefix");
} elseif ($this->getTable()->getAttribute('columnPrefix', null) !== null) {
$this->namePrefix = $this->getTable()->getAttribute('columnPrefix');
} else {
$this->namePrefix = '';
}
// Accessor visibility
if ($this->getAttribute('accessorVisibility', null) !== null) {
$this->setAccessorVisibility($this->getAttribute('accessorVisibility'));
} elseif ($this->getTable()->getAttribute('defaultAccessorVisibility', null) !== null) {
$this->setAccessorVisibility($this->getTable()->getAttribute('defaultAccessorVisibility'));
} elseif ($this->getTable()->getDatabase()->getAttribute('defaultAccessorVisibility', null) !== null) {
$this->setAccessorVisibility($this->getTable()->getDatabase()->getAttribute('defaultAccessorVisibility'));
} else {
$this->setAccessorVisibility(self::DEFAULT_VISIBILITY);
}
// Mutator visibility
if ($this->getAttribute('mutatorVisibility', null) !== null) {
$this->setMutatorVisibility($this->getAttribute('mutatorVisibility'));
} elseif ($this->getTable()->getAttribute('defaultMutatorVisibility', null) !== null) {
$this->setMutatorVisibility($this->getTable()->getAttribute('defaultMutatorVisibility'));
} elseif ($this->getTable()->getDatabase()->getAttribute('defaultMutatorVisibility', null) !== null) {
$this->setMutatorVisibility($this->getTable()->getDatabase()->getAttribute('defaultMutatorVisibility'));
} else {
$this->setMutatorVisibility(self::DEFAULT_VISIBILITY);
}
$this->peerName = $this->getAttribute("peerName");
// retrieves the method for converting from specified name to a PHP name, defaulting to parent tables default method
$this->phpNamingMethod = $this->getAttribute("phpNamingMethod", $this->parentTable->getDatabase()->getDefaultPhpNamingMethod());
$this->isPrimaryString = $this->booleanValue($this->getAttribute("primaryString"));
$this->isPrimaryKey = $this->booleanValue($this->getAttribute("primaryKey"));
$this->isNodeKey = $this->booleanValue($this->getAttribute("nodeKey"));
$this->nodeKeySep = $this->getAttribute("nodeKeySep", ".");
$this->isNestedSetLeftKey = $this->booleanValue($this->getAttribute("nestedSetLeftKey"));
$this->isNestedSetRightKey = $this->booleanValue($this->getAttribute("nestedSetRightKey"));
$this->isTreeScopeKey = $this->booleanValue($this->getAttribute("treeScopeKey"));
$this->isNotNull = ($this->booleanValue($this->getAttribute("required")) || $this->isPrimaryKey); // primary keys are required
//AutoIncrement/Sequences
$this->isAutoIncrement = $this->booleanValue($this->getAttribute("autoIncrement"));
$this->isLazyLoad = $this->booleanValue($this->getAttribute("lazyLoad"));
// Add type, size information to associated Domain object
$this->getDomain()->replaceSqlType($this->getAttribute("sqlType"));
if (!$this->getAttribute("size") && $this->getDomain()->getType() == 'VARCHAR' && $this->hasPlatform() && !$this->getAttribute("sqlType") && !$this->getPlatform()->supportsVarcharWithoutSize()) {
$size = 255;
} else {
$size = $this->getAttribute("size");
}
$this->getDomain()->replaceSize($size);
$this->getDomain()->replaceScale($this->getAttribute("scale"));
$defval = $this->getAttribute("defaultValue", $this->getAttribute("default"));
if ($defval !== null && strtolower($defval) !== 'null') {
$this->getDomain()->setDefaultValue(new ColumnDefaultValue($defval, ColumnDefaultValue::TYPE_VALUE));
} elseif ($this->getAttribute("defaultExpr") !== null) {
$this->getDomain()->setDefaultValue(new ColumnDefaultValue($this->getAttribute("defaultExpr"), ColumnDefaultValue::TYPE_EXPR));
}
if ($this->getAttribute('valueSet', null) !== null) {
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$valueSet = str_getcsv($this->getAttribute("valueSet"));
} else {
// unfortunately, no good fallback for PHP 5.2
$valueSet = explode(',', $this->getAttribute("valueSet"));
}
$valueSet = array_map('trim', $valueSet);
$this->valueSet = $valueSet;
} elseif (preg_match('/enum\((.*?)\)/i', $this->getAttribute('sqlType', ''), $matches)) {
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$valueSet = str_getcsv($matches['1'], ',', '\'');
} else {
// unfortunately, no good fallback for PHP 5.2
$valueSet = array();
foreach (explode(',', $matches['1']) as $value) {
$valueSet[] = trim($value, " '");
}
}
$this->valueSet = $valueSet;
}
$this->inheritanceType = $this->getAttribute("inheritance");
// here we are only checking for 'false', so don't use booleanValue()
$this->isInheritance = ($this->inheritanceType !== null && $this->inheritanceType !== "false");
$this->description = $this->getAttribute("description");
} catch (Exception $e) {
throw new EngineException("Error setting up column " . var_export($this->getAttribute("name"), true) . ": " . $e->getMessage());
}
} | [
"protected",
"function",
"setupObject",
"(",
")",
"{",
"try",
"{",
"$",
"dom",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"domain\"",
")",
";",
"if",
"(",
"$",
"dom",
")",
"{",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"copy",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getDomain",
"(",
"$",
"dom",
")",
")",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"type\"",
")",
")",
";",
"if",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"platform",
"=",
"$",
"this",
"->",
"getPlatform",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"copy",
"(",
"$",
"this",
"->",
"getPlatform",
"(",
")",
"->",
"getDomainForType",
"(",
"$",
"type",
")",
")",
";",
"}",
"else",
"{",
"// no platform - probably during tests",
"$",
"this",
"->",
"setDomain",
"(",
"new",
"Domain",
"(",
"$",
"type",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"platform",
"=",
"$",
"this",
"->",
"getPlatform",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"copy",
"(",
"$",
"this",
"->",
"getPlatform",
"(",
")",
"->",
"getDomainForType",
"(",
"self",
"::",
"DEFAULT_TYPE",
")",
")",
";",
"}",
"else",
"{",
"// no platform - probably during tests",
"$",
"this",
"->",
"setDomain",
"(",
"new",
"Domain",
"(",
"self",
"::",
"DEFAULT_TYPE",
")",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"name",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"name\"",
")",
";",
"$",
"this",
"->",
"phpName",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"phpName\"",
")",
";",
"$",
"this",
"->",
"phpType",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"phpType\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"prefix\"",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"namePrefix",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"prefix\"",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getAttribute",
"(",
"'columnPrefix'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"namePrefix",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getAttribute",
"(",
"'columnPrefix'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"namePrefix",
"=",
"''",
";",
"}",
"// Accessor visibility",
"if",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'accessorVisibility'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setAccessorVisibility",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'accessorVisibility'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultAccessorVisibility'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setAccessorVisibility",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultAccessorVisibility'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultAccessorVisibility'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setAccessorVisibility",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultAccessorVisibility'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setAccessorVisibility",
"(",
"self",
"::",
"DEFAULT_VISIBILITY",
")",
";",
"}",
"// Mutator visibility",
"if",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'mutatorVisibility'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setMutatorVisibility",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'mutatorVisibility'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultMutatorVisibility'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setMutatorVisibility",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultMutatorVisibility'",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultMutatorVisibility'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setMutatorVisibility",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getAttribute",
"(",
"'defaultMutatorVisibility'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setMutatorVisibility",
"(",
"self",
"::",
"DEFAULT_VISIBILITY",
")",
";",
"}",
"$",
"this",
"->",
"peerName",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"peerName\"",
")",
";",
"// retrieves the method for converting from specified name to a PHP name, defaulting to parent tables default method",
"$",
"this",
"->",
"phpNamingMethod",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"phpNamingMethod\"",
",",
"$",
"this",
"->",
"parentTable",
"->",
"getDatabase",
"(",
")",
"->",
"getDefaultPhpNamingMethod",
"(",
")",
")",
";",
"$",
"this",
"->",
"isPrimaryString",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"primaryString\"",
")",
")",
";",
"$",
"this",
"->",
"isPrimaryKey",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"primaryKey\"",
")",
")",
";",
"$",
"this",
"->",
"isNodeKey",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"nodeKey\"",
")",
")",
";",
"$",
"this",
"->",
"nodeKeySep",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"nodeKeySep\"",
",",
"\".\"",
")",
";",
"$",
"this",
"->",
"isNestedSetLeftKey",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"nestedSetLeftKey\"",
")",
")",
";",
"$",
"this",
"->",
"isNestedSetRightKey",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"nestedSetRightKey\"",
")",
")",
";",
"$",
"this",
"->",
"isTreeScopeKey",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"treeScopeKey\"",
")",
")",
";",
"$",
"this",
"->",
"isNotNull",
"=",
"(",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"required\"",
")",
")",
"||",
"$",
"this",
"->",
"isPrimaryKey",
")",
";",
"// primary keys are required",
"//AutoIncrement/Sequences",
"$",
"this",
"->",
"isAutoIncrement",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"autoIncrement\"",
")",
")",
";",
"$",
"this",
"->",
"isLazyLoad",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"lazyLoad\"",
")",
")",
";",
"// Add type, size information to associated Domain object",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"replaceSqlType",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"sqlType\"",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getAttribute",
"(",
"\"size\"",
")",
"&&",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"getType",
"(",
")",
"==",
"'VARCHAR'",
"&&",
"$",
"this",
"->",
"hasPlatform",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getAttribute",
"(",
"\"sqlType\"",
")",
"&&",
"!",
"$",
"this",
"->",
"getPlatform",
"(",
")",
"->",
"supportsVarcharWithoutSize",
"(",
")",
")",
"{",
"$",
"size",
"=",
"255",
";",
"}",
"else",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"size\"",
")",
";",
"}",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"replaceSize",
"(",
"$",
"size",
")",
";",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"replaceScale",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"scale\"",
")",
")",
";",
"$",
"defval",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultValue\"",
",",
"$",
"this",
"->",
"getAttribute",
"(",
"\"default\"",
")",
")",
";",
"if",
"(",
"$",
"defval",
"!==",
"null",
"&&",
"strtolower",
"(",
"$",
"defval",
")",
"!==",
"'null'",
")",
"{",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"setDefaultValue",
"(",
"new",
"ColumnDefaultValue",
"(",
"$",
"defval",
",",
"ColumnDefaultValue",
"::",
"TYPE_VALUE",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultExpr\"",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"setDefaultValue",
"(",
"new",
"ColumnDefaultValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultExpr\"",
")",
",",
"ColumnDefaultValue",
"::",
"TYPE_EXPR",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'valueSet'",
",",
"null",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.3.0'",
",",
"'>='",
")",
")",
"{",
"$",
"valueSet",
"=",
"str_getcsv",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"valueSet\"",
")",
")",
";",
"}",
"else",
"{",
"// unfortunately, no good fallback for PHP 5.2",
"$",
"valueSet",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"getAttribute",
"(",
"\"valueSet\"",
")",
")",
";",
"}",
"$",
"valueSet",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"valueSet",
")",
";",
"$",
"this",
"->",
"valueSet",
"=",
"$",
"valueSet",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/enum\\((.*?)\\)/i'",
",",
"$",
"this",
"->",
"getAttribute",
"(",
"'sqlType'",
",",
"''",
")",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.3.0'",
",",
"'>='",
")",
")",
"{",
"$",
"valueSet",
"=",
"str_getcsv",
"(",
"$",
"matches",
"[",
"'1'",
"]",
",",
"','",
",",
"'\\''",
")",
";",
"}",
"else",
"{",
"// unfortunately, no good fallback for PHP 5.2",
"$",
"valueSet",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"matches",
"[",
"'1'",
"]",
")",
"as",
"$",
"value",
")",
"{",
"$",
"valueSet",
"[",
"]",
"=",
"trim",
"(",
"$",
"value",
",",
"\" '\"",
")",
";",
"}",
"}",
"$",
"this",
"->",
"valueSet",
"=",
"$",
"valueSet",
";",
"}",
"$",
"this",
"->",
"inheritanceType",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"inheritance\"",
")",
";",
"// here we are only checking for 'false', so don't use booleanValue()",
"$",
"this",
"->",
"isInheritance",
"=",
"(",
"$",
"this",
"->",
"inheritanceType",
"!==",
"null",
"&&",
"$",
"this",
"->",
"inheritanceType",
"!==",
"\"false\"",
")",
";",
"$",
"this",
"->",
"description",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"description\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"EngineException",
"(",
"\"Error setting up column \"",
".",
"var_export",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"name\"",
")",
",",
"true",
")",
".",
"\": \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Sets up the Column object based on the attributes that were passed to loadFromXML().
@see parent::loadFromXML() | [
"Sets",
"up",
"the",
"Column",
"object",
"based",
"on",
"the",
"attributes",
"that",
"were",
"passed",
"to",
"loadFromXML",
"()",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L143-L271 |
propelorm/Propel | generator/lib/model/Column.php | Column.getStudlyPhpName | public function getStudlyPhpName()
{
$phpname = $this->getPhpName();
if (strlen($phpname) > 1) {
return strtolower(substr($phpname, 0, 1)) . substr($phpname, 1);
} else { // 0 or 1 chars (I suppose that's rare)
return strtolower($phpname);
}
} | php | public function getStudlyPhpName()
{
$phpname = $this->getPhpName();
if (strlen($phpname) > 1) {
return strtolower(substr($phpname, 0, 1)) . substr($phpname, 1);
} else { // 0 or 1 chars (I suppose that's rare)
return strtolower($phpname);
}
} | [
"public",
"function",
"getStudlyPhpName",
"(",
")",
"{",
"$",
"phpname",
"=",
"$",
"this",
"->",
"getPhpName",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"phpname",
")",
">",
"1",
")",
"{",
"return",
"strtolower",
"(",
"substr",
"(",
"$",
"phpname",
",",
"0",
",",
"1",
")",
")",
".",
"substr",
"(",
"$",
"phpname",
",",
"1",
")",
";",
"}",
"else",
"{",
"// 0 or 1 chars (I suppose that's rare)",
"return",
"strtolower",
"(",
"$",
"phpname",
")",
";",
"}",
"}"
] | Get studly version of PHP name.
The studly name is the PHP name with the first character lowercase.
@return string | [
"Get",
"studly",
"version",
"of",
"PHP",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L395-L404 |
propelorm/Propel | generator/lib/model/Column.php | Column.setAccessorVisibility | public function setAccessorVisibility($newVisibility)
{
if (in_array($newVisibility, self::$valid_visibilities)) {
$this->accessorVisibility = $newVisibility;
} else {
$this->accessorVisibility = self::DEFAULT_VISIBILITY;
}
} | php | public function setAccessorVisibility($newVisibility)
{
if (in_array($newVisibility, self::$valid_visibilities)) {
$this->accessorVisibility = $newVisibility;
} else {
$this->accessorVisibility = self::DEFAULT_VISIBILITY;
}
} | [
"public",
"function",
"setAccessorVisibility",
"(",
"$",
"newVisibility",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"newVisibility",
",",
"self",
"::",
"$",
"valid_visibilities",
")",
")",
"{",
"$",
"this",
"->",
"accessorVisibility",
"=",
"$",
"newVisibility",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"accessorVisibility",
"=",
"self",
"::",
"DEFAULT_VISIBILITY",
";",
"}",
"}"
] | Set the visibility of the accessor methods for this column / attribute
@param $newVisibility string | [
"Set",
"the",
"visibility",
"of",
"the",
"accessor",
"methods",
"for",
"this",
"column",
"/",
"attribute"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L425-L432 |
propelorm/Propel | generator/lib/model/Column.php | Column.setMutatorVisibility | public function setMutatorVisibility($newVisibility)
{
if (in_array($newVisibility, self::$valid_visibilities)) {
$this->mutatorVisibility = $newVisibility;
} else {
$this->mutatorVisibility = self::DEFAULT_VISIBILITY;
}
} | php | public function setMutatorVisibility($newVisibility)
{
if (in_array($newVisibility, self::$valid_visibilities)) {
$this->mutatorVisibility = $newVisibility;
} else {
$this->mutatorVisibility = self::DEFAULT_VISIBILITY;
}
} | [
"public",
"function",
"setMutatorVisibility",
"(",
"$",
"newVisibility",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"newVisibility",
",",
"self",
"::",
"$",
"valid_visibilities",
")",
")",
"{",
"$",
"this",
"->",
"mutatorVisibility",
"=",
"$",
"newVisibility",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"mutatorVisibility",
"=",
"self",
"::",
"DEFAULT_VISIBILITY",
";",
"}",
"}"
] | Set the visibility of the mutator methods for this column / attribute
@param $newVisibility string | [
"Set",
"the",
"visibility",
"of",
"the",
"mutator",
"methods",
"for",
"this",
"column",
"/",
"attribute"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L453-L460 |
propelorm/Propel | generator/lib/model/Column.php | Column.addInheritance | public function addInheritance($inhdata)
{
if ($inhdata instanceof Inheritance) {
$inh = $inhdata;
$inh->setColumn($this);
if ($this->inheritanceList === null) {
$this->inheritanceList = array();
$this->isEnumeratedClasses = true;
}
$this->inheritanceList[] = $inh;
return $inh;
} else {
$inh = new Inheritance();
$inh->loadFromXML($inhdata);
return $this->addInheritance($inh);
}
} | php | public function addInheritance($inhdata)
{
if ($inhdata instanceof Inheritance) {
$inh = $inhdata;
$inh->setColumn($this);
if ($this->inheritanceList === null) {
$this->inheritanceList = array();
$this->isEnumeratedClasses = true;
}
$this->inheritanceList[] = $inh;
return $inh;
} else {
$inh = new Inheritance();
$inh->loadFromXML($inhdata);
return $this->addInheritance($inh);
}
} | [
"public",
"function",
"addInheritance",
"(",
"$",
"inhdata",
")",
"{",
"if",
"(",
"$",
"inhdata",
"instanceof",
"Inheritance",
")",
"{",
"$",
"inh",
"=",
"$",
"inhdata",
";",
"$",
"inh",
"->",
"setColumn",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"this",
"->",
"inheritanceList",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"inheritanceList",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"isEnumeratedClasses",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"inheritanceList",
"[",
"]",
"=",
"$",
"inh",
";",
"return",
"$",
"inh",
";",
"}",
"else",
"{",
"$",
"inh",
"=",
"new",
"Inheritance",
"(",
")",
";",
"$",
"inh",
"->",
"loadFromXML",
"(",
"$",
"inhdata",
")",
";",
"return",
"$",
"this",
"->",
"addInheritance",
"(",
"$",
"inh",
")",
";",
"}",
"}"
] | Adds a new inheritance definition to the inheritance list and set the
parent column of the inheritance to the current column
@param Inheritance|string $inhdata Inheritance or XML data.
@return Inheritance | [
"Adds",
"a",
"new",
"inheritance",
"definition",
"to",
"the",
"inheritance",
"list",
"and",
"set",
"the",
"parent",
"column",
"of",
"the",
"inheritance",
"to",
"the",
"current",
"column"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L574-L592 |
propelorm/Propel | generator/lib/model/Column.php | Column.addReferrer | public function addReferrer(ForeignKey $fk)
{
if ($this->referrers === null) {
$this->referrers = array();
}
$this->referrers[] = $fk;
} | php | public function addReferrer(ForeignKey $fk)
{
if ($this->referrers === null) {
$this->referrers = array();
}
$this->referrers[] = $fk;
} | [
"public",
"function",
"addReferrer",
"(",
"ForeignKey",
"$",
"fk",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"referrers",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"referrers",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"referrers",
"[",
"]",
"=",
"$",
"fk",
";",
"}"
] | Adds the foreign key from another table that refers to this column. | [
"Adds",
"the",
"foreign",
"key",
"from",
"another",
"table",
"that",
"refers",
"to",
"this",
"column",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L828-L834 |
propelorm/Propel | generator/lib/model/Column.php | Column.setType | public function setType($propelType)
{
$this->getDomain()->setType($propelType);
if ($propelType == PropelTypes::VARBINARY || $propelType == PropelTypes::LONGVARBINARY || $propelType == PropelTypes::BLOB) {
$this->needsTransactionInPostgres = true;
}
} | php | public function setType($propelType)
{
$this->getDomain()->setType($propelType);
if ($propelType == PropelTypes::VARBINARY || $propelType == PropelTypes::LONGVARBINARY || $propelType == PropelTypes::BLOB) {
$this->needsTransactionInPostgres = true;
}
} | [
"public",
"function",
"setType",
"(",
"$",
"propelType",
")",
"{",
"$",
"this",
"->",
"getDomain",
"(",
")",
"->",
"setType",
"(",
"$",
"propelType",
")",
";",
"if",
"(",
"$",
"propelType",
"==",
"PropelTypes",
"::",
"VARBINARY",
"||",
"$",
"propelType",
"==",
"PropelTypes",
"::",
"LONGVARBINARY",
"||",
"$",
"propelType",
"==",
"PropelTypes",
"::",
"BLOB",
")",
"{",
"$",
"this",
"->",
"needsTransactionInPostgres",
"=",
"true",
";",
"}",
"}"
] | Sets the propel colunm type.
@param string $propelType
@see Domain::setType() | [
"Sets",
"the",
"propel",
"colunm",
"type",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L888-L894 |
propelorm/Propel | generator/lib/model/Column.php | Column.setDefaultValue | public function setDefaultValue($def)
{
if (!$def instanceof ColumnDefaultValue) {
$def = new ColumnDefaultValue($def, ColumnDefaultValue::TYPE_VALUE);
}
$this->domain->setDefaultValue($def);
return $this;
} | php | public function setDefaultValue($def)
{
if (!$def instanceof ColumnDefaultValue) {
$def = new ColumnDefaultValue($def, ColumnDefaultValue::TYPE_VALUE);
}
$this->domain->setDefaultValue($def);
return $this;
} | [
"public",
"function",
"setDefaultValue",
"(",
"$",
"def",
")",
"{",
"if",
"(",
"!",
"$",
"def",
"instanceof",
"ColumnDefaultValue",
")",
"{",
"$",
"def",
"=",
"new",
"ColumnDefaultValue",
"(",
"$",
"def",
",",
"ColumnDefaultValue",
"::",
"TYPE_VALUE",
")",
";",
"}",
"$",
"this",
"->",
"domain",
"->",
"setDefaultValue",
"(",
"$",
"def",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set a string that will give this column a default value.
@param ColumnDefaultValue|int|float|bool|string column default value
@return Column | [
"Set",
"a",
"string",
"that",
"will",
"give",
"this",
"column",
"a",
"default",
"value",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L1194-L1202 |
propelorm/Propel | generator/lib/model/Column.php | Column.getAutoIncrementString | public function getAutoIncrementString()
{
if ($this->isAutoIncrement() && IDMethod::NATIVE === $this->getTable()->getIdMethod()) {
return $this->getPlatform()->getAutoIncrement();
} elseif ($this->isAutoIncrement()) {
throw new EngineException(sprintf(
'You have specified autoIncrement for column "%s", but you have not specified idMethod="native" for table "%s".',
$this->name,
$this->getTable()->getName()
));
}
return '';
} | php | public function getAutoIncrementString()
{
if ($this->isAutoIncrement() && IDMethod::NATIVE === $this->getTable()->getIdMethod()) {
return $this->getPlatform()->getAutoIncrement();
} elseif ($this->isAutoIncrement()) {
throw new EngineException(sprintf(
'You have specified autoIncrement for column "%s", but you have not specified idMethod="native" for table "%s".',
$this->name,
$this->getTable()->getName()
));
}
return '';
} | [
"public",
"function",
"getAutoIncrementString",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAutoIncrement",
"(",
")",
"&&",
"IDMethod",
"::",
"NATIVE",
"===",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getIdMethod",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getPlatform",
"(",
")",
"->",
"getAutoIncrement",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isAutoIncrement",
"(",
")",
")",
"{",
"throw",
"new",
"EngineException",
"(",
"sprintf",
"(",
"'You have specified autoIncrement for column \"%s\", but you have not specified idMethod=\"native\" for table \"%s\".'",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Gets the auto-increment string.
@return string
@throws EngineException | [
"Gets",
"the",
"auto",
"-",
"increment",
"string",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L1250-L1263 |
propelorm/Propel | generator/lib/model/Column.php | Column.setTypeFromString | public function setTypeFromString($typeName, $size)
{
$tn = strtoupper($typeName);
$this->setType($tn);
if ($size !== null) {
$this->size = $size;
}
if (strpos($tn, "CHAR") !== false) {
$this->domain->setType(PropelTypes::VARCHAR);
} elseif (strpos($tn, "INT") !== false) {
$this->domain->setType(PropelTypes::INTEGER);
} elseif (strpos($tn, "FLOAT") !== false) {
$this->domain->setType(PropelTypes::FLOAT);
} elseif (strpos($tn, "DATE") !== false) {
$this->domain->setType(PropelTypes::DATE);
} elseif (strpos($tn, "TIME") !== false) {
$this->domain->setType(PropelTypes::TIMESTAMP);
} elseif (strpos($tn, "BINARY") !== false) {
$this->domain->setType(PropelTypes::LONGVARBINARY);
} else {
$this->domain->setType(PropelTypes::VARCHAR);
}
} | php | public function setTypeFromString($typeName, $size)
{
$tn = strtoupper($typeName);
$this->setType($tn);
if ($size !== null) {
$this->size = $size;
}
if (strpos($tn, "CHAR") !== false) {
$this->domain->setType(PropelTypes::VARCHAR);
} elseif (strpos($tn, "INT") !== false) {
$this->domain->setType(PropelTypes::INTEGER);
} elseif (strpos($tn, "FLOAT") !== false) {
$this->domain->setType(PropelTypes::FLOAT);
} elseif (strpos($tn, "DATE") !== false) {
$this->domain->setType(PropelTypes::DATE);
} elseif (strpos($tn, "TIME") !== false) {
$this->domain->setType(PropelTypes::TIMESTAMP);
} elseif (strpos($tn, "BINARY") !== false) {
$this->domain->setType(PropelTypes::LONGVARBINARY);
} else {
$this->domain->setType(PropelTypes::VARCHAR);
}
} | [
"public",
"function",
"setTypeFromString",
"(",
"$",
"typeName",
",",
"$",
"size",
")",
"{",
"$",
"tn",
"=",
"strtoupper",
"(",
"$",
"typeName",
")",
";",
"$",
"this",
"->",
"setType",
"(",
"$",
"tn",
")",
";",
"if",
"(",
"$",
"size",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"size",
"=",
"$",
"size",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"tn",
",",
"\"CHAR\"",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"VARCHAR",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"tn",
",",
"\"INT\"",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"INTEGER",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"tn",
",",
"\"FLOAT\"",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"FLOAT",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"tn",
",",
"\"DATE\"",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"DATE",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"tn",
",",
"\"TIME\"",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"TIMESTAMP",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"tn",
",",
"\"BINARY\"",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"LONGVARBINARY",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"domain",
"->",
"setType",
"(",
"PropelTypes",
"::",
"VARCHAR",
")",
";",
"}",
"}"
] | Set the column type from a string property
(normally a string from an sql input file)
@deprecated Do not use; this will be removed in next release. | [
"Set",
"the",
"column",
"type",
"from",
"a",
"string",
"property",
"(",
"normally",
"a",
"string",
"from",
"an",
"sql",
"input",
"file",
")"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Column.php#L1280-L1304 |
propelorm/Propel | runtime/lib/om/BaseObject.php | BaseObject.resetModified | public function resetModified($col = null)
{
if ($col !== null) {
while (($offset = array_search($col, $this->modifiedColumns)) !== false) {
array_splice($this->modifiedColumns, $offset, 1);
}
} else {
$this->modifiedColumns = array();
}
return $this;
} | php | public function resetModified($col = null)
{
if ($col !== null) {
while (($offset = array_search($col, $this->modifiedColumns)) !== false) {
array_splice($this->modifiedColumns, $offset, 1);
}
} else {
$this->modifiedColumns = array();
}
return $this;
} | [
"public",
"function",
"resetModified",
"(",
"$",
"col",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"col",
"!==",
"null",
")",
"{",
"while",
"(",
"(",
"$",
"offset",
"=",
"array_search",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"modifiedColumns",
")",
")",
"!==",
"false",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"modifiedColumns",
",",
"$",
"offset",
",",
"1",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the modified state for the object to be false.
@param string $col If supplied, only the specified column is reset.
@return self | [
"Sets",
"the",
"modified",
"state",
"for",
"the",
"object",
"to",
"be",
"false",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/om/BaseObject.php#L252-L263 |
propelorm/Propel | runtime/lib/om/BaseObject.php | BaseObject.equals | public function equals($obj)
{
$thisclass = get_class($this);
if (is_object($obj) && $obj instanceof $thisclass) {
if ($this === $obj) {
return true;
} elseif ($this->getPrimaryKey() === null || $obj->getPrimaryKey() === null) {
return false;
} else {
return ($this->getPrimaryKey() === $obj->getPrimaryKey());
}
} else {
return false;
}
} | php | public function equals($obj)
{
$thisclass = get_class($this);
if (is_object($obj) && $obj instanceof $thisclass) {
if ($this === $obj) {
return true;
} elseif ($this->getPrimaryKey() === null || $obj->getPrimaryKey() === null) {
return false;
} else {
return ($this->getPrimaryKey() === $obj->getPrimaryKey());
}
} else {
return false;
}
} | [
"public",
"function",
"equals",
"(",
"$",
"obj",
")",
"{",
"$",
"thisclass",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"obj",
")",
"&&",
"$",
"obj",
"instanceof",
"$",
"thisclass",
")",
"{",
"if",
"(",
"$",
"this",
"===",
"$",
"obj",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"===",
"null",
"||",
"$",
"obj",
"->",
"getPrimaryKey",
"(",
")",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"===",
"$",
"obj",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Compares this with another <code>BaseObject</code> instance. If
<code>obj</code> is an instance of <code>BaseObject</code>, delegates to
<code>equals(BaseObject)</code>. Otherwise, returns <code>false</code>.
@param obj The object to compare to.
@return Whether equal to the object specified. | [
"Compares",
"this",
"with",
"another",
"<code",
">",
"BaseObject<",
"/",
"code",
">",
"instance",
".",
"If",
"<code",
">",
"obj<",
"/",
"code",
">",
"is",
"an",
"instance",
"of",
"<code",
">",
"BaseObject<",
"/",
"code",
">",
"delegates",
"to",
"<code",
">",
"equals",
"(",
"BaseObject",
")",
"<",
"/",
"code",
">",
".",
"Otherwise",
"returns",
"<code",
">",
"false<",
"/",
"code",
">",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/om/BaseObject.php#L274-L288 |
propelorm/Propel | runtime/lib/om/BaseObject.php | BaseObject.hashCode | public function hashCode()
{
if (null !== $this->getPrimaryKey()) {
return crc32(serialize($this->getPrimaryKey()));
}
return crc32(serialize(clone $this));
} | php | public function hashCode()
{
if (null !== $this->getPrimaryKey()) {
return crc32(serialize($this->getPrimaryKey()));
}
return crc32(serialize(clone $this));
} | [
"public",
"function",
"hashCode",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
"{",
"return",
"crc32",
"(",
"serialize",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
")",
";",
"}",
"return",
"crc32",
"(",
"serialize",
"(",
"clone",
"$",
"this",
")",
")",
";",
"}"
] | If the primary key is not null, return the hashcode of the
primary key. Otherwise, return the hash code of the object.
@return int Hashcode | [
"If",
"the",
"primary",
"key",
"is",
"not",
"null",
"return",
"the",
"hashcode",
"of",
"the",
"primary",
"key",
".",
"Otherwise",
"return",
"the",
"hash",
"code",
"of",
"the",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/om/BaseObject.php#L296-L303 |
propelorm/Propel | runtime/lib/om/BaseObject.php | BaseObject.getVirtualColumn | public function getVirtualColumn($name)
{
if (!$this->hasVirtualColumn($name)) {
throw new PropelException('Cannot get value of inexistent virtual column ' . $name);
}
return $this->virtualColumns[$name];
} | php | public function getVirtualColumn($name)
{
if (!$this->hasVirtualColumn($name)) {
throw new PropelException('Cannot get value of inexistent virtual column ' . $name);
}
return $this->virtualColumns[$name];
} | [
"public",
"function",
"getVirtualColumn",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVirtualColumn",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot get value of inexistent virtual column '",
".",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"virtualColumns",
"[",
"$",
"name",
"]",
";",
"}"
] | Get the value of a virtual column in this object
@return mixed
@throws PropelException | [
"Get",
"the",
"value",
"of",
"a",
"virtual",
"column",
"in",
"this",
"object"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/om/BaseObject.php#L334-L341 |
propelorm/Propel | runtime/lib/om/BaseObject.php | BaseObject.log | protected function log($msg, $priority = Propel::LOG_INFO)
{
return Propel::log(get_class($this) . ': ' . $msg, $priority);
} | php | protected function log($msg, $priority = Propel::LOG_INFO)
{
return Propel::log(get_class($this) . ': ' . $msg, $priority);
} | [
"protected",
"function",
"log",
"(",
"$",
"msg",
",",
"$",
"priority",
"=",
"Propel",
"::",
"LOG_INFO",
")",
"{",
"return",
"Propel",
"::",
"log",
"(",
"get_class",
"(",
"$",
"this",
")",
".",
"': '",
".",
"$",
"msg",
",",
"$",
"priority",
")",
";",
"}"
] | Logs a message using Propel::log().
@param string $msg
@param int $priority One of the Propel::LOG_* logging levels
@return boolean | [
"Logs",
"a",
"message",
"using",
"Propel",
"::",
"log",
"()",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/om/BaseObject.php#L366-L369 |
propelorm/Propel | runtime/lib/om/BaseObject.php | BaseObject.exportTo | public function exportTo($parser, $includeLazyLoadColumns = true)
{
if (!$parser instanceof PropelParser) {
$parser = PropelParser::getParser($parser);
}
return $parser->fromArray($this->toArray(BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
} | php | public function exportTo($parser, $includeLazyLoadColumns = true)
{
if (!$parser instanceof PropelParser) {
$parser = PropelParser::getParser($parser);
}
return $parser->fromArray($this->toArray(BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
} | [
"public",
"function",
"exportTo",
"(",
"$",
"parser",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"parser",
"instanceof",
"PropelParser",
")",
"{",
"$",
"parser",
"=",
"PropelParser",
"::",
"getParser",
"(",
"$",
"parser",
")",
";",
"}",
"return",
"$",
"parser",
"->",
"fromArray",
"(",
"$",
"this",
"->",
"toArray",
"(",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
",",
"array",
"(",
")",
",",
"true",
")",
")",
";",
"}"
] | Export the current object properties to a string, using a given parser format
<code>
$book = BookQuery::create()->findPk(9012);
echo $book->exportTo('JSON');
=> {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
</code>
@param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
@return string The exported data | [
"Export",
"the",
"current",
"object",
"properties",
"to",
"a",
"string",
"using",
"a",
"given",
"parser",
"format",
"<code",
">",
"$book",
"=",
"BookQuery",
"::",
"create",
"()",
"-",
">",
"findPk",
"(",
"9012",
")",
";",
"echo",
"$book",
"-",
">",
"exportTo",
"(",
"JSON",
")",
";",
"=",
">",
"{",
"Id",
":",
"9012",
"Title",
":",
"Don",
"Juan",
"ISBN",
":",
"0140422161",
"Price",
":",
"12",
".",
"99",
"PublisherId",
":",
"1234",
"AuthorId",
":",
"5678",
"}",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/om/BaseObject.php#L406-L413 |
propelorm/Propel | runtime/lib/map/RelationMap.php | RelationMap.addColumnMapping | public function addColumnMapping(ColumnMap $local, ColumnMap $foreign)
{
$this->localColumns[] = $local;
$this->foreignColumns[] = $foreign;
} | php | public function addColumnMapping(ColumnMap $local, ColumnMap $foreign)
{
$this->localColumns[] = $local;
$this->foreignColumns[] = $foreign;
} | [
"public",
"function",
"addColumnMapping",
"(",
"ColumnMap",
"$",
"local",
",",
"ColumnMap",
"$",
"foreign",
")",
"{",
"$",
"this",
"->",
"localColumns",
"[",
"]",
"=",
"$",
"local",
";",
"$",
"this",
"->",
"foreignColumns",
"[",
"]",
"=",
"$",
"foreign",
";",
"}"
] | Add a column mapping
@param ColumnMap $local The local column
@param ColumnMap $foreign The foreign column | [
"Add",
"a",
"column",
"mapping"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/RelationMap.php#L174-L178 |
propelorm/Propel | runtime/lib/adapter/DBSQLSRV.php | DBSQLSRV.setCharset | public function setCharset(PDO $con, $charset)
{
switch (strtolower($charset)) {
case 'utf-8':
$con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8);
break;
case 'system':
$con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM);
break;
default:
throw new PropelException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver');
}
} | php | public function setCharset(PDO $con, $charset)
{
switch (strtolower($charset)) {
case 'utf-8':
$con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8);
break;
case 'system':
$con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM);
break;
default:
throw new PropelException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver');
}
} | [
"public",
"function",
"setCharset",
"(",
"PDO",
"$",
"con",
",",
"$",
"charset",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"charset",
")",
")",
"{",
"case",
"'utf-8'",
":",
"$",
"con",
"->",
"setAttribute",
"(",
"PDO",
"::",
"SQLSRV_ATTR_ENCODING",
",",
"PDO",
"::",
"SQLSRV_ENCODING_UTF8",
")",
";",
"break",
";",
"case",
"'system'",
":",
"$",
"con",
"->",
"setAttribute",
"(",
"PDO",
"::",
"SQLSRV_ATTR_ENCODING",
",",
"PDO",
"::",
"SQLSRV_ENCODING_SYSTEM",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"PropelException",
"(",
"'only utf-8 or system encoding are supported by the pdo_sqlsrv driver'",
")",
";",
"}",
"}"
] | @see parent::setCharset()
@param PDO $con
@param string $charset
@throws PropelException | [
"@see",
"parent",
"::",
"setCharset",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBSQLSRV.php#L42-L54 |
propelorm/Propel | runtime/lib/adapter/DBSQLSRV.php | DBSQLSRV.bindValue | public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
{
if ($cMap->isTemporal()) {
$value = $this->formatTemporalValue($value, $cMap);
} elseif (is_resource($value) && $cMap->isLob()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
rewind($value);
// pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY
// driver option can be utilized. This requires a unique blob parameter because the bindParam
// value is passed by reference and if we didn't do this then the referenced parameter value
// would change on the next loop
$blob = "blob" . $position;
$$blob = $value;
return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
}
return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
} | php | public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
{
if ($cMap->isTemporal()) {
$value = $this->formatTemporalValue($value, $cMap);
} elseif (is_resource($value) && $cMap->isLob()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
rewind($value);
// pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY
// driver option can be utilized. This requires a unique blob parameter because the bindParam
// value is passed by reference and if we didn't do this then the referenced parameter value
// would change on the next loop
$blob = "blob" . $position;
$$blob = $value;
return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
}
return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
} | [
"public",
"function",
"bindValue",
"(",
"PDOStatement",
"$",
"stmt",
",",
"$",
"parameter",
",",
"$",
"value",
",",
"ColumnMap",
"$",
"cMap",
",",
"$",
"position",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cMap",
"->",
"isTemporal",
"(",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"formatTemporalValue",
"(",
"$",
"value",
",",
"$",
"cMap",
")",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"value",
")",
"&&",
"$",
"cMap",
"->",
"isLob",
"(",
")",
")",
"{",
"// we always need to make sure that the stream is rewound, otherwise nothing will",
"// get written to database.",
"rewind",
"(",
"$",
"value",
")",
";",
"// pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY",
"// driver option can be utilized. This requires a unique blob parameter because the bindParam",
"// value is passed by reference and if we didn't do this then the referenced parameter value",
"// would change on the next loop",
"$",
"blob",
"=",
"\"blob\"",
".",
"$",
"position",
";",
"$",
"$",
"blob",
"=",
"$",
"value",
";",
"return",
"$",
"stmt",
"->",
"bindParam",
"(",
"$",
"parameter",
",",
"$",
"{",
"$",
"blob",
"}",
",",
"PDO",
"::",
"PARAM_LOB",
",",
"0",
",",
"PDO",
"::",
"SQLSRV_ENCODING_BINARY",
")",
";",
"}",
"return",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"parameter",
",",
"$",
"value",
",",
"$",
"cMap",
"->",
"getPdoType",
"(",
")",
")",
";",
"}"
] | @see DBAdapter::bindValue()
@param PDOStatement $stmt
@param string $parameter
@param mixed $value
@param ColumnMap $cMap
@param null|integer $position
@return boolean | [
"@see",
"DBAdapter",
"::",
"bindValue",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBSQLSRV.php#L95-L114 |
propelorm/Propel | generator/lib/builder/om/QueryInheritanceBuilder.php | QueryInheritanceBuilder.getParentClassName | protected function getParentClassName()
{
$ancestorClassName = ClassTools::classname($this->getChild()->getAncestor());
if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) {
return $this->getNewStubQueryBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))->getClassname();
} else {
// find the inheritance for the parent class
foreach ($this->getTable()->getChildrenColumn()->getChildren() as $child) {
if ($child->getClassName() == $ancestorClassName) {
return $this->getNewStubQueryInheritanceBuilder($child)->getClassname();
}
}
}
} | php | protected function getParentClassName()
{
$ancestorClassName = ClassTools::classname($this->getChild()->getAncestor());
if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) {
return $this->getNewStubQueryBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))->getClassname();
} else {
// find the inheritance for the parent class
foreach ($this->getTable()->getChildrenColumn()->getChildren() as $child) {
if ($child->getClassName() == $ancestorClassName) {
return $this->getNewStubQueryInheritanceBuilder($child)->getClassname();
}
}
}
} | [
"protected",
"function",
"getParentClassName",
"(",
")",
"{",
"$",
"ancestorClassName",
"=",
"ClassTools",
"::",
"classname",
"(",
"$",
"this",
"->",
"getChild",
"(",
")",
"->",
"getAncestor",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"hasTableByPhpName",
"(",
"$",
"ancestorClassName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getNewStubQueryBuilder",
"(",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getTableByPhpName",
"(",
"$",
"ancestorClassName",
")",
")",
"->",
"getClassname",
"(",
")",
";",
"}",
"else",
"{",
"// find the inheritance for the parent class",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getChildrenColumn",
"(",
")",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"getClassName",
"(",
")",
"==",
"$",
"ancestorClassName",
")",
"{",
"return",
"$",
"this",
"->",
"getNewStubQueryInheritanceBuilder",
"(",
"$",
"child",
")",
"->",
"getClassname",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Returns classpath to parent class.
@return string | [
"Returns",
"classpath",
"to",
"parent",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryInheritanceBuilder.php#L93-L106 |
propelorm/Propel | generator/lib/builder/om/QueryInheritanceBuilder.php | QueryInheritanceBuilder.addClassOpen | protected function addClassOpen(&$script)
{
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$baseBuilder = $this->getStubQueryBuilder();
$this->declareClassFromBuilder($baseBuilder);
$baseClassname = $this->getParentClassName();
$script .= "
/**
* Skeleton subclass for representing a query for one of the subclasses of the '$tableName' table.
*
* $tableDesc
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
}
$script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator." . $this->getPackage() . "
*/
class " . $this->getClassname() . " extends " . $baseClassname . " {
";
} | php | protected function addClassOpen(&$script)
{
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$baseBuilder = $this->getStubQueryBuilder();
$this->declareClassFromBuilder($baseBuilder);
$baseClassname = $this->getParentClassName();
$script .= "
/**
* Skeleton subclass for representing a query for one of the subclasses of the '$tableName' table.
*
* $tableDesc
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
}
$script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator." . $this->getPackage() . "
*/
class " . $this->getClassname() . " extends " . $baseClassname . " {
";
} | [
"protected",
"function",
"addClassOpen",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"tableName",
"=",
"$",
"table",
"->",
"getName",
"(",
")",
";",
"$",
"tableDesc",
"=",
"$",
"table",
"->",
"getDescription",
"(",
")",
";",
"$",
"baseBuilder",
"=",
"$",
"this",
"->",
"getStubQueryBuilder",
"(",
")",
";",
"$",
"this",
"->",
"declareClassFromBuilder",
"(",
"$",
"baseBuilder",
")",
";",
"$",
"baseClassname",
"=",
"$",
"this",
"->",
"getParentClassName",
"(",
")",
";",
"$",
"script",
".=",
"\"\n/**\n * Skeleton subclass for representing a query for one of the subclasses of the '$tableName' table.\n *\n * $tableDesc\n *\"",
";",
"if",
"(",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'addTimeStamp'",
")",
")",
"{",
"$",
"now",
"=",
"strftime",
"(",
"'%c'",
")",
";",
"$",
"script",
".=",
"\"\n * This class was autogenerated by Propel \"",
".",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'version'",
")",
".",
"\" on:\n *\n * $now\n *\"",
";",
"}",
"$",
"script",
".=",
"\"\n * You should add additional methods to this class to meet the\n * application requirements. This class will only be generated as\n * long as it does not already exist in the output directory.\n *\n * @package propel.generator.\"",
".",
"$",
"this",
"->",
"getPackage",
"(",
")",
".",
"\"\n */\nclass \"",
".",
"$",
"this",
"->",
"getClassname",
"(",
")",
".",
"\" extends \"",
".",
"$",
"baseClassname",
".",
"\" {\n\"",
";",
"}"
] | Adds class phpdoc comment and opening of class.
@param string &$script The script will be modified in this method. | [
"Adds",
"class",
"phpdoc",
"comment",
"and",
"opening",
"of",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryInheritanceBuilder.php#L127-L160 |
propelorm/Propel | generator/lib/builder/om/QueryInheritanceBuilder.php | QueryInheritanceBuilder.addClassBody | protected function addClassBody(&$script)
{
$this->declareClassFromBuilder($this->getStubPeerBuilder());
$this->declareClasses('PropelPDO', 'Criteria', 'BasePeer', 'PropelException');
$this->addFactory($script);
$this->addPreSelect($script);
$this->addPreUpdate($script);
$this->addPreDelete($script);
$this->addDoDeleteAll($script);
$this->addFindOneOrCreate($script);
} | php | protected function addClassBody(&$script)
{
$this->declareClassFromBuilder($this->getStubPeerBuilder());
$this->declareClasses('PropelPDO', 'Criteria', 'BasePeer', 'PropelException');
$this->addFactory($script);
$this->addPreSelect($script);
$this->addPreUpdate($script);
$this->addPreDelete($script);
$this->addDoDeleteAll($script);
$this->addFindOneOrCreate($script);
} | [
"protected",
"function",
"addClassBody",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"this",
"->",
"declareClassFromBuilder",
"(",
"$",
"this",
"->",
"getStubPeerBuilder",
"(",
")",
")",
";",
"$",
"this",
"->",
"declareClasses",
"(",
"'PropelPDO'",
",",
"'Criteria'",
",",
"'BasePeer'",
",",
"'PropelException'",
")",
";",
"$",
"this",
"->",
"addFactory",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addPreSelect",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addPreUpdate",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addPreDelete",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addDoDeleteAll",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addFindOneOrCreate",
"(",
"$",
"script",
")",
";",
"}"
] | Specifies the methods that are added as part of the stub object class.
By default there are no methods for the empty stub classes; override this method
if you want to change that behavior.
@see ObjectBuilder::addClassBody() | [
"Specifies",
"the",
"methods",
"that",
"are",
"added",
"as",
"part",
"of",
"the",
"stub",
"object",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryInheritanceBuilder.php#L170-L180 |
propelorm/Propel | generator/lib/builder/om/QueryInheritanceBuilder.php | QueryInheritanceBuilder.addFindOneOrCreate | protected function addFindOneOrCreate(&$script)
{
$child = $this->getChild();
$col = $child->getColumn();
$script .= "
/**
* Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria
* and format the result with the current formatter
* By default, returns a model object
*
* @param PropelPDO \$con an optional connection object
*
* @return mixed the result, formatted by the current formatter
*
* @throws PropelException
*/
public function findOneOrCreate(\$con = null)
{
if (\$this->joins) {
throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.');
}
if (!\$ret = \$this->findOne(\$con)) {
\$class = " . $this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . ";
\$obj = new \$class;
foreach (\$this->keys() as \$key) {
\$obj->setByName(\$key, \$this->getValue(\$key), BasePeer::TYPE_COLNAME);
}
\$ret = \$this->getFormatter()->formatRecord(\$obj);
}
return \$ret;
}
";
} | php | protected function addFindOneOrCreate(&$script)
{
$child = $this->getChild();
$col = $child->getColumn();
$script .= "
/**
* Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria
* and format the result with the current formatter
* By default, returns a model object
*
* @param PropelPDO \$con an optional connection object
*
* @return mixed the result, formatted by the current formatter
*
* @throws PropelException
*/
public function findOneOrCreate(\$con = null)
{
if (\$this->joins) {
throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.');
}
if (!\$ret = \$this->findOne(\$con)) {
\$class = " . $this->getPeerClassname() . "::CLASSNAME_" . strtoupper($child->getKey()) . ";
\$obj = new \$class;
foreach (\$this->keys() as \$key) {
\$obj->setByName(\$key, \$this->getValue(\$key), BasePeer::TYPE_COLNAME);
}
\$ret = \$this->getFormatter()->formatRecord(\$obj);
}
return \$ret;
}
";
} | [
"protected",
"function",
"addFindOneOrCreate",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"child",
"=",
"$",
"this",
"->",
"getChild",
"(",
")",
";",
"$",
"col",
"=",
"$",
"child",
"->",
"getColumn",
"(",
")",
";",
"$",
"script",
".=",
"\"\n\n /**\n * Issue a SELECT ... LIMIT 1 query based on the current ModelCriteria\n * and format the result with the current formatter\n * By default, returns a model object\n *\n * @param PropelPDO \\$con an optional connection object\n *\n * @return mixed the result, formatted by the current formatter\n *\n * @throws PropelException\n */\n public function findOneOrCreate(\\$con = null)\n {\n if (\\$this->joins) {\n throw new PropelException('findOneOrCreate() cannot be used on a query with a join, because Propel cannot transform a SQL JOIN into a subquery. You should split the query in two queries to avoid joins.');\n }\n if (!\\$ret = \\$this->findOne(\\$con)) {\n \\$class = \"",
".",
"$",
"this",
"->",
"getPeerClassname",
"(",
")",
".",
"\"::CLASSNAME_\"",
".",
"strtoupper",
"(",
"$",
"child",
"->",
"getKey",
"(",
")",
")",
".",
"\";\n \\$obj = new \\$class;\n foreach (\\$this->keys() as \\$key) {\n \\$obj->setByName(\\$key, \\$this->getValue(\\$key), BasePeer::TYPE_COLNAME);\n }\n \\$ret = \\$this->getFormatter()->formatRecord(\\$obj);\n }\n\n return \\$ret;\n }\n\"",
";",
"}"
] | Adds findOneOrCreate function for this object.
@param unknown $script | [
"Adds",
"findOneOrCreate",
"function",
"for",
"this",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/QueryInheritanceBuilder.php#L314-L348 |
propelorm/Propel | generator/lib/behavior/AlternativeCodingStandardsBehavior.php | AlternativeCodingStandardsBehavior.filter | protected function filter(&$script)
{
$filter = array();
if ($this->getParameter('brackets_newline') == 'true') {
$filter['#^(\t*)\}\h(else|elseif|catch)(.*)\h\{$#m'] = "$1}
$1$2$3
$1{";
$filter['#^(\t*)(\w.*)\h\{$#m'] = "$1$2
$1{";
}
if ($this->getParameter('remove_closing_comments') == 'true') {
$filter['#^(\t*)} //.*$#m'] = "$1}";
}
if ($this->getParameter('use_whitespace') == 'true') {
$filter['#\t#'] = str_repeat(' ', $this->getParameter('tab_size'));
}
$script = preg_replace(array_keys($filter), array_values($filter), $script);
if ($this->getParameter('strip_comments') == 'true') {
$script = self::stripComments($script);
}
} | php | protected function filter(&$script)
{
$filter = array();
if ($this->getParameter('brackets_newline') == 'true') {
$filter['#^(\t*)\}\h(else|elseif|catch)(.*)\h\{$#m'] = "$1}
$1$2$3
$1{";
$filter['#^(\t*)(\w.*)\h\{$#m'] = "$1$2
$1{";
}
if ($this->getParameter('remove_closing_comments') == 'true') {
$filter['#^(\t*)} //.*$#m'] = "$1}";
}
if ($this->getParameter('use_whitespace') == 'true') {
$filter['#\t#'] = str_repeat(' ', $this->getParameter('tab_size'));
}
$script = preg_replace(array_keys($filter), array_values($filter), $script);
if ($this->getParameter('strip_comments') == 'true') {
$script = self::stripComments($script);
}
} | [
"protected",
"function",
"filter",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"filter",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'brackets_newline'",
")",
"==",
"'true'",
")",
"{",
"$",
"filter",
"[",
"'#^(\\t*)\\}\\h(else|elseif|catch)(.*)\\h\\{$#m'",
"]",
"=",
"\"$1}\n$1$2$3\n$1{\"",
";",
"$",
"filter",
"[",
"'#^(\\t*)(\\w.*)\\h\\{$#m'",
"]",
"=",
"\"$1$2\n$1{\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'remove_closing_comments'",
")",
"==",
"'true'",
")",
"{",
"$",
"filter",
"[",
"'#^(\\t*)} //.*$#m'",
"]",
"=",
"\"$1}\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'use_whitespace'",
")",
"==",
"'true'",
")",
"{",
"$",
"filter",
"[",
"'#\\t#'",
"]",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"this",
"->",
"getParameter",
"(",
"'tab_size'",
")",
")",
";",
"}",
"$",
"script",
"=",
"preg_replace",
"(",
"array_keys",
"(",
"$",
"filter",
")",
",",
"array_values",
"(",
"$",
"filter",
")",
",",
"$",
"script",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'strip_comments'",
")",
"==",
"'true'",
")",
"{",
"$",
"script",
"=",
"self",
"::",
"stripComments",
"(",
"$",
"script",
")",
";",
"}",
"}"
] | Transform the coding standards of a PHP sourcecode string
@param string $script A script string to be filtered, passed as reference | [
"Transform",
"the",
"coding",
"standards",
"of",
"a",
"PHP",
"sourcecode",
"string"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/AlternativeCodingStandardsBehavior.php#L90-L112 |
propelorm/Propel | generator/lib/behavior/AlternativeCodingStandardsBehavior.php | AlternativeCodingStandardsBehavior.stripComments | public static function stripComments($code)
{
$output = '';
$commentTokens = array(T_COMMENT, T_DOC_COMMENT);
foreach (token_get_all($code) as $token) {
if (is_array($token)) {
if (in_array($token[0], $commentTokens)) {
continue;
}
$token = $token[1];
}
$output .= $token;
}
return $output;
} | php | public static function stripComments($code)
{
$output = '';
$commentTokens = array(T_COMMENT, T_DOC_COMMENT);
foreach (token_get_all($code) as $token) {
if (is_array($token)) {
if (in_array($token[0], $commentTokens)) {
continue;
}
$token = $token[1];
}
$output .= $token;
}
return $output;
} | [
"public",
"static",
"function",
"stripComments",
"(",
"$",
"code",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"commentTokens",
"=",
"array",
"(",
"T_COMMENT",
",",
"T_DOC_COMMENT",
")",
";",
"foreach",
"(",
"token_get_all",
"(",
"$",
"code",
")",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"token",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"token",
"[",
"0",
"]",
",",
"$",
"commentTokens",
")",
")",
"{",
"continue",
";",
"}",
"$",
"token",
"=",
"$",
"token",
"[",
"1",
"]",
";",
"}",
"$",
"output",
".=",
"$",
"token",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Remove inline and codeblock comments from a PHP code string
@param string $code The input code
@return string The input code, without comments | [
"Remove",
"inline",
"and",
"codeblock",
"comments",
"from",
"a",
"PHP",
"code",
"string"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/AlternativeCodingStandardsBehavior.php#L121-L136 |
propelorm/Propel | generator/lib/task/PropelSQLExec.php | PropelSQLExec.getBuildConnection | public function getBuildConnection($database)
{
if (!isset($this->buildConnections[$database])) {
// fallback to default connection settings from build.properties
return array(
'dsn' => $this->url,
'user' => $this->userId,
'password' => $this->password,
);
}
return $this->buildConnections[$database];
} | php | public function getBuildConnection($database)
{
if (!isset($this->buildConnections[$database])) {
// fallback to default connection settings from build.properties
return array(
'dsn' => $this->url,
'user' => $this->userId,
'password' => $this->password,
);
}
return $this->buildConnections[$database];
} | [
"public",
"function",
"getBuildConnection",
"(",
"$",
"database",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"buildConnections",
"[",
"$",
"database",
"]",
")",
")",
"{",
"// fallback to default connection settings from build.properties",
"return",
"array",
"(",
"'dsn'",
"=>",
"$",
"this",
"->",
"url",
",",
"'user'",
"=>",
"$",
"this",
"->",
"userId",
",",
"'password'",
"=>",
"$",
"this",
"->",
"password",
",",
")",
";",
"}",
"return",
"$",
"this",
"->",
"buildConnections",
"[",
"$",
"database",
"]",
";",
"}"
] | Get the buildtime connection settings for a given database name.
@param string $database
@return array $buildConnections | [
"Get",
"the",
"buildtime",
"connection",
"settings",
"for",
"a",
"given",
"database",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLExec.php#L116-L128 |
propelorm/Propel | generator/lib/task/PropelSQLExec.php | PropelSQLExec.main | public function main()
{
$conf = new GeneratorConfig();
$conf->setBuildProperties($this->getProject()->getProperties());
$this->setBuildConnections($conf->getBuildConnections());
if ($this->sqldbmap === null || $this->getSqlDbMap()->exists() === false) {
throw new BuildException("You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $this->sqldbmap->getPath());
}
if ($this->url === null) {
throw new BuildException("DSN url attribute must be set!");
}
// get an ordered list of SQL files to execute
$databases = $this->getFilesToExecute();
$this->log(sprintf('Reading SQL files...'));
foreach ($databases as $database => $files) {
$statements[$database] = array();
foreach ($files as $fileName) {
$fullFileName = $this->srcDir ? $this->srcDir . DIRECTORY_SEPARATOR . $fileName : $fileName;
if (file_exists($fullFileName)) {
$this->log(sprintf(' Loading statements from "%s"', $fullFileName));
$fileStatements = PropelSQLParser::parseFile($fullFileName);
$this->log(sprintf(' %d statements to execute', count($fileStatements)), Project::MSG_VERBOSE);
$statements[$database] = array_merge($statements[$database], $fileStatements);
} else {
$this->log(sprintf('File "%s" in sqldbmap does not exist, skipping it.', $fullFileName));
}
}
}
$successfulStatements = 0;
$this->log(sprintf('Executing SQL statements...'));
foreach ($statements as $database => $statementList) {
$successfulStatements += $this->insertDatabaseSqlFiles($database, $statementList);
}
$this->log(sprintf('SQL execution complete. %d statements successfully executed.', $successfulStatements));
} | php | public function main()
{
$conf = new GeneratorConfig();
$conf->setBuildProperties($this->getProject()->getProperties());
$this->setBuildConnections($conf->getBuildConnections());
if ($this->sqldbmap === null || $this->getSqlDbMap()->exists() === false) {
throw new BuildException("You haven't provided an sqldbmap, or " . "the one you specified doesn't exist: " . $this->sqldbmap->getPath());
}
if ($this->url === null) {
throw new BuildException("DSN url attribute must be set!");
}
// get an ordered list of SQL files to execute
$databases = $this->getFilesToExecute();
$this->log(sprintf('Reading SQL files...'));
foreach ($databases as $database => $files) {
$statements[$database] = array();
foreach ($files as $fileName) {
$fullFileName = $this->srcDir ? $this->srcDir . DIRECTORY_SEPARATOR . $fileName : $fileName;
if (file_exists($fullFileName)) {
$this->log(sprintf(' Loading statements from "%s"', $fullFileName));
$fileStatements = PropelSQLParser::parseFile($fullFileName);
$this->log(sprintf(' %d statements to execute', count($fileStatements)), Project::MSG_VERBOSE);
$statements[$database] = array_merge($statements[$database], $fileStatements);
} else {
$this->log(sprintf('File "%s" in sqldbmap does not exist, skipping it.', $fullFileName));
}
}
}
$successfulStatements = 0;
$this->log(sprintf('Executing SQL statements...'));
foreach ($statements as $database => $statementList) {
$successfulStatements += $this->insertDatabaseSqlFiles($database, $statementList);
}
$this->log(sprintf('SQL execution complete. %d statements successfully executed.', $successfulStatements));
} | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"conf",
"=",
"new",
"GeneratorConfig",
"(",
")",
";",
"$",
"conf",
"->",
"setBuildProperties",
"(",
"$",
"this",
"->",
"getProject",
"(",
")",
"->",
"getProperties",
"(",
")",
")",
";",
"$",
"this",
"->",
"setBuildConnections",
"(",
"$",
"conf",
"->",
"getBuildConnections",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"sqldbmap",
"===",
"null",
"||",
"$",
"this",
"->",
"getSqlDbMap",
"(",
")",
"->",
"exists",
"(",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"You haven't provided an sqldbmap, or \"",
".",
"\"the one you specified doesn't exist: \"",
".",
"$",
"this",
"->",
"sqldbmap",
"->",
"getPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"url",
"===",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"DSN url attribute must be set!\"",
")",
";",
"}",
"// get an ordered list of SQL files to execute",
"$",
"databases",
"=",
"$",
"this",
"->",
"getFilesToExecute",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Reading SQL files...'",
")",
")",
";",
"foreach",
"(",
"$",
"databases",
"as",
"$",
"database",
"=>",
"$",
"files",
")",
"{",
"$",
"statements",
"[",
"$",
"database",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"fileName",
")",
"{",
"$",
"fullFileName",
"=",
"$",
"this",
"->",
"srcDir",
"?",
"$",
"this",
"->",
"srcDir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"fileName",
":",
"$",
"fileName",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fullFileName",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' Loading statements from \"%s\"'",
",",
"$",
"fullFileName",
")",
")",
";",
"$",
"fileStatements",
"=",
"PropelSQLParser",
"::",
"parseFile",
"(",
"$",
"fullFileName",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' %d statements to execute'",
",",
"count",
"(",
"$",
"fileStatements",
")",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"statements",
"[",
"$",
"database",
"]",
"=",
"array_merge",
"(",
"$",
"statements",
"[",
"$",
"database",
"]",
",",
"$",
"fileStatements",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'File \"%s\" in sqldbmap does not exist, skipping it.'",
",",
"$",
"fullFileName",
")",
")",
";",
"}",
"}",
"}",
"$",
"successfulStatements",
"=",
"0",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Executing SQL statements...'",
")",
")",
";",
"foreach",
"(",
"$",
"statements",
"as",
"$",
"database",
"=>",
"$",
"statementList",
")",
"{",
"$",
"successfulStatements",
"+=",
"$",
"this",
"->",
"insertDatabaseSqlFiles",
"(",
"$",
"database",
",",
"$",
"statementList",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'SQL execution complete. %d statements successfully executed.'",
",",
"$",
"successfulStatements",
")",
")",
";",
"}"
] | Load the sql file and then execute it
@throws BuildException | [
"Load",
"the",
"sql",
"file",
"and",
"then",
"execute",
"it"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLExec.php#L209-L249 |
propelorm/Propel | generator/lib/task/PropelSQLExec.php | PropelSQLExec.insertDatabaseSqlFiles | protected function insertDatabaseSqlFiles($database, $statements)
{
$buildConnection = $this->getBuildConnection($database);
$dsn = str_replace("@DB@", $database, $buildConnection['dsn']);
$this->log(sprintf(' Connecting to database "%s" using DSN "%s"', $database, $dsn));
try {
// Set user + password to null if they are empty strings or missing
$username = isset($buildConnection['user']) && $buildConnection['user'] ? $buildConnection['user'] : null;
$password = isset($buildConnection['password']) && $buildConnection['password'] ? $buildConnection['password'] : null;
$this->conn = new PDO($dsn, $username, $password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Process all statements
foreach ($statements as $statement) {
$this->execSQL($statement);
if (!$this->autocommit) {
$this->log(" Commiting transaction", Project::MSG_VERBOSE);
$this->conn->commit();
}
}
} catch (IOException $e) {
if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") {
try {
$this->conn->rollBack();
} catch (PDOException $ex) {
// do nothing.
$this->log(" Rollback failed.");
}
}
throw new BuildException($e);
} catch (PDOException $e) {
if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") {
try {
$this->conn->rollBack();
} catch (PDOException $ex) {
// do nothing.
$this->log(" Rollback failed");
}
}
throw new BuildException($e);
}
$this->log(sprintf(' %d of %d SQL statements executed successfully', $this->goodSql, $this->totalSql));
return $this->goodSql;
} | php | protected function insertDatabaseSqlFiles($database, $statements)
{
$buildConnection = $this->getBuildConnection($database);
$dsn = str_replace("@DB@", $database, $buildConnection['dsn']);
$this->log(sprintf(' Connecting to database "%s" using DSN "%s"', $database, $dsn));
try {
// Set user + password to null if they are empty strings or missing
$username = isset($buildConnection['user']) && $buildConnection['user'] ? $buildConnection['user'] : null;
$password = isset($buildConnection['password']) && $buildConnection['password'] ? $buildConnection['password'] : null;
$this->conn = new PDO($dsn, $username, $password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Process all statements
foreach ($statements as $statement) {
$this->execSQL($statement);
if (!$this->autocommit) {
$this->log(" Commiting transaction", Project::MSG_VERBOSE);
$this->conn->commit();
}
}
} catch (IOException $e) {
if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") {
try {
$this->conn->rollBack();
} catch (PDOException $ex) {
// do nothing.
$this->log(" Rollback failed.");
}
}
throw new BuildException($e);
} catch (PDOException $e) {
if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") {
try {
$this->conn->rollBack();
} catch (PDOException $ex) {
// do nothing.
$this->log(" Rollback failed");
}
}
throw new BuildException($e);
}
$this->log(sprintf(' %d of %d SQL statements executed successfully', $this->goodSql, $this->totalSql));
return $this->goodSql;
} | [
"protected",
"function",
"insertDatabaseSqlFiles",
"(",
"$",
"database",
",",
"$",
"statements",
")",
"{",
"$",
"buildConnection",
"=",
"$",
"this",
"->",
"getBuildConnection",
"(",
"$",
"database",
")",
";",
"$",
"dsn",
"=",
"str_replace",
"(",
"\"@DB@\"",
",",
"$",
"database",
",",
"$",
"buildConnection",
"[",
"'dsn'",
"]",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' Connecting to database \"%s\" using DSN \"%s\"'",
",",
"$",
"database",
",",
"$",
"dsn",
")",
")",
";",
"try",
"{",
"// Set user + password to null if they are empty strings or missing",
"$",
"username",
"=",
"isset",
"(",
"$",
"buildConnection",
"[",
"'user'",
"]",
")",
"&&",
"$",
"buildConnection",
"[",
"'user'",
"]",
"?",
"$",
"buildConnection",
"[",
"'user'",
"]",
":",
"null",
";",
"$",
"password",
"=",
"isset",
"(",
"$",
"buildConnection",
"[",
"'password'",
"]",
")",
"&&",
"$",
"buildConnection",
"[",
"'password'",
"]",
"?",
"$",
"buildConnection",
"[",
"'password'",
"]",
":",
"null",
";",
"$",
"this",
"->",
"conn",
"=",
"new",
"PDO",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
")",
";",
"$",
"this",
"->",
"conn",
"->",
"setAttribute",
"(",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"// Process all statements",
"foreach",
"(",
"$",
"statements",
"as",
"$",
"statement",
")",
"{",
"$",
"this",
"->",
"execSQL",
"(",
"$",
"statement",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"autocommit",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\" Commiting transaction\"",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"this",
"->",
"conn",
"->",
"commit",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"autocommit",
"&&",
"$",
"this",
"->",
"conn",
"!==",
"null",
"&&",
"$",
"this",
"->",
"onError",
"==",
"\"abort\"",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"conn",
"->",
"rollBack",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"ex",
")",
"{",
"// do nothing.",
"$",
"this",
"->",
"log",
"(",
"\" Rollback failed.\"",
")",
";",
"}",
"}",
"throw",
"new",
"BuildException",
"(",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"autocommit",
"&&",
"$",
"this",
"->",
"conn",
"!==",
"null",
"&&",
"$",
"this",
"->",
"onError",
"==",
"\"abort\"",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"conn",
"->",
"rollBack",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"ex",
")",
"{",
"// do nothing.",
"$",
"this",
"->",
"log",
"(",
"\" Rollback failed\"",
")",
";",
"}",
"}",
"throw",
"new",
"BuildException",
"(",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' %d of %d SQL statements executed successfully'",
",",
"$",
"this",
"->",
"goodSql",
",",
"$",
"this",
"->",
"totalSql",
")",
")",
";",
"return",
"$",
"this",
"->",
"goodSql",
";",
"}"
] | Executes a set of SQL statements into the target database.
@param string $database The name of the database, as defined in the build connections
@param array $statements list of SQL statements (strings) to be executed
@return integer the number of successful statements
@throws BuildException | [
"Executes",
"a",
"set",
"of",
"SQL",
"statements",
"into",
"the",
"target",
"database",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLExec.php#L290-L338 |
propelorm/Propel | generator/lib/task/PropelSQLExec.php | PropelSQLExec.execSQL | protected function execSQL($sql)
{
// Check and ignore empty statements
if (trim($sql) == "") {
return;
}
try {
$this->totalSql++;
if (!$this->autocommit) {
$this->conn->beginTransaction();
}
$stmt = $this->conn->prepare($sql);
$this->log(sprintf(' Executing statement "%s"', $sql), Project::MSG_VERBOSE);
$stmt->execute();
$this->log(sprintf(' %d rows affected', $stmt->rowCount()), Project::MSG_VERBOSE);
if (!$this->autocommit) {
$this->conn->commit();
}
$this->goodSql++;
} catch (PDOException $e) {
$this->log("Failed to execute: " . $sql, Project::MSG_ERR);
if ($this->onError != "continue") {
throw $e;
}
$this->log($e->getMessage(), Project::MSG_ERR);
}
} | php | protected function execSQL($sql)
{
// Check and ignore empty statements
if (trim($sql) == "") {
return;
}
try {
$this->totalSql++;
if (!$this->autocommit) {
$this->conn->beginTransaction();
}
$stmt = $this->conn->prepare($sql);
$this->log(sprintf(' Executing statement "%s"', $sql), Project::MSG_VERBOSE);
$stmt->execute();
$this->log(sprintf(' %d rows affected', $stmt->rowCount()), Project::MSG_VERBOSE);
if (!$this->autocommit) {
$this->conn->commit();
}
$this->goodSql++;
} catch (PDOException $e) {
$this->log("Failed to execute: " . $sql, Project::MSG_ERR);
if ($this->onError != "continue") {
throw $e;
}
$this->log($e->getMessage(), Project::MSG_ERR);
}
} | [
"protected",
"function",
"execSQL",
"(",
"$",
"sql",
")",
"{",
"// Check and ignore empty statements",
"if",
"(",
"trim",
"(",
"$",
"sql",
")",
"==",
"\"\"",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"totalSql",
"++",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"autocommit",
")",
"{",
"$",
"this",
"->",
"conn",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"$",
"stmt",
"=",
"$",
"this",
"->",
"conn",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' Executing statement \"%s\"'",
",",
"$",
"sql",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' %d rows affected'",
",",
"$",
"stmt",
"->",
"rowCount",
"(",
")",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"autocommit",
")",
"{",
"$",
"this",
"->",
"conn",
"->",
"commit",
"(",
")",
";",
"}",
"$",
"this",
"->",
"goodSql",
"++",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Failed to execute: \"",
".",
"$",
"sql",
",",
"Project",
"::",
"MSG_ERR",
")",
";",
"if",
"(",
"$",
"this",
"->",
"onError",
"!=",
"\"continue\"",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Project",
"::",
"MSG_ERR",
")",
";",
"}",
"}"
] | Execute a SQL statement using the current connection property.
@param string $sql SQL statement to execute
@throws PDOException | [
"Execute",
"a",
"SQL",
"statement",
"using",
"the",
"current",
"connection",
"property",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLExec.php#L347-L378 |
propelorm/Propel | generator/lib/reverse/sqlite/SqliteSchemaParser.php | SqliteSchemaParser.addColumns | protected function addColumns(Table $table)
{
$stmt = $this->dbh->query("PRAGMA table_info('" . $table->getName() . "')");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $row['name'];
$fulltype = $row['type'];
$size = null;
$precision = null;
$scale = null;
if (preg_match('/^([^\(]+)\(\s*(\d+)\s*,\s*(\d+)\s*\)$/', $fulltype, $matches)) {
$type = $matches[1];
$precision = $matches[2];
$scale = $matches[3]; // aka precision
} elseif (preg_match('/^([^\(]+)\(\s*(\d+)\s*\)$/', $fulltype, $matches)) {
$type = $matches[1];
$size = $matches[2];
} else {
$type = $fulltype;
}
// If column is primary key and of type INTEGER, it is auto increment
// See: http://sqlite.org/faq.html#q1
$autoincrement = ($row['pk'] == 1 && strtolower($type) == 'integer');
$not_null = $row['notnull'];
$default = $row['dflt_value'];
$propelType = $this->getMappedPropelType(strtolower($type));
if (!$propelType) {
$propelType = Column::DEFAULT_TYPE;
$this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support.");
}
$column = new Column($name);
$column->setTable($table);
$column->setDomainForType($propelType);
// We may want to provide an option to include this:
// $column->getDomain()->replaceSqlType($type);
$column->getDomain()->replaceSize($size);
$column->getDomain()->replaceScale($scale);
if ($default !== null) {
$column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
}
$column->setAutoIncrement($autoincrement);
$column->setNotNull($not_null);
if (($row['pk'] == 1) || (strtolower($type) == 'integer')) {
$column->setPrimaryKey(true);
}
$table->addColumn($column);
}
} | php | protected function addColumns(Table $table)
{
$stmt = $this->dbh->query("PRAGMA table_info('" . $table->getName() . "')");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $row['name'];
$fulltype = $row['type'];
$size = null;
$precision = null;
$scale = null;
if (preg_match('/^([^\(]+)\(\s*(\d+)\s*,\s*(\d+)\s*\)$/', $fulltype, $matches)) {
$type = $matches[1];
$precision = $matches[2];
$scale = $matches[3]; // aka precision
} elseif (preg_match('/^([^\(]+)\(\s*(\d+)\s*\)$/', $fulltype, $matches)) {
$type = $matches[1];
$size = $matches[2];
} else {
$type = $fulltype;
}
// If column is primary key and of type INTEGER, it is auto increment
// See: http://sqlite.org/faq.html#q1
$autoincrement = ($row['pk'] == 1 && strtolower($type) == 'integer');
$not_null = $row['notnull'];
$default = $row['dflt_value'];
$propelType = $this->getMappedPropelType(strtolower($type));
if (!$propelType) {
$propelType = Column::DEFAULT_TYPE;
$this->warn("Column [" . $table->getName() . "." . $name . "] has a column type (" . $type . ") that Propel does not support.");
}
$column = new Column($name);
$column->setTable($table);
$column->setDomainForType($propelType);
// We may want to provide an option to include this:
// $column->getDomain()->replaceSqlType($type);
$column->getDomain()->replaceSize($size);
$column->getDomain()->replaceScale($scale);
if ($default !== null) {
$column->getDomain()->setDefaultValue(new ColumnDefaultValue($default, ColumnDefaultValue::TYPE_VALUE));
}
$column->setAutoIncrement($autoincrement);
$column->setNotNull($not_null);
if (($row['pk'] == 1) || (strtolower($type) == 'integer')) {
$column->setPrimaryKey(true);
}
$table->addColumn($column);
}
} | [
"protected",
"function",
"addColumns",
"(",
"Table",
"$",
"table",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"dbh",
"->",
"query",
"(",
"\"PRAGMA table_info('\"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
".",
"\"')\"",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
"{",
"$",
"name",
"=",
"$",
"row",
"[",
"'name'",
"]",
";",
"$",
"fulltype",
"=",
"$",
"row",
"[",
"'type'",
"]",
";",
"$",
"size",
"=",
"null",
";",
"$",
"precision",
"=",
"null",
";",
"$",
"scale",
"=",
"null",
";",
"if",
"(",
"preg_match",
"(",
"'/^([^\\(]+)\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)$/'",
",",
"$",
"fulltype",
",",
"$",
"matches",
")",
")",
"{",
"$",
"type",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"precision",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"scale",
"=",
"$",
"matches",
"[",
"3",
"]",
";",
"// aka precision",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^([^\\(]+)\\(\\s*(\\d+)\\s*\\)$/'",
",",
"$",
"fulltype",
",",
"$",
"matches",
")",
")",
"{",
"$",
"type",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"size",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"$",
"fulltype",
";",
"}",
"// If column is primary key and of type INTEGER, it is auto increment",
"// See: http://sqlite.org/faq.html#q1",
"$",
"autoincrement",
"=",
"(",
"$",
"row",
"[",
"'pk'",
"]",
"==",
"1",
"&&",
"strtolower",
"(",
"$",
"type",
")",
"==",
"'integer'",
")",
";",
"$",
"not_null",
"=",
"$",
"row",
"[",
"'notnull'",
"]",
";",
"$",
"default",
"=",
"$",
"row",
"[",
"'dflt_value'",
"]",
";",
"$",
"propelType",
"=",
"$",
"this",
"->",
"getMappedPropelType",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
";",
"if",
"(",
"!",
"$",
"propelType",
")",
"{",
"$",
"propelType",
"=",
"Column",
"::",
"DEFAULT_TYPE",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Column [\"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
".",
"\".\"",
".",
"$",
"name",
".",
"\"] has a column type (\"",
".",
"$",
"type",
".",
"\") that Propel does not support.\"",
")",
";",
"}",
"$",
"column",
"=",
"new",
"Column",
"(",
"$",
"name",
")",
";",
"$",
"column",
"->",
"setTable",
"(",
"$",
"table",
")",
";",
"$",
"column",
"->",
"setDomainForType",
"(",
"$",
"propelType",
")",
";",
"// We may want to provide an option to include this:",
"// $column->getDomain()->replaceSqlType($type);",
"$",
"column",
"->",
"getDomain",
"(",
")",
"->",
"replaceSize",
"(",
"$",
"size",
")",
";",
"$",
"column",
"->",
"getDomain",
"(",
")",
"->",
"replaceScale",
"(",
"$",
"scale",
")",
";",
"if",
"(",
"$",
"default",
"!==",
"null",
")",
"{",
"$",
"column",
"->",
"getDomain",
"(",
")",
"->",
"setDefaultValue",
"(",
"new",
"ColumnDefaultValue",
"(",
"$",
"default",
",",
"ColumnDefaultValue",
"::",
"TYPE_VALUE",
")",
")",
";",
"}",
"$",
"column",
"->",
"setAutoIncrement",
"(",
"$",
"autoincrement",
")",
";",
"$",
"column",
"->",
"setNotNull",
"(",
"$",
"not_null",
")",
";",
"if",
"(",
"(",
"$",
"row",
"[",
"'pk'",
"]",
"==",
"1",
")",
"||",
"(",
"strtolower",
"(",
"$",
"type",
")",
"==",
"'integer'",
")",
")",
"{",
"$",
"column",
"->",
"setPrimaryKey",
"(",
"true",
")",
";",
"}",
"$",
"table",
"->",
"addColumn",
"(",
"$",
"column",
")",
";",
"}",
"}"
] | Adds Columns to the specified table.
@param Table $table The Table model class to add columns to.
@param string $version The database version. | [
"Adds",
"Columns",
"to",
"the",
"specified",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/reverse/sqlite/SqliteSchemaParser.php#L112-L166 |
propelorm/Propel | generator/lib/reverse/sqlite/SqliteSchemaParser.php | SqliteSchemaParser.addIndexes | protected function addIndexes(Table $table)
{
$stmt = $this->dbh->query("PRAGMA index_list('" . $table->getName() . "')");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $row['name'];
$index = new Index($name);
$stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')");
while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
$colname = $row2['name'];
$index->addColumn($table->getColumn($colname));
}
$table->addIndex($index);
}
} | php | protected function addIndexes(Table $table)
{
$stmt = $this->dbh->query("PRAGMA index_list('" . $table->getName() . "')");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name = $row['name'];
$index = new Index($name);
$stmt2 = $this->dbh->query("PRAGMA index_info('" . $name . "')");
while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
$colname = $row2['name'];
$index->addColumn($table->getColumn($colname));
}
$table->addIndex($index);
}
} | [
"protected",
"function",
"addIndexes",
"(",
"Table",
"$",
"table",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"dbh",
"->",
"query",
"(",
"\"PRAGMA index_list('\"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
".",
"\"')\"",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
"{",
"$",
"name",
"=",
"$",
"row",
"[",
"'name'",
"]",
";",
"$",
"index",
"=",
"new",
"Index",
"(",
"$",
"name",
")",
";",
"$",
"stmt2",
"=",
"$",
"this",
"->",
"dbh",
"->",
"query",
"(",
"\"PRAGMA index_info('\"",
".",
"$",
"name",
".",
"\"')\"",
")",
";",
"while",
"(",
"$",
"row2",
"=",
"$",
"stmt2",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
"{",
"$",
"colname",
"=",
"$",
"row2",
"[",
"'name'",
"]",
";",
"$",
"index",
"->",
"addColumn",
"(",
"$",
"table",
"->",
"getColumn",
"(",
"$",
"colname",
")",
")",
";",
"}",
"$",
"table",
"->",
"addIndex",
"(",
"$",
"index",
")",
";",
"}",
"}"
] | Load indexes for this table | [
"Load",
"indexes",
"for",
"this",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/reverse/sqlite/SqliteSchemaParser.php#L171-L188 |
propelorm/Propel | runtime/lib/validator/MaxValueValidator.php | MaxValueValidator.isValid | public function isValid(ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value) == true) {
return intval($value) <= intval($map->getValue());
}
return false;
} | php | public function isValid(ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value) == true) {
return intval($value) <= intval($map->getValue());
}
return false;
} | [
"public",
"function",
"isValid",
"(",
"ValidatorMap",
"$",
"map",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"==",
"false",
"&&",
"is_numeric",
"(",
"$",
"value",
")",
"==",
"true",
")",
"{",
"return",
"intval",
"(",
"$",
"value",
")",
"<=",
"intval",
"(",
"$",
"map",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | @see BasicValidator::isValid()
@param ValidatorMap $map
@param mixed $value
@return boolean | [
"@see",
"BasicValidator",
"::",
"isValid",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/validator/MaxValueValidator.php#L39-L46 |
propelorm/Propel | generator/lib/util/PropelSQLParser.php | PropelSQLParser.executeStatements | protected static function executeStatements($statements, $connection)
{
foreach ($statements as $statement) {
$stmt = $connection->prepare($statement);
if ($stmt instanceof PDOStatement) {
// only execute if has no error
$stmt->execute();
}
}
return count($statements);
} | php | protected static function executeStatements($statements, $connection)
{
foreach ($statements as $statement) {
$stmt = $connection->prepare($statement);
if ($stmt instanceof PDOStatement) {
// only execute if has no error
$stmt->execute();
}
}
return count($statements);
} | [
"protected",
"static",
"function",
"executeStatements",
"(",
"$",
"statements",
",",
"$",
"connection",
")",
"{",
"foreach",
"(",
"$",
"statements",
"as",
"$",
"statement",
")",
"{",
"$",
"stmt",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"statement",
")",
";",
"if",
"(",
"$",
"stmt",
"instanceof",
"PDOStatement",
")",
"{",
"// only execute if has no error",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"}",
"return",
"count",
"(",
"$",
"statements",
")",
";",
"}"
] | Execute a list of DDL statements based on an array
Does not use transactions since they are not supported in DDL statements
@param array $statements a list of SQL statements
@param PDO $connection a connection object
@return integer the number of executed statements | [
"Execute",
"a",
"list",
"of",
"DDL",
"statements",
"based",
"on",
"an",
"array",
"Does",
"not",
"use",
"transactions",
"since",
"they",
"are",
"not",
"supported",
"in",
"DDL",
"statements"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/util/PropelSQLParser.php#L87-L98 |
propelorm/Propel | generator/lib/model/diff/PropelDatabaseDiff.php | PropelDatabaseDiff.getReverseDiff | public function getReverseDiff()
{
$diff = new self();
$diff->setAddedTables($this->getRemovedTables());
// idMethod is not set for tables build from reverse engineering
// FIXME: this should be handled by reverse classes
foreach ($diff->getAddedTables() as $name => $table) {
if ($table->getIdMethod() == IDMethod::NO_ID_METHOD) {
$table->setIdMethod(IDMethod::NATIVE);
}
}
$diff->setRemovedTables($this->getAddedTables());
$diff->setRenamedTables(array_flip($this->getRenamedTables()));
$tableDiffs = array();
foreach ($this->getModifiedTables() as $name => $tableDiff) {
$tableDiffs[$name] = $tableDiff->getReverseDiff();
}
$diff->setModifiedTables($tableDiffs);
return $diff;
} | php | public function getReverseDiff()
{
$diff = new self();
$diff->setAddedTables($this->getRemovedTables());
// idMethod is not set for tables build from reverse engineering
// FIXME: this should be handled by reverse classes
foreach ($diff->getAddedTables() as $name => $table) {
if ($table->getIdMethod() == IDMethod::NO_ID_METHOD) {
$table->setIdMethod(IDMethod::NATIVE);
}
}
$diff->setRemovedTables($this->getAddedTables());
$diff->setRenamedTables(array_flip($this->getRenamedTables()));
$tableDiffs = array();
foreach ($this->getModifiedTables() as $name => $tableDiff) {
$tableDiffs[$name] = $tableDiff->getReverseDiff();
}
$diff->setModifiedTables($tableDiffs);
return $diff;
} | [
"public",
"function",
"getReverseDiff",
"(",
")",
"{",
"$",
"diff",
"=",
"new",
"self",
"(",
")",
";",
"$",
"diff",
"->",
"setAddedTables",
"(",
"$",
"this",
"->",
"getRemovedTables",
"(",
")",
")",
";",
"// idMethod is not set for tables build from reverse engineering",
"// FIXME: this should be handled by reverse classes",
"foreach",
"(",
"$",
"diff",
"->",
"getAddedTables",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"->",
"getIdMethod",
"(",
")",
"==",
"IDMethod",
"::",
"NO_ID_METHOD",
")",
"{",
"$",
"table",
"->",
"setIdMethod",
"(",
"IDMethod",
"::",
"NATIVE",
")",
";",
"}",
"}",
"$",
"diff",
"->",
"setRemovedTables",
"(",
"$",
"this",
"->",
"getAddedTables",
"(",
")",
")",
";",
"$",
"diff",
"->",
"setRenamedTables",
"(",
"array_flip",
"(",
"$",
"this",
"->",
"getRenamedTables",
"(",
")",
")",
")",
";",
"$",
"tableDiffs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getModifiedTables",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"tableDiff",
")",
"{",
"$",
"tableDiffs",
"[",
"$",
"name",
"]",
"=",
"$",
"tableDiff",
"->",
"getReverseDiff",
"(",
")",
";",
"}",
"$",
"diff",
"->",
"setModifiedTables",
"(",
"$",
"tableDiffs",
")",
";",
"return",
"$",
"diff",
";",
"}"
] | Get the reverse diff for this diff
@return PropelDatabaseDiff | [
"Get",
"the",
"reverse",
"diff",
"for",
"this",
"diff"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelDatabaseDiff.php#L241-L261 |
propelorm/Propel | generator/lib/model/diff/PropelDatabaseDiff.php | PropelDatabaseDiff.getDescription | public function getDescription()
{
$changes = array();
if ($count = $this->countAddedTables()) {
$changes[] = sprintf('%d added tables', $count);
}
if ($count = $this->countRemovedTables()) {
$changes[] = sprintf('%d removed tables', $count);
}
if ($count = $this->countModifiedTables()) {
$changes[] = sprintf('%d modified tables', $count);
}
if ($count = $this->countRenamedTables()) {
$changes[] = sprintf('%d renamed tables', $count);
}
return implode(', ', $changes);
} | php | public function getDescription()
{
$changes = array();
if ($count = $this->countAddedTables()) {
$changes[] = sprintf('%d added tables', $count);
}
if ($count = $this->countRemovedTables()) {
$changes[] = sprintf('%d removed tables', $count);
}
if ($count = $this->countModifiedTables()) {
$changes[] = sprintf('%d modified tables', $count);
}
if ($count = $this->countRenamedTables()) {
$changes[] = sprintf('%d renamed tables', $count);
}
return implode(', ', $changes);
} | [
"public",
"function",
"getDescription",
"(",
")",
"{",
"$",
"changes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"count",
"=",
"$",
"this",
"->",
"countAddedTables",
"(",
")",
")",
"{",
"$",
"changes",
"[",
"]",
"=",
"sprintf",
"(",
"'%d added tables'",
",",
"$",
"count",
")",
";",
"}",
"if",
"(",
"$",
"count",
"=",
"$",
"this",
"->",
"countRemovedTables",
"(",
")",
")",
"{",
"$",
"changes",
"[",
"]",
"=",
"sprintf",
"(",
"'%d removed tables'",
",",
"$",
"count",
")",
";",
"}",
"if",
"(",
"$",
"count",
"=",
"$",
"this",
"->",
"countModifiedTables",
"(",
")",
")",
"{",
"$",
"changes",
"[",
"]",
"=",
"sprintf",
"(",
"'%d modified tables'",
",",
"$",
"count",
")",
";",
"}",
"if",
"(",
"$",
"count",
"=",
"$",
"this",
"->",
"countRenamedTables",
"(",
")",
")",
"{",
"$",
"changes",
"[",
"]",
"=",
"sprintf",
"(",
"'%d renamed tables'",
",",
"$",
"count",
")",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"changes",
")",
";",
"}"
] | Get a description of the database modifications
@return string | [
"Get",
"a",
"description",
"of",
"the",
"database",
"modifications"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelDatabaseDiff.php#L268-L285 |
propelorm/Propel | generator/lib/task/PropelConvertConfTask.php | PropelConvertConfTask.main | public function main()
{
// Check to make sure the input and output files were specified and that the input file exists.
if (!$this->xmlConfFile || !$this->xmlConfFile->exists()) {
throw new BuildException("No valid xmlConfFile specified.", $this->getLocation());
}
if (!$this->outputFile) {
throw new BuildException("No outputFile specified.", $this->getLocation());
}
$this->log('Loading XML configuration file...');
// Create a PHP array from the runtime-conf.xml file
$xmlDom = new DOMDocument();
$xmlDom->load($this->xmlConfFile->getAbsolutePath());
$xml = simplexml_load_string($xmlDom->saveXML());
$phpconf = self::simpleXmlToArray($xml);
$this->log(sprintf('Loaded "%s" successfully', $this->xmlConfFile->getAbsolutePath()), Project::MSG_VERBOSE);
/* For some reason the array generated from runtime-conf.xml has separate
* 'log' section and 'propel' sections. To maintain backward compatibility
* we need to put 'log' back into the 'propel' section.
*/
$log = array();
if (isset($phpconf['log'])) {
$phpconf['propel']['log'] = $phpconf['log'];
unset($phpconf['log']);
}
if (isset($phpconf['propel'])) {
$phpconf = $phpconf['propel'];
}
// add generator version
$phpconf['generator_version'] = $this->getGeneratorConfig()->getBuildProperty('version');
if (!$this->outputClassmapFile) {
// We'll create a default one for BC
$this->outputClassmapFile = 'classmap-' . $this->outputFile;
}
// Write resulting PHP data to output file
$outfile = new PhingFile($this->outputDirectory, $this->outputFile);
$output = "<?php\n";
$output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
$output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n";
$output .= "\$conf = ";
$output .= var_export($phpconf, true);
$output .= ";\n";
$output .= "\$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '" . $this->outputClassmapFile . "');\n";
$output .= "return \$conf;";
$mustWriteRuntimeConf = true;
if (file_exists($outfile->getAbsolutePath())) {
$currentRuntimeConf = file_get_contents($outfile->getAbsolutePath());
if ($currentRuntimeConf == $output) {
$this->log(sprintf('No change in PHP runtime conf file "%s"', $outfile->getPath()), Project::MSG_VERBOSE);
$mustWriteRuntimeConf = false;
} else {
$this->log(sprintf('Updating PHP runtime conf file "%s"', $outfile->getPath()));
}
} else {
$this->log(sprintf('Creating PHP runtime conf file "%s"', $outfile->getPath()));
}
if ($mustWriteRuntimeConf && !file_put_contents($outfile->getAbsolutePath(), $output)) {
throw new BuildException("Error writing output file: " . $outfile->getAbsolutePath(), $this->getLocation());
}
// add classmap
$phpconfClassmap = $this->getClassMap();
$outfile = new PhingFile($this->outputDirectory, $this->outputClassmapFile);
$output = '<' . '?' . "php\n";
$output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
$output .= "return ";
$output .= var_export($phpconfClassmap, true);
$output .= ";";
$mustWriteClassMap = true;
if (file_exists($outfile->getAbsolutePath())) {
$currentClassmap = file_get_contents($outfile->getAbsolutePath());
if ($currentClassmap == $output) {
$this->log(sprintf('No change in PHP classmap file "%s"', $outfile->getPath()), Project::MSG_VERBOSE);
$mustWriteClassMap = false;
} else {
$currentPhpconfClassmap = include $outfile->getAbsolutePath();
if ($addedMaps = array_diff_assoc($phpconfClassmap, $currentPhpconfClassmap)) {
$this->log('Added classmap for the following classes:', Project::MSG_VERBOSE);
$this->logClassMap($addedMaps);
}
if ($removedMaps = array_diff_assoc($currentPhpconfClassmap, $phpconfClassmap)) {
$this->log('Removed classmap for the following classes:', Project::MSG_VERBOSE);
$this->logClassMap($removedMaps);
}
$this->log(sprintf('Updating PHP classmap file "%s"', $outfile->getPath()));
}
} else {
$this->log(sprintf('Creating PHP classmap file "%s"', $outfile->getPath()));
$this->logClassMap($phpconfClassmap);
}
if ($mustWriteClassMap && !file_put_contents($outfile->getAbsolutePath(), $output)) {
throw new BuildException("Error writing output file: " . $outfile->getAbsolutePath(), $this->getLocation());
}
if (!$mustWriteRuntimeConf && !$mustWriteClassMap) {
$this->log('No change in compiled configuration files');
}
} | php | public function main()
{
// Check to make sure the input and output files were specified and that the input file exists.
if (!$this->xmlConfFile || !$this->xmlConfFile->exists()) {
throw new BuildException("No valid xmlConfFile specified.", $this->getLocation());
}
if (!$this->outputFile) {
throw new BuildException("No outputFile specified.", $this->getLocation());
}
$this->log('Loading XML configuration file...');
// Create a PHP array from the runtime-conf.xml file
$xmlDom = new DOMDocument();
$xmlDom->load($this->xmlConfFile->getAbsolutePath());
$xml = simplexml_load_string($xmlDom->saveXML());
$phpconf = self::simpleXmlToArray($xml);
$this->log(sprintf('Loaded "%s" successfully', $this->xmlConfFile->getAbsolutePath()), Project::MSG_VERBOSE);
/* For some reason the array generated from runtime-conf.xml has separate
* 'log' section and 'propel' sections. To maintain backward compatibility
* we need to put 'log' back into the 'propel' section.
*/
$log = array();
if (isset($phpconf['log'])) {
$phpconf['propel']['log'] = $phpconf['log'];
unset($phpconf['log']);
}
if (isset($phpconf['propel'])) {
$phpconf = $phpconf['propel'];
}
// add generator version
$phpconf['generator_version'] = $this->getGeneratorConfig()->getBuildProperty('version');
if (!$this->outputClassmapFile) {
// We'll create a default one for BC
$this->outputClassmapFile = 'classmap-' . $this->outputFile;
}
// Write resulting PHP data to output file
$outfile = new PhingFile($this->outputDirectory, $this->outputFile);
$output = "<?php\n";
$output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
$output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n";
$output .= "\$conf = ";
$output .= var_export($phpconf, true);
$output .= ";\n";
$output .= "\$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '" . $this->outputClassmapFile . "');\n";
$output .= "return \$conf;";
$mustWriteRuntimeConf = true;
if (file_exists($outfile->getAbsolutePath())) {
$currentRuntimeConf = file_get_contents($outfile->getAbsolutePath());
if ($currentRuntimeConf == $output) {
$this->log(sprintf('No change in PHP runtime conf file "%s"', $outfile->getPath()), Project::MSG_VERBOSE);
$mustWriteRuntimeConf = false;
} else {
$this->log(sprintf('Updating PHP runtime conf file "%s"', $outfile->getPath()));
}
} else {
$this->log(sprintf('Creating PHP runtime conf file "%s"', $outfile->getPath()));
}
if ($mustWriteRuntimeConf && !file_put_contents($outfile->getAbsolutePath(), $output)) {
throw new BuildException("Error writing output file: " . $outfile->getAbsolutePath(), $this->getLocation());
}
// add classmap
$phpconfClassmap = $this->getClassMap();
$outfile = new PhingFile($this->outputDirectory, $this->outputClassmapFile);
$output = '<' . '?' . "php\n";
$output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
$output .= "return ";
$output .= var_export($phpconfClassmap, true);
$output .= ";";
$mustWriteClassMap = true;
if (file_exists($outfile->getAbsolutePath())) {
$currentClassmap = file_get_contents($outfile->getAbsolutePath());
if ($currentClassmap == $output) {
$this->log(sprintf('No change in PHP classmap file "%s"', $outfile->getPath()), Project::MSG_VERBOSE);
$mustWriteClassMap = false;
} else {
$currentPhpconfClassmap = include $outfile->getAbsolutePath();
if ($addedMaps = array_diff_assoc($phpconfClassmap, $currentPhpconfClassmap)) {
$this->log('Added classmap for the following classes:', Project::MSG_VERBOSE);
$this->logClassMap($addedMaps);
}
if ($removedMaps = array_diff_assoc($currentPhpconfClassmap, $phpconfClassmap)) {
$this->log('Removed classmap for the following classes:', Project::MSG_VERBOSE);
$this->logClassMap($removedMaps);
}
$this->log(sprintf('Updating PHP classmap file "%s"', $outfile->getPath()));
}
} else {
$this->log(sprintf('Creating PHP classmap file "%s"', $outfile->getPath()));
$this->logClassMap($phpconfClassmap);
}
if ($mustWriteClassMap && !file_put_contents($outfile->getAbsolutePath(), $output)) {
throw new BuildException("Error writing output file: " . $outfile->getAbsolutePath(), $this->getLocation());
}
if (!$mustWriteRuntimeConf && !$mustWriteClassMap) {
$this->log('No change in compiled configuration files');
}
} | [
"public",
"function",
"main",
"(",
")",
"{",
"// Check to make sure the input and output files were specified and that the input file exists.",
"if",
"(",
"!",
"$",
"this",
"->",
"xmlConfFile",
"||",
"!",
"$",
"this",
"->",
"xmlConfFile",
"->",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"No valid xmlConfFile specified.\"",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"outputFile",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"No outputFile specified.\"",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"'Loading XML configuration file...'",
")",
";",
"// Create a PHP array from the runtime-conf.xml file",
"$",
"xmlDom",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"xmlDom",
"->",
"load",
"(",
"$",
"this",
"->",
"xmlConfFile",
"->",
"getAbsolutePath",
"(",
")",
")",
";",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"xmlDom",
"->",
"saveXML",
"(",
")",
")",
";",
"$",
"phpconf",
"=",
"self",
"::",
"simpleXmlToArray",
"(",
"$",
"xml",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Loaded \"%s\" successfully'",
",",
"$",
"this",
"->",
"xmlConfFile",
"->",
"getAbsolutePath",
"(",
")",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"/* For some reason the array generated from runtime-conf.xml has separate\n * 'log' section and 'propel' sections. To maintain backward compatibility\n * we need to put 'log' back into the 'propel' section.\n */",
"$",
"log",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"phpconf",
"[",
"'log'",
"]",
")",
")",
"{",
"$",
"phpconf",
"[",
"'propel'",
"]",
"[",
"'log'",
"]",
"=",
"$",
"phpconf",
"[",
"'log'",
"]",
";",
"unset",
"(",
"$",
"phpconf",
"[",
"'log'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"phpconf",
"[",
"'propel'",
"]",
")",
")",
"{",
"$",
"phpconf",
"=",
"$",
"phpconf",
"[",
"'propel'",
"]",
";",
"}",
"// add generator version",
"$",
"phpconf",
"[",
"'generator_version'",
"]",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getBuildProperty",
"(",
"'version'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"outputClassmapFile",
")",
"{",
"// We'll create a default one for BC",
"$",
"this",
"->",
"outputClassmapFile",
"=",
"'classmap-'",
".",
"$",
"this",
"->",
"outputFile",
";",
"}",
"// Write resulting PHP data to output file",
"$",
"outfile",
"=",
"new",
"PhingFile",
"(",
"$",
"this",
"->",
"outputDirectory",
",",
"$",
"this",
"->",
"outputFile",
")",
";",
"$",
"output",
"=",
"\"<?php\\n\"",
";",
"$",
"output",
".=",
"\"// This file generated by Propel \"",
".",
"$",
"phpconf",
"[",
"'generator_version'",
"]",
".",
"\" convert-conf target\"",
".",
"(",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getBuildProperty",
"(",
"'addTimestamp'",
")",
"?",
"\" on \"",
".",
"strftime",
"(",
"\"%c\"",
")",
":",
"''",
")",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"// from XML runtime conf file \"",
".",
"$",
"this",
"->",
"xmlConfFile",
"->",
"getPath",
"(",
")",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"\\$conf = \"",
";",
"$",
"output",
".=",
"var_export",
"(",
"$",
"phpconf",
",",
"true",
")",
";",
"$",
"output",
".=",
"\";\\n\"",
";",
"$",
"output",
".=",
"\"\\$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '\"",
".",
"$",
"this",
"->",
"outputClassmapFile",
".",
"\"');\\n\"",
";",
"$",
"output",
".=",
"\"return \\$conf;\"",
";",
"$",
"mustWriteRuntimeConf",
"=",
"true",
";",
"if",
"(",
"file_exists",
"(",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
")",
")",
"{",
"$",
"currentRuntimeConf",
"=",
"file_get_contents",
"(",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"$",
"currentRuntimeConf",
"==",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'No change in PHP runtime conf file \"%s\"'",
",",
"$",
"outfile",
"->",
"getPath",
"(",
")",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"mustWriteRuntimeConf",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Updating PHP runtime conf file \"%s\"'",
",",
"$",
"outfile",
"->",
"getPath",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Creating PHP runtime conf file \"%s\"'",
",",
"$",
"outfile",
"->",
"getPath",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"mustWriteRuntimeConf",
"&&",
"!",
"file_put_contents",
"(",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
",",
"$",
"output",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Error writing output file: \"",
".",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
"// add classmap",
"$",
"phpconfClassmap",
"=",
"$",
"this",
"->",
"getClassMap",
"(",
")",
";",
"$",
"outfile",
"=",
"new",
"PhingFile",
"(",
"$",
"this",
"->",
"outputDirectory",
",",
"$",
"this",
"->",
"outputClassmapFile",
")",
";",
"$",
"output",
"=",
"'<'",
".",
"'?'",
".",
"\"php\\n\"",
";",
"$",
"output",
".=",
"\"// This file generated by Propel \"",
".",
"$",
"phpconf",
"[",
"'generator_version'",
"]",
".",
"\" convert-conf target\"",
".",
"(",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getBuildProperty",
"(",
"'addTimestamp'",
")",
"?",
"\" on \"",
".",
"strftime",
"(",
"\"%c\"",
")",
":",
"''",
")",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"\"return \"",
";",
"$",
"output",
".=",
"var_export",
"(",
"$",
"phpconfClassmap",
",",
"true",
")",
";",
"$",
"output",
".=",
"\";\"",
";",
"$",
"mustWriteClassMap",
"=",
"true",
";",
"if",
"(",
"file_exists",
"(",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
")",
")",
"{",
"$",
"currentClassmap",
"=",
"file_get_contents",
"(",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
")",
";",
"if",
"(",
"$",
"currentClassmap",
"==",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'No change in PHP classmap file \"%s\"'",
",",
"$",
"outfile",
"->",
"getPath",
"(",
")",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"mustWriteClassMap",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"currentPhpconfClassmap",
"=",
"include",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
";",
"if",
"(",
"$",
"addedMaps",
"=",
"array_diff_assoc",
"(",
"$",
"phpconfClassmap",
",",
"$",
"currentPhpconfClassmap",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Added classmap for the following classes:'",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"this",
"->",
"logClassMap",
"(",
"$",
"addedMaps",
")",
";",
"}",
"if",
"(",
"$",
"removedMaps",
"=",
"array_diff_assoc",
"(",
"$",
"currentPhpconfClassmap",
",",
"$",
"phpconfClassmap",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Removed classmap for the following classes:'",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"this",
"->",
"logClassMap",
"(",
"$",
"removedMaps",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Updating PHP classmap file \"%s\"'",
",",
"$",
"outfile",
"->",
"getPath",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Creating PHP classmap file \"%s\"'",
",",
"$",
"outfile",
"->",
"getPath",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"logClassMap",
"(",
"$",
"phpconfClassmap",
")",
";",
"}",
"if",
"(",
"$",
"mustWriteClassMap",
"&&",
"!",
"file_put_contents",
"(",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
",",
"$",
"output",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Error writing output file: \"",
".",
"$",
"outfile",
"->",
"getAbsolutePath",
"(",
")",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"mustWriteRuntimeConf",
"&&",
"!",
"$",
"mustWriteClassMap",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'No change in compiled configuration files'",
")",
";",
"}",
"}"
] | The main method does the work of the task. | [
"The",
"main",
"method",
"does",
"the",
"work",
"of",
"the",
"task",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelConvertConfTask.php#L81-L189 |
propelorm/Propel | generator/lib/task/PropelConvertConfTask.php | PropelConvertConfTask.logClassMap | protected function logClassMap($classMap)
{
foreach ($classMap as $className => $classPath) {
$this->log(sprintf(' %-15s => %s', $className, $classPath), Project::MSG_VERBOSE);
}
} | php | protected function logClassMap($classMap)
{
foreach ($classMap as $className => $classPath) {
$this->log(sprintf(' %-15s => %s', $className, $classPath), Project::MSG_VERBOSE);
}
} | [
"protected",
"function",
"logClassMap",
"(",
"$",
"classMap",
")",
"{",
"foreach",
"(",
"$",
"classMap",
"as",
"$",
"className",
"=>",
"$",
"classPath",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"' %-15s => %s'",
",",
"$",
"className",
",",
"$",
"classPath",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"}",
"}"
] | main() | [
"main",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelConvertConfTask.php#L191-L196 |
propelorm/Propel | generator/lib/task/PropelConvertConfTask.php | PropelConvertConfTask.getConvertedXmlValue | private static function getConvertedXmlValue($value)
{
$value = (string) $value; // convert from simplexml to string
// handle booleans specially
$lwr = strtolower($value);
if ($lwr === "false") {
$value = false;
} elseif ($lwr === "true") {
$value = true;
}
return $value;
} | php | private static function getConvertedXmlValue($value)
{
$value = (string) $value; // convert from simplexml to string
// handle booleans specially
$lwr = strtolower($value);
if ($lwr === "false") {
$value = false;
} elseif ($lwr === "true") {
$value = true;
}
return $value;
} | [
"private",
"static",
"function",
"getConvertedXmlValue",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"// convert from simplexml to string",
"// handle booleans specially",
"$",
"lwr",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"lwr",
"===",
"\"false\"",
")",
"{",
"$",
"value",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"lwr",
"===",
"\"true\"",
")",
"{",
"$",
"value",
"=",
"true",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Process XML value, handling boolean, if appropriate.
@param object The simplexml value object.
@return mixed | [
"Process",
"XML",
"value",
"handling",
"boolean",
"if",
"appropriate",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelConvertConfTask.php#L270-L282 |
propelorm/Propel | generator/lib/task/PropelConvertConfTask.php | PropelConvertConfTask.getClassMap | protected function getClassMap()
{
$phpconfClassmap = array();
$generatorConfig = $this->getGeneratorConfig();
foreach ($this->getDataModels() as $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$classMap = array();
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
// -----------------------------------------------------
// Add TableMap class,
// Peer, Object & Query stub classes,
// and Peer, Object & Query base classes
// -----------------------------------------------------
// (this code is based on PropelOMTask)
foreach (array('tablemap', 'peerstub', 'objectstub', 'querystub', 'peer', 'object', 'query') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
// -----------------------------------------------------
// Add children classes for object and query,
// as well as base child query,
// for single tabel inheritance tables.
// -----------------------------------------------------
if ($col = $table->getChildrenColumn()) {
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
foreach (array('objectmultiextend', 'queryinheritance', 'queryinheritancestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
}
}
// -----------------------------------------------------
// Add base classes for alias tables (undocumented)
// -----------------------------------------------------
$baseClass = $table->getBaseClass();
if ($baseClass !== null) {
$className = ClassTools::classname($baseClass);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($baseClass);
$classMap[$className] = $classPath;
}
}
$basePeer = $table->getBasePeer();
if ($basePeer !== null) {
$className = ClassTools::classname($basePeer);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($basePeer);
$classMap[$className] = $classPath;
}
}
// ----------------------------------------------
// Add classes for interface
// ----------------------------------------------
if ($table->getInterface()) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
// ----------------------------------------------
// Add classes from old treeMode implementations
// ----------------------------------------------
if ($table->treeMode() == 'MaterializedPath') {
foreach (array('nodepeerstub', 'nodestub', 'nodepeer', 'node') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
if ($table->treeMode() == 'NestedSet') {
foreach (array('nestedset', 'nestedsetpeer') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
// ----------------------------------
// Add classes added by behaviors
// ----------------------------------
if ($table->hasAdditionalBuilders()) {
foreach ($table->getAdditionalBuilders() as $builderClass) {
$builder = new $builderClass($table);
$builder->setGeneratorConfig($generatorConfig);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
} // if (!$table->isReferenceOnly())
}
$phpconfClassmap = array_merge($phpconfClassmap, $classMap);
}
}
// sort the classmap by class name, to avoid discrepancies between OS
ksort($phpconfClassmap);
return $phpconfClassmap;
} | php | protected function getClassMap()
{
$phpconfClassmap = array();
$generatorConfig = $this->getGeneratorConfig();
foreach ($this->getDataModels() as $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$classMap = array();
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
// -----------------------------------------------------
// Add TableMap class,
// Peer, Object & Query stub classes,
// and Peer, Object & Query base classes
// -----------------------------------------------------
// (this code is based on PropelOMTask)
foreach (array('tablemap', 'peerstub', 'objectstub', 'querystub', 'peer', 'object', 'query') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
// -----------------------------------------------------
// Add children classes for object and query,
// as well as base child query,
// for single tabel inheritance tables.
// -----------------------------------------------------
if ($col = $table->getChildrenColumn()) {
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
foreach (array('objectmultiextend', 'queryinheritance', 'queryinheritancestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
}
}
// -----------------------------------------------------
// Add base classes for alias tables (undocumented)
// -----------------------------------------------------
$baseClass = $table->getBaseClass();
if ($baseClass !== null) {
$className = ClassTools::classname($baseClass);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($baseClass);
$classMap[$className] = $classPath;
}
}
$basePeer = $table->getBasePeer();
if ($basePeer !== null) {
$className = ClassTools::classname($basePeer);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($basePeer);
$classMap[$className] = $classPath;
}
}
// ----------------------------------------------
// Add classes for interface
// ----------------------------------------------
if ($table->getInterface()) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
// ----------------------------------------------
// Add classes from old treeMode implementations
// ----------------------------------------------
if ($table->treeMode() == 'MaterializedPath') {
foreach (array('nodepeerstub', 'nodestub', 'nodepeer', 'node') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
if ($table->treeMode() == 'NestedSet') {
foreach (array('nestedset', 'nestedsetpeer') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
// ----------------------------------
// Add classes added by behaviors
// ----------------------------------
if ($table->hasAdditionalBuilders()) {
foreach ($table->getAdditionalBuilders() as $builderClass) {
$builder = new $builderClass($table);
$builder->setGeneratorConfig($generatorConfig);
$classMap[$builder->getFullyQualifiedClassname()] = $builder->getClassFilePath();
}
}
} // if (!$table->isReferenceOnly())
}
$phpconfClassmap = array_merge($phpconfClassmap, $classMap);
}
}
// sort the classmap by class name, to avoid discrepancies between OS
ksort($phpconfClassmap);
return $phpconfClassmap;
} | [
"protected",
"function",
"getClassMap",
"(",
")",
"{",
"$",
"phpconfClassmap",
"=",
"array",
"(",
")",
";",
"$",
"generatorConfig",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDataModels",
"(",
")",
"as",
"$",
"dataModel",
")",
"{",
"foreach",
"(",
"$",
"dataModel",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"database",
")",
"{",
"$",
"classMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"database",
"->",
"getTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"$",
"table",
"->",
"isForReferenceOnly",
"(",
")",
")",
"{",
"// -----------------------------------------------------",
"// Add TableMap class,",
"// Peer, Object & Query stub classes,",
"// and Peer, Object & Query base classes",
"// -----------------------------------------------------",
"// (this code is based on PropelOMTask)",
"foreach",
"(",
"array",
"(",
"'tablemap'",
",",
"'peerstub'",
",",
"'objectstub'",
",",
"'querystub'",
",",
"'peer'",
",",
"'object'",
",",
"'query'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"classMap",
"[",
"$",
"builder",
"->",
"getFullyQualifiedClassname",
"(",
")",
"]",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"}",
"// -----------------------------------------------------",
"// Add children classes for object and query,",
"// as well as base child query,",
"// for single tabel inheritance tables.",
"// -----------------------------------------------------",
"if",
"(",
"$",
"col",
"=",
"$",
"table",
"->",
"getChildrenColumn",
"(",
")",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isEnumeratedClasses",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"col",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"foreach",
"(",
"array",
"(",
"'objectmultiextend'",
",",
"'queryinheritance'",
",",
"'queryinheritancestub'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"builder",
"->",
"setChild",
"(",
"$",
"child",
")",
";",
"$",
"classMap",
"[",
"$",
"builder",
"->",
"getFullyQualifiedClassname",
"(",
")",
"]",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"}",
"}",
"}",
"}",
"// -----------------------------------------------------",
"// Add base classes for alias tables (undocumented)",
"// -----------------------------------------------------",
"$",
"baseClass",
"=",
"$",
"table",
"->",
"getBaseClass",
"(",
")",
";",
"if",
"(",
"$",
"baseClass",
"!==",
"null",
")",
"{",
"$",
"className",
"=",
"ClassTools",
"::",
"classname",
"(",
"$",
"baseClass",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"classMap",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"classPath",
"=",
"ClassTools",
"::",
"getFilePath",
"(",
"$",
"baseClass",
")",
";",
"$",
"classMap",
"[",
"$",
"className",
"]",
"=",
"$",
"classPath",
";",
"}",
"}",
"$",
"basePeer",
"=",
"$",
"table",
"->",
"getBasePeer",
"(",
")",
";",
"if",
"(",
"$",
"basePeer",
"!==",
"null",
")",
"{",
"$",
"className",
"=",
"ClassTools",
"::",
"classname",
"(",
"$",
"basePeer",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"classMap",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"classPath",
"=",
"ClassTools",
"::",
"getFilePath",
"(",
"$",
"basePeer",
")",
";",
"$",
"classMap",
"[",
"$",
"className",
"]",
"=",
"$",
"classPath",
";",
"}",
"}",
"// ----------------------------------------------",
"// Add classes for interface",
"// ----------------------------------------------",
"if",
"(",
"$",
"table",
"->",
"getInterface",
"(",
")",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"'interface'",
")",
";",
"$",
"classMap",
"[",
"$",
"builder",
"->",
"getFullyQualifiedClassname",
"(",
")",
"]",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"}",
"// ----------------------------------------------",
"// Add classes from old treeMode implementations",
"// ----------------------------------------------",
"if",
"(",
"$",
"table",
"->",
"treeMode",
"(",
")",
"==",
"'MaterializedPath'",
")",
"{",
"foreach",
"(",
"array",
"(",
"'nodepeerstub'",
",",
"'nodestub'",
",",
"'nodepeer'",
",",
"'node'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"classMap",
"[",
"$",
"builder",
"->",
"getFullyQualifiedClassname",
"(",
")",
"]",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"table",
"->",
"treeMode",
"(",
")",
"==",
"'NestedSet'",
")",
"{",
"foreach",
"(",
"array",
"(",
"'nestedset'",
",",
"'nestedsetpeer'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"classMap",
"[",
"$",
"builder",
"->",
"getFullyQualifiedClassname",
"(",
")",
"]",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"}",
"}",
"// ----------------------------------",
"// Add classes added by behaviors",
"// ----------------------------------",
"if",
"(",
"$",
"table",
"->",
"hasAdditionalBuilders",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"getAdditionalBuilders",
"(",
")",
"as",
"$",
"builderClass",
")",
"{",
"$",
"builder",
"=",
"new",
"$",
"builderClass",
"(",
"$",
"table",
")",
";",
"$",
"builder",
"->",
"setGeneratorConfig",
"(",
"$",
"generatorConfig",
")",
";",
"$",
"classMap",
"[",
"$",
"builder",
"->",
"getFullyQualifiedClassname",
"(",
")",
"]",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"}",
"}",
"}",
"// if (!$table->isReferenceOnly())",
"}",
"$",
"phpconfClassmap",
"=",
"array_merge",
"(",
"$",
"phpconfClassmap",
",",
"$",
"classMap",
")",
";",
"}",
"}",
"// sort the classmap by class name, to avoid discrepancies between OS",
"ksort",
"(",
"$",
"phpconfClassmap",
")",
";",
"return",
"$",
"phpconfClassmap",
";",
"}"
] | Lists data model classes and builds an associative array className => classPath
To be used for autoloading
@return array | [
"Lists",
"data",
"model",
"classes",
"and",
"builds",
"an",
"associative",
"array",
"className",
"=",
">",
"classPath",
"To",
"be",
"used",
"for",
"autoloading"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelConvertConfTask.php#L290-L405 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.doDelete | public static function doDelete(Criteria $criteria, PropelPDO $con)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
//join are not supported with DELETE statement
if (count($criteria->getJoins())) {
throw new PropelException('Delete does not support join');
}
// Set up a list of required tables (one DELETE statement will
// be executed per table)
$tables = $criteria->getTablesColumns();
if (empty($tables)) {
throw new PropelException("Cannot delete from an empty Criteria");
}
$affectedRows = 0; // initialize this in case the next loop has no iterations.
foreach ($tables as $tableName => $columns) {
$whereClause = array();
$params = array();
$stmt = null;
try {
$sql = $db->getDeleteFromClause($criteria, $tableName);
foreach ($columns as $colName) {
$sb = "";
$criteria->getCriterion($colName)->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
$sql .= " WHERE " . implode(" AND ", $whereClause);
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
$affectedRows = $stmt->rowCount();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e);
}
} // for each table
return $affectedRows;
} | php | public static function doDelete(Criteria $criteria, PropelPDO $con)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
//join are not supported with DELETE statement
if (count($criteria->getJoins())) {
throw new PropelException('Delete does not support join');
}
// Set up a list of required tables (one DELETE statement will
// be executed per table)
$tables = $criteria->getTablesColumns();
if (empty($tables)) {
throw new PropelException("Cannot delete from an empty Criteria");
}
$affectedRows = 0; // initialize this in case the next loop has no iterations.
foreach ($tables as $tableName => $columns) {
$whereClause = array();
$params = array();
$stmt = null;
try {
$sql = $db->getDeleteFromClause($criteria, $tableName);
foreach ($columns as $colName) {
$sb = "";
$criteria->getCriterion($colName)->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
$sql .= " WHERE " . implode(" AND ", $whereClause);
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
$affectedRows = $stmt->rowCount();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute DELETE statement [%s]', $sql), $e);
}
} // for each table
return $affectedRows;
} | [
"public",
"static",
"function",
"doDelete",
"(",
"Criteria",
"$",
"criteria",
",",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"//join are not supported with DELETE statement",
"if",
"(",
"count",
"(",
"$",
"criteria",
"->",
"getJoins",
"(",
")",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Delete does not support join'",
")",
";",
"}",
"// Set up a list of required tables (one DELETE statement will",
"// be executed per table)",
"$",
"tables",
"=",
"$",
"criteria",
"->",
"getTablesColumns",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"tables",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot delete from an empty Criteria\"",
")",
";",
"}",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize this in case the next loop has no iterations.",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"columns",
")",
"{",
"$",
"whereClause",
"=",
"array",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"stmt",
"=",
"null",
";",
"try",
"{",
"$",
"sql",
"=",
"$",
"db",
"->",
"getDeleteFromClause",
"(",
"$",
"criteria",
",",
"$",
"tableName",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"colName",
")",
"{",
"$",
"sb",
"=",
"\"\"",
";",
"$",
"criteria",
"->",
"getCriterion",
"(",
"$",
"colName",
")",
"->",
"appendPsTo",
"(",
"$",
"sb",
",",
"$",
"params",
")",
";",
"$",
"whereClause",
"[",
"]",
"=",
"$",
"sb",
";",
"}",
"$",
"sql",
".=",
"\" WHERE \"",
".",
"implode",
"(",
"\" AND \"",
",",
"$",
"whereClause",
")",
";",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"db",
"->",
"bindValues",
"(",
"$",
"stmt",
",",
"$",
"params",
",",
"$",
"dbMap",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"$",
"affectedRows",
"=",
"$",
"stmt",
"->",
"rowCount",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute DELETE statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"}",
"// for each table",
"return",
"$",
"affectedRows",
";",
"}"
] | Method to perform deletes based on values and keys in a
Criteria.
@param Criteria $criteria The criteria to use.
@param PropelPDO $con A PropelPDO connection object.
@return int The number of rows affected by last statement execution. For most
uses there is only one delete statement executed, so this number
will correspond to the number of rows affected by the call to this
method. Note that the return value does require that this information
is returned (supported) by the PDO driver.
@throws PropelException | [
"Method",
"to",
"perform",
"deletes",
"based",
"on",
"values",
"and",
"keys",
"in",
"a",
"Criteria",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L110-L155 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.doDeleteAll | public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = null)
{
try {
$db = Propel::getDB($databaseName);
if ($db->useQuoteIdentifier()) {
$tableName = $db->quoteIdentifierTable($tableName);
}
$sql = "DELETE FROM " . $tableName;
$stmt = $con->prepare($sql);
$stmt->execute();
return $stmt->rowCount();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute DELETE ALL statement [%s]', $sql), $e);
}
} | php | public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = null)
{
try {
$db = Propel::getDB($databaseName);
if ($db->useQuoteIdentifier()) {
$tableName = $db->quoteIdentifierTable($tableName);
}
$sql = "DELETE FROM " . $tableName;
$stmt = $con->prepare($sql);
$stmt->execute();
return $stmt->rowCount();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute DELETE ALL statement [%s]', $sql), $e);
}
} | [
"public",
"static",
"function",
"doDeleteAll",
"(",
"$",
"tableName",
",",
"PropelPDO",
"$",
"con",
",",
"$",
"databaseName",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"databaseName",
")",
";",
"if",
"(",
"$",
"db",
"->",
"useQuoteIdentifier",
"(",
")",
")",
"{",
"$",
"tableName",
"=",
"$",
"db",
"->",
"quoteIdentifierTable",
"(",
"$",
"tableName",
")",
";",
"}",
"$",
"sql",
"=",
"\"DELETE FROM \"",
".",
"$",
"tableName",
";",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"stmt",
"->",
"rowCount",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute DELETE ALL statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Method to deletes all contents of specified table.
This method is invoked from generated Peer classes like this:
<code>
public static function doDeleteAll($con = null)
{
if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME);
BasePeer::doDeleteAll(self::TABLE_NAME, $con, self::DATABASE_NAME);
}
</code>
@param string $tableName The name of the table to empty.
@param PropelPDO $con A PropelPDO connection object.
@param string $databaseName the name of the database.
@return int The number of rows affected by the statement. Note
that the return value does require that this information
is returned (supported) by the Propel db driver.
@throws PropelException - wrapping SQLException caught from statement execution. | [
"Method",
"to",
"deletes",
"all",
"contents",
"of",
"specified",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L178-L194 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.doSelect | public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$db = Propel::getDB($criteria->getDbName());
$stmt = null;
if ($con === null) {
$con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
}
try {
$params = array();
$sql = self::createSelectSql($criteria, $params);
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
} catch (Exception $e) {
if ($stmt) {
$stmt = null; // close
}
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
}
return $stmt;
} | php | public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$db = Propel::getDB($criteria->getDbName());
$stmt = null;
if ($con === null) {
$con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
}
try {
$params = array();
$sql = self::createSelectSql($criteria, $params);
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
} catch (Exception $e) {
if ($stmt) {
$stmt = null; // close
}
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
}
return $stmt;
} | [
"public",
"static",
"function",
"doSelect",
"(",
"Criteria",
"$",
"criteria",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"stmt",
"=",
"null",
";",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"try",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"sql",
"=",
"self",
"::",
"createSelectSql",
"(",
"$",
"criteria",
",",
"$",
"params",
")",
";",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"db",
"->",
"bindValues",
"(",
"$",
"stmt",
",",
"$",
"params",
",",
"$",
"dbMap",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"stmt",
")",
"{",
"$",
"stmt",
"=",
"null",
";",
"// close",
"}",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute SELECT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"stmt",
";",
"}"
] | Executes query build by createSelectSql() and returns the resultset statement.
@param Criteria $criteria A Criteria.
@param PropelPDO $con A PropelPDO connection to use.
@return PDOStatement The resultset.
@throws PropelException
@see createSelectSql() | [
"Executes",
"query",
"build",
"by",
"createSelectSql",
"()",
"and",
"returns",
"the",
"resultset",
"statement",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L467-L496 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.doCount | public static function doCount(Criteria $criteria, PropelPDO $con = null)
{
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$db = Propel::getDB($criteria->getDbName());
if ($con === null) {
$con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
}
$stmt = null;
$needsComplexCount = $criteria->getGroupByColumns()
|| $criteria->getOffset()
|| $criteria->getLimit()
|| $criteria->getHaving()
|| in_array(Criteria::DISTINCT, $criteria->getSelectModifiers());
try {
$params = array();
if ($needsComplexCount) {
if (self::needsSelectAliases($criteria)) {
if ($criteria->getHaving()) {
throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part');
}
$db->turnSelectColumnsToAliases($criteria);
}
$selectSql = self::createSelectSql($criteria, $params);
$sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
} else {
// Replace SELECT columns with COUNT(*)
$criteria->clearSelectColumns()->addSelectColumn('COUNT(*)');
$sql = self::createSelectSql($criteria, $params);
}
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
} catch (Exception $e) {
if ($stmt !== null) {
$stmt = null;
}
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e);
}
return $stmt;
} | php | public static function doCount(Criteria $criteria, PropelPDO $con = null)
{
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$db = Propel::getDB($criteria->getDbName());
if ($con === null) {
$con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
}
$stmt = null;
$needsComplexCount = $criteria->getGroupByColumns()
|| $criteria->getOffset()
|| $criteria->getLimit()
|| $criteria->getHaving()
|| in_array(Criteria::DISTINCT, $criteria->getSelectModifiers());
try {
$params = array();
if ($needsComplexCount) {
if (self::needsSelectAliases($criteria)) {
if ($criteria->getHaving()) {
throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part');
}
$db->turnSelectColumnsToAliases($criteria);
}
$selectSql = self::createSelectSql($criteria, $params);
$sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
} else {
// Replace SELECT columns with COUNT(*)
$criteria->clearSelectColumns()->addSelectColumn('COUNT(*)');
$sql = self::createSelectSql($criteria, $params);
}
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
} catch (Exception $e) {
if ($stmt !== null) {
$stmt = null;
}
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e);
}
return $stmt;
} | [
"public",
"static",
"function",
"doCount",
"(",
"Criteria",
"$",
"criteria",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"stmt",
"=",
"null",
";",
"$",
"needsComplexCount",
"=",
"$",
"criteria",
"->",
"getGroupByColumns",
"(",
")",
"||",
"$",
"criteria",
"->",
"getOffset",
"(",
")",
"||",
"$",
"criteria",
"->",
"getLimit",
"(",
")",
"||",
"$",
"criteria",
"->",
"getHaving",
"(",
")",
"||",
"in_array",
"(",
"Criteria",
"::",
"DISTINCT",
",",
"$",
"criteria",
"->",
"getSelectModifiers",
"(",
")",
")",
";",
"try",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"needsComplexCount",
")",
"{",
"if",
"(",
"self",
"::",
"needsSelectAliases",
"(",
"$",
"criteria",
")",
")",
"{",
"if",
"(",
"$",
"criteria",
"->",
"getHaving",
"(",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part'",
")",
";",
"}",
"$",
"db",
"->",
"turnSelectColumnsToAliases",
"(",
"$",
"criteria",
")",
";",
"}",
"$",
"selectSql",
"=",
"self",
"::",
"createSelectSql",
"(",
"$",
"criteria",
",",
"$",
"params",
")",
";",
"$",
"sql",
"=",
"'SELECT COUNT(*) FROM ('",
".",
"$",
"selectSql",
".",
"') propelmatch4cnt'",
";",
"}",
"else",
"{",
"// Replace SELECT columns with COUNT(*)",
"$",
"criteria",
"->",
"clearSelectColumns",
"(",
")",
"->",
"addSelectColumn",
"(",
"'COUNT(*)'",
")",
";",
"$",
"sql",
"=",
"self",
"::",
"createSelectSql",
"(",
"$",
"criteria",
",",
"$",
"params",
")",
";",
"}",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"db",
"->",
"bindValues",
"(",
"$",
"stmt",
",",
"$",
"params",
",",
"$",
"dbMap",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"stmt",
"!==",
"null",
")",
"{",
"$",
"stmt",
"=",
"null",
";",
"}",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute COUNT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"stmt",
";",
"}"
] | Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a
sub-select of the SQL created by createSelectSql() and returns the statement.
@param Criteria $criteria A Criteria.
@param PropelPDO $con A PropelPDO connection to use.
@return PDOStatement The resultset statement.
@throws PropelException
@see createSelectSql() | [
"Executes",
"a",
"COUNT",
"query",
"using",
"either",
"a",
"simple",
"SQL",
"rewrite",
"or",
"for",
"more",
"complex",
"queries",
"a",
"sub",
"-",
"select",
"of",
"the",
"SQL",
"created",
"by",
"createSelectSql",
"()",
"and",
"returns",
"the",
"statement",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L509-L557 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.doValidate | public static function doValidate($dbName, $tableName, $columns)
{
$dbMap = Propel::getDatabaseMap($dbName);
$tableMap = $dbMap->getTable($tableName);
$failureMap = array(); // map of ValidationFailed objects
foreach ($columns as $colName => $colValue) {
if ($tableMap->hasColumn($colName)) {
$col = $tableMap->getColumn($colName);
foreach ($col->getValidators() as $validatorMap) {
$validator = BasePeer::getValidator($validatorMap->getClass());
if ($validator && ($col->isNotNull() || $colValue !== null) && $validator->isValid($validatorMap, $colValue) === false) {
// for now we do one ValidationFailed per column, not per rule
if (!isset($failureMap[$colName])) {
$failureMap[$colName] = new ValidationFailed($colName, $validatorMap->getMessage(), $validator);
break;
}
}
}
}
}
return (!empty($failureMap) ? $failureMap : true);
} | php | public static function doValidate($dbName, $tableName, $columns)
{
$dbMap = Propel::getDatabaseMap($dbName);
$tableMap = $dbMap->getTable($tableName);
$failureMap = array(); // map of ValidationFailed objects
foreach ($columns as $colName => $colValue) {
if ($tableMap->hasColumn($colName)) {
$col = $tableMap->getColumn($colName);
foreach ($col->getValidators() as $validatorMap) {
$validator = BasePeer::getValidator($validatorMap->getClass());
if ($validator && ($col->isNotNull() || $colValue !== null) && $validator->isValid($validatorMap, $colValue) === false) {
// for now we do one ValidationFailed per column, not per rule
if (!isset($failureMap[$colName])) {
$failureMap[$colName] = new ValidationFailed($colName, $validatorMap->getMessage(), $validator);
break;
}
}
}
}
}
return (!empty($failureMap) ? $failureMap : true);
} | [
"public",
"static",
"function",
"doValidate",
"(",
"$",
"dbName",
",",
"$",
"tableName",
",",
"$",
"columns",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"dbName",
")",
";",
"$",
"tableMap",
"=",
"$",
"dbMap",
"->",
"getTable",
"(",
"$",
"tableName",
")",
";",
"$",
"failureMap",
"=",
"array",
"(",
")",
";",
"// map of ValidationFailed objects",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"colName",
"=>",
"$",
"colValue",
")",
"{",
"if",
"(",
"$",
"tableMap",
"->",
"hasColumn",
"(",
"$",
"colName",
")",
")",
"{",
"$",
"col",
"=",
"$",
"tableMap",
"->",
"getColumn",
"(",
"$",
"colName",
")",
";",
"foreach",
"(",
"$",
"col",
"->",
"getValidators",
"(",
")",
"as",
"$",
"validatorMap",
")",
"{",
"$",
"validator",
"=",
"BasePeer",
"::",
"getValidator",
"(",
"$",
"validatorMap",
"->",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"$",
"validator",
"&&",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
"||",
"$",
"colValue",
"!==",
"null",
")",
"&&",
"$",
"validator",
"->",
"isValid",
"(",
"$",
"validatorMap",
",",
"$",
"colValue",
")",
"===",
"false",
")",
"{",
"// for now we do one ValidationFailed per column, not per rule",
"if",
"(",
"!",
"isset",
"(",
"$",
"failureMap",
"[",
"$",
"colName",
"]",
")",
")",
"{",
"$",
"failureMap",
"[",
"$",
"colName",
"]",
"=",
"new",
"ValidationFailed",
"(",
"$",
"colName",
",",
"$",
"validatorMap",
"->",
"getMessage",
"(",
")",
",",
"$",
"validator",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"(",
"!",
"empty",
"(",
"$",
"failureMap",
")",
"?",
"$",
"failureMap",
":",
"true",
")",
";",
"}"
] | Applies any validators that were defined in the schema to the specified columns.
@param string $dbName The name of the database
@param string $tableName The name of the table
@param array $columns Array of column names as key and column values as value.
@return ValidationFailed[]|bool A list of validation failures, true if valid. | [
"Applies",
"any",
"validators",
"that",
"were",
"defined",
"in",
"the",
"schema",
"to",
"the",
"specified",
"columns",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L568-L590 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.getPrimaryKey | private static function getPrimaryKey(Criteria $criteria)
{
// Assume all the keys are for the same table.
$keys = $criteria->keys();
$key = $keys[0];
$table = $criteria->getTableName($key);
$pk = null;
if (!empty($table)) {
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$pks = $dbMap->getTable($table)->getPrimaryKeys();
if (!empty($pks)) {
$pk = array_shift($pks);
}
}
return $pk;
} | php | private static function getPrimaryKey(Criteria $criteria)
{
// Assume all the keys are for the same table.
$keys = $criteria->keys();
$key = $keys[0];
$table = $criteria->getTableName($key);
$pk = null;
if (!empty($table)) {
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$pks = $dbMap->getTable($table)->getPrimaryKeys();
if (!empty($pks)) {
$pk = array_shift($pks);
}
}
return $pk;
} | [
"private",
"static",
"function",
"getPrimaryKey",
"(",
"Criteria",
"$",
"criteria",
")",
"{",
"// Assume all the keys are for the same table.",
"$",
"keys",
"=",
"$",
"criteria",
"->",
"keys",
"(",
")",
";",
"$",
"key",
"=",
"$",
"keys",
"[",
"0",
"]",
";",
"$",
"table",
"=",
"$",
"criteria",
"->",
"getTableName",
"(",
"$",
"key",
")",
";",
"$",
"pk",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"table",
")",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"pks",
"=",
"$",
"dbMap",
"->",
"getTable",
"(",
"$",
"table",
")",
"->",
"getPrimaryKeys",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pks",
")",
")",
"{",
"$",
"pk",
"=",
"array_shift",
"(",
"$",
"pks",
")",
";",
"}",
"}",
"return",
"$",
"pk",
";",
"}"
] | Helper method which returns the primary key contained
in the given Criteria object.
@param Criteria $criteria A Criteria.
@return ColumnMap If the Criteria object contains a primary key, or null if it doesn't.
@throws PropelException | [
"Helper",
"method",
"which",
"returns",
"the",
"primary",
"key",
"contained",
"in",
"the",
"given",
"Criteria",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L601-L621 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.needsSelectAliases | public static function needsSelectAliases(Criteria $criteria)
{
$columnNames = array();
foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) {
if ($pos = strrpos($fullyQualifiedColumnName, '.')) {
$columnName = substr($fullyQualifiedColumnName, $pos);
if (isset($columnNames[$columnName])) {
// more than one column with the same name, so aliasing is required
return true;
}
$columnNames[$columnName] = true;
}
}
return false;
} | php | public static function needsSelectAliases(Criteria $criteria)
{
$columnNames = array();
foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) {
if ($pos = strrpos($fullyQualifiedColumnName, '.')) {
$columnName = substr($fullyQualifiedColumnName, $pos);
if (isset($columnNames[$columnName])) {
// more than one column with the same name, so aliasing is required
return true;
}
$columnNames[$columnName] = true;
}
}
return false;
} | [
"public",
"static",
"function",
"needsSelectAliases",
"(",
"Criteria",
"$",
"criteria",
")",
"{",
"$",
"columnNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criteria",
"->",
"getSelectColumns",
"(",
")",
"as",
"$",
"fullyQualifiedColumnName",
")",
"{",
"if",
"(",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"fullyQualifiedColumnName",
",",
"'.'",
")",
")",
"{",
"$",
"columnName",
"=",
"substr",
"(",
"$",
"fullyQualifiedColumnName",
",",
"$",
"pos",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"columnNames",
"[",
"$",
"columnName",
"]",
")",
")",
"{",
"// more than one column with the same name, so aliasing is required",
"return",
"true",
";",
"}",
"$",
"columnNames",
"[",
"$",
"columnName",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks whether the Criteria needs to use column aliasing
This is implemented in a service class rather than in Criteria itself
in order to avoid doing the tests when it's not necessary (e.g. for SELECTs) | [
"Checks",
"whether",
"the",
"Criteria",
"needs",
"to",
"use",
"column",
"aliasing",
"This",
"is",
"implemented",
"in",
"a",
"service",
"class",
"rather",
"than",
"in",
"Criteria",
"itself",
"in",
"order",
"to",
"avoid",
"doing",
"the",
"tests",
"when",
"it",
"s",
"not",
"necessary",
"(",
"e",
".",
"g",
".",
"for",
"SELECTs",
")"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L628-L643 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.createSelectSql | public static function createSelectSql(Criteria $criteria, &$params)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$fromClause = array();
$joinClause = array();
$joinTables = array();
$whereClause = array();
$orderByClause = array();
$orderBy = $criteria->getOrderByColumns();
$groupBy = $criteria->getGroupByColumns();
$ignoreCase = $criteria->isIgnoreCase();
// get the first part of the SQL statement, the SELECT part
$selectSql = $db->createSelectSqlPart($criteria, $fromClause);
// Handle joins
// joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause.
// joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause
foreach ($criteria->getJoins() as $join) {
$join->setDB($db);
// add 'em to the queues..
if (!$fromClause) {
$fromClause[] = $join->getLeftTableWithAlias();
}
$joinTables[] = $join->getRightTableWithAlias();
$joinClause[] = $join->getClause($params);
}
// add the criteria to WHERE clause
// this will also add the table names to the FROM clause if they are not already
// included via a LEFT JOIN
foreach ($criteria->keys() as $key) {
$criterion = $criteria->getCriterion($key);
$table = null;
foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
$tableName = $attachedCriterion->getTable();
$table = $criteria->getTableForAlias($tableName);
if ($table !== null) {
$fromClause[] = $table . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
$table = $tableName;
}
if (($criteria->isIgnoreCase() || $attachedCriterion->isIgnoreCase())
&& $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) {
$attachedCriterion->setIgnoreCase(true);
}
}
$criterion->setDB($db);
$sb = '';
$criterion->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
// Unique from clause elements
$fromClause = array_unique($fromClause);
$fromClause = array_diff($fromClause, array(''));
// tables should not exist in both the from and join clauses
if ($joinTables && $fromClause) {
foreach ($fromClause as $fi => $ftable) {
if (in_array($ftable, $joinTables)) {
unset($fromClause[$fi]);
}
}
}
// Add the GROUP BY columns
$groupByClause = $groupBy;
$having = $criteria->getHaving();
$havingString = null;
if ($having !== null) {
$sb = '';
$having->appendPsTo($sb, $params);
$havingString = $sb;
}
if (!empty($orderBy)) {
foreach ($orderBy as $orderByColumn) {
// Add function expression as-is.
if (strpos($orderByColumn, '(') !== false) {
$orderByClause[] = $orderByColumn;
continue;
}
// Split orderByColumn (i.e. "table.column DESC")
$dotPos = strrpos($orderByColumn, '.');
if ($dotPos !== false) {
$tableName = substr($orderByColumn, 0, $dotPos);
$columnName = substr($orderByColumn, $dotPos + 1);
} else {
$tableName = '';
$columnName = $orderByColumn;
}
$spacePos = strpos($columnName, ' ');
if ($spacePos !== false) {
$direction = substr($columnName, $spacePos);
$columnName = substr($columnName, 0, $spacePos);
} else {
$direction = '';
}
$tableAlias = $tableName;
if ($aliasTableName = $criteria->getTableForAlias($tableName)) {
$tableName = $aliasTableName;
}
$columnAlias = $columnName;
if ($asColumnName = $criteria->getColumnForAs($columnName)) {
$columnName = $asColumnName;
}
$column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null;
if ($criteria->isIgnoreCase() && $column && $column->isText()) {
$ignoreCaseColumn = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias");
$orderByClause[] = $ignoreCaseColumn . $direction;
$selectSql .= ', ' . $ignoreCaseColumn;
} else {
$orderByClause[] = $orderByColumn;
}
}
}
if (empty($fromClause) && $criteria->getPrimaryTableName()) {
$fromClause[] = $criteria->getPrimaryTableName();
}
// tables should not exist as alias of subQuery
if ($criteria->hasSelectQueries()) {
foreach ($fromClause as $key => $ftable) {
if (strpos($ftable, ' ') !== false) {
list($realtable, $tableName) = explode(' ', $ftable);
} else {
$tableName = $ftable;
}
if ($criteria->hasSelectQuery($tableName)) {
unset($fromClause[$key]);
}
}
}
// from / join tables quoted if it is necessary
if ($db->useQuoteIdentifier()) {
$fromClause = array_map(array($db, 'quoteIdentifierTable'), $fromClause);
$joinClause = $joinClause ? $joinClause : array_map(array($db, 'quoteIdentifierTable'), $joinClause);
}
// add subQuery to From after adding quotes
foreach ($criteria->getSelectQueries() as $subQueryAlias => $subQueryCriteria) {
$fromClause[] = '(' . BasePeer::createSelectSql($subQueryCriteria, $params) . ') AS ' . $subQueryAlias;
}
// build from-clause
$from = '';
if (!empty($joinClause) && count($fromClause) > 1) {
$from .= implode(" CROSS JOIN ", $fromClause);
} else {
$from .= implode(", ", $fromClause);
}
$from .= $joinClause ? ' ' . implode(' ', $joinClause) : '';
// Build the SQL from the arrays we compiled
$sql = $selectSql
." FROM " . $from
.($whereClause ? " WHERE ".implode(" AND ", $whereClause) : "")
.($groupByClause ? " GROUP BY ".implode(",", $groupByClause) : "")
.($havingString ? " HAVING ".$havingString : "")
.($orderByClause ? " ORDER BY ".implode(",", $orderByClause) : "");
// APPLY OFFSET & LIMIT to the query.
if ($criteria->getLimit() || $criteria->getOffset()) {
$db->applyLimit($sql, $criteria->getOffset(), $criteria->getLimit(), $criteria);
}
return $sql;
} | php | public static function createSelectSql(Criteria $criteria, &$params)
{
$db = Propel::getDB($criteria->getDbName());
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$fromClause = array();
$joinClause = array();
$joinTables = array();
$whereClause = array();
$orderByClause = array();
$orderBy = $criteria->getOrderByColumns();
$groupBy = $criteria->getGroupByColumns();
$ignoreCase = $criteria->isIgnoreCase();
// get the first part of the SQL statement, the SELECT part
$selectSql = $db->createSelectSqlPart($criteria, $fromClause);
// Handle joins
// joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause.
// joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause
foreach ($criteria->getJoins() as $join) {
$join->setDB($db);
// add 'em to the queues..
if (!$fromClause) {
$fromClause[] = $join->getLeftTableWithAlias();
}
$joinTables[] = $join->getRightTableWithAlias();
$joinClause[] = $join->getClause($params);
}
// add the criteria to WHERE clause
// this will also add the table names to the FROM clause if they are not already
// included via a LEFT JOIN
foreach ($criteria->keys() as $key) {
$criterion = $criteria->getCriterion($key);
$table = null;
foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
$tableName = $attachedCriterion->getTable();
$table = $criteria->getTableForAlias($tableName);
if ($table !== null) {
$fromClause[] = $table . ' ' . $tableName;
} else {
$fromClause[] = $tableName;
$table = $tableName;
}
if (($criteria->isIgnoreCase() || $attachedCriterion->isIgnoreCase())
&& $dbMap->getTable($table)->getColumn($attachedCriterion->getColumn())->isText()) {
$attachedCriterion->setIgnoreCase(true);
}
}
$criterion->setDB($db);
$sb = '';
$criterion->appendPsTo($sb, $params);
$whereClause[] = $sb;
}
// Unique from clause elements
$fromClause = array_unique($fromClause);
$fromClause = array_diff($fromClause, array(''));
// tables should not exist in both the from and join clauses
if ($joinTables && $fromClause) {
foreach ($fromClause as $fi => $ftable) {
if (in_array($ftable, $joinTables)) {
unset($fromClause[$fi]);
}
}
}
// Add the GROUP BY columns
$groupByClause = $groupBy;
$having = $criteria->getHaving();
$havingString = null;
if ($having !== null) {
$sb = '';
$having->appendPsTo($sb, $params);
$havingString = $sb;
}
if (!empty($orderBy)) {
foreach ($orderBy as $orderByColumn) {
// Add function expression as-is.
if (strpos($orderByColumn, '(') !== false) {
$orderByClause[] = $orderByColumn;
continue;
}
// Split orderByColumn (i.e. "table.column DESC")
$dotPos = strrpos($orderByColumn, '.');
if ($dotPos !== false) {
$tableName = substr($orderByColumn, 0, $dotPos);
$columnName = substr($orderByColumn, $dotPos + 1);
} else {
$tableName = '';
$columnName = $orderByColumn;
}
$spacePos = strpos($columnName, ' ');
if ($spacePos !== false) {
$direction = substr($columnName, $spacePos);
$columnName = substr($columnName, 0, $spacePos);
} else {
$direction = '';
}
$tableAlias = $tableName;
if ($aliasTableName = $criteria->getTableForAlias($tableName)) {
$tableName = $aliasTableName;
}
$columnAlias = $columnName;
if ($asColumnName = $criteria->getColumnForAs($columnName)) {
$columnName = $asColumnName;
}
$column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null;
if ($criteria->isIgnoreCase() && $column && $column->isText()) {
$ignoreCaseColumn = $db->ignoreCaseInOrderBy("$tableAlias.$columnAlias");
$orderByClause[] = $ignoreCaseColumn . $direction;
$selectSql .= ', ' . $ignoreCaseColumn;
} else {
$orderByClause[] = $orderByColumn;
}
}
}
if (empty($fromClause) && $criteria->getPrimaryTableName()) {
$fromClause[] = $criteria->getPrimaryTableName();
}
// tables should not exist as alias of subQuery
if ($criteria->hasSelectQueries()) {
foreach ($fromClause as $key => $ftable) {
if (strpos($ftable, ' ') !== false) {
list($realtable, $tableName) = explode(' ', $ftable);
} else {
$tableName = $ftable;
}
if ($criteria->hasSelectQuery($tableName)) {
unset($fromClause[$key]);
}
}
}
// from / join tables quoted if it is necessary
if ($db->useQuoteIdentifier()) {
$fromClause = array_map(array($db, 'quoteIdentifierTable'), $fromClause);
$joinClause = $joinClause ? $joinClause : array_map(array($db, 'quoteIdentifierTable'), $joinClause);
}
// add subQuery to From after adding quotes
foreach ($criteria->getSelectQueries() as $subQueryAlias => $subQueryCriteria) {
$fromClause[] = '(' . BasePeer::createSelectSql($subQueryCriteria, $params) . ') AS ' . $subQueryAlias;
}
// build from-clause
$from = '';
if (!empty($joinClause) && count($fromClause) > 1) {
$from .= implode(" CROSS JOIN ", $fromClause);
} else {
$from .= implode(", ", $fromClause);
}
$from .= $joinClause ? ' ' . implode(' ', $joinClause) : '';
// Build the SQL from the arrays we compiled
$sql = $selectSql
." FROM " . $from
.($whereClause ? " WHERE ".implode(" AND ", $whereClause) : "")
.($groupByClause ? " GROUP BY ".implode(",", $groupByClause) : "")
.($havingString ? " HAVING ".$havingString : "")
.($orderByClause ? " ORDER BY ".implode(",", $orderByClause) : "");
// APPLY OFFSET & LIMIT to the query.
if ($criteria->getLimit() || $criteria->getOffset()) {
$db->applyLimit($sql, $criteria->getOffset(), $criteria->getLimit(), $criteria);
}
return $sql;
} | [
"public",
"static",
"function",
"createSelectSql",
"(",
"Criteria",
"$",
"criteria",
",",
"&",
"$",
"params",
")",
"{",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"fromClause",
"=",
"array",
"(",
")",
";",
"$",
"joinClause",
"=",
"array",
"(",
")",
";",
"$",
"joinTables",
"=",
"array",
"(",
")",
";",
"$",
"whereClause",
"=",
"array",
"(",
")",
";",
"$",
"orderByClause",
"=",
"array",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"criteria",
"->",
"getOrderByColumns",
"(",
")",
";",
"$",
"groupBy",
"=",
"$",
"criteria",
"->",
"getGroupByColumns",
"(",
")",
";",
"$",
"ignoreCase",
"=",
"$",
"criteria",
"->",
"isIgnoreCase",
"(",
")",
";",
"// get the first part of the SQL statement, the SELECT part",
"$",
"selectSql",
"=",
"$",
"db",
"->",
"createSelectSqlPart",
"(",
"$",
"criteria",
",",
"$",
"fromClause",
")",
";",
"// Handle joins",
"// joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause.",
"// joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause",
"foreach",
"(",
"$",
"criteria",
"->",
"getJoins",
"(",
")",
"as",
"$",
"join",
")",
"{",
"$",
"join",
"->",
"setDB",
"(",
"$",
"db",
")",
";",
"// add 'em to the queues..",
"if",
"(",
"!",
"$",
"fromClause",
")",
"{",
"$",
"fromClause",
"[",
"]",
"=",
"$",
"join",
"->",
"getLeftTableWithAlias",
"(",
")",
";",
"}",
"$",
"joinTables",
"[",
"]",
"=",
"$",
"join",
"->",
"getRightTableWithAlias",
"(",
")",
";",
"$",
"joinClause",
"[",
"]",
"=",
"$",
"join",
"->",
"getClause",
"(",
"$",
"params",
")",
";",
"}",
"// add the criteria to WHERE clause",
"// this will also add the table names to the FROM clause if they are not already",
"// included via a LEFT JOIN",
"foreach",
"(",
"$",
"criteria",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"criterion",
"=",
"$",
"criteria",
"->",
"getCriterion",
"(",
"$",
"key",
")",
";",
"$",
"table",
"=",
"null",
";",
"foreach",
"(",
"$",
"criterion",
"->",
"getAttachedCriterion",
"(",
")",
"as",
"$",
"attachedCriterion",
")",
"{",
"$",
"tableName",
"=",
"$",
"attachedCriterion",
"->",
"getTable",
"(",
")",
";",
"$",
"table",
"=",
"$",
"criteria",
"->",
"getTableForAlias",
"(",
"$",
"tableName",
")",
";",
"if",
"(",
"$",
"table",
"!==",
"null",
")",
"{",
"$",
"fromClause",
"[",
"]",
"=",
"$",
"table",
".",
"' '",
".",
"$",
"tableName",
";",
"}",
"else",
"{",
"$",
"fromClause",
"[",
"]",
"=",
"$",
"tableName",
";",
"$",
"table",
"=",
"$",
"tableName",
";",
"}",
"if",
"(",
"(",
"$",
"criteria",
"->",
"isIgnoreCase",
"(",
")",
"||",
"$",
"attachedCriterion",
"->",
"isIgnoreCase",
"(",
")",
")",
"&&",
"$",
"dbMap",
"->",
"getTable",
"(",
"$",
"table",
")",
"->",
"getColumn",
"(",
"$",
"attachedCriterion",
"->",
"getColumn",
"(",
")",
")",
"->",
"isText",
"(",
")",
")",
"{",
"$",
"attachedCriterion",
"->",
"setIgnoreCase",
"(",
"true",
")",
";",
"}",
"}",
"$",
"criterion",
"->",
"setDB",
"(",
"$",
"db",
")",
";",
"$",
"sb",
"=",
"''",
";",
"$",
"criterion",
"->",
"appendPsTo",
"(",
"$",
"sb",
",",
"$",
"params",
")",
";",
"$",
"whereClause",
"[",
"]",
"=",
"$",
"sb",
";",
"}",
"// Unique from clause elements",
"$",
"fromClause",
"=",
"array_unique",
"(",
"$",
"fromClause",
")",
";",
"$",
"fromClause",
"=",
"array_diff",
"(",
"$",
"fromClause",
",",
"array",
"(",
"''",
")",
")",
";",
"// tables should not exist in both the from and join clauses",
"if",
"(",
"$",
"joinTables",
"&&",
"$",
"fromClause",
")",
"{",
"foreach",
"(",
"$",
"fromClause",
"as",
"$",
"fi",
"=>",
"$",
"ftable",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"ftable",
",",
"$",
"joinTables",
")",
")",
"{",
"unset",
"(",
"$",
"fromClause",
"[",
"$",
"fi",
"]",
")",
";",
"}",
"}",
"}",
"// Add the GROUP BY columns",
"$",
"groupByClause",
"=",
"$",
"groupBy",
";",
"$",
"having",
"=",
"$",
"criteria",
"->",
"getHaving",
"(",
")",
";",
"$",
"havingString",
"=",
"null",
";",
"if",
"(",
"$",
"having",
"!==",
"null",
")",
"{",
"$",
"sb",
"=",
"''",
";",
"$",
"having",
"->",
"appendPsTo",
"(",
"$",
"sb",
",",
"$",
"params",
")",
";",
"$",
"havingString",
"=",
"$",
"sb",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"orderBy",
")",
")",
"{",
"foreach",
"(",
"$",
"orderBy",
"as",
"$",
"orderByColumn",
")",
"{",
"// Add function expression as-is.",
"if",
"(",
"strpos",
"(",
"$",
"orderByColumn",
",",
"'('",
")",
"!==",
"false",
")",
"{",
"$",
"orderByClause",
"[",
"]",
"=",
"$",
"orderByColumn",
";",
"continue",
";",
"}",
"// Split orderByColumn (i.e. \"table.column DESC\")",
"$",
"dotPos",
"=",
"strrpos",
"(",
"$",
"orderByColumn",
",",
"'.'",
")",
";",
"if",
"(",
"$",
"dotPos",
"!==",
"false",
")",
"{",
"$",
"tableName",
"=",
"substr",
"(",
"$",
"orderByColumn",
",",
"0",
",",
"$",
"dotPos",
")",
";",
"$",
"columnName",
"=",
"substr",
"(",
"$",
"orderByColumn",
",",
"$",
"dotPos",
"+",
"1",
")",
";",
"}",
"else",
"{",
"$",
"tableName",
"=",
"''",
";",
"$",
"columnName",
"=",
"$",
"orderByColumn",
";",
"}",
"$",
"spacePos",
"=",
"strpos",
"(",
"$",
"columnName",
",",
"' '",
")",
";",
"if",
"(",
"$",
"spacePos",
"!==",
"false",
")",
"{",
"$",
"direction",
"=",
"substr",
"(",
"$",
"columnName",
",",
"$",
"spacePos",
")",
";",
"$",
"columnName",
"=",
"substr",
"(",
"$",
"columnName",
",",
"0",
",",
"$",
"spacePos",
")",
";",
"}",
"else",
"{",
"$",
"direction",
"=",
"''",
";",
"}",
"$",
"tableAlias",
"=",
"$",
"tableName",
";",
"if",
"(",
"$",
"aliasTableName",
"=",
"$",
"criteria",
"->",
"getTableForAlias",
"(",
"$",
"tableName",
")",
")",
"{",
"$",
"tableName",
"=",
"$",
"aliasTableName",
";",
"}",
"$",
"columnAlias",
"=",
"$",
"columnName",
";",
"if",
"(",
"$",
"asColumnName",
"=",
"$",
"criteria",
"->",
"getColumnForAs",
"(",
"$",
"columnName",
")",
")",
"{",
"$",
"columnName",
"=",
"$",
"asColumnName",
";",
"}",
"$",
"column",
"=",
"$",
"tableName",
"?",
"$",
"dbMap",
"->",
"getTable",
"(",
"$",
"tableName",
")",
"->",
"getColumn",
"(",
"$",
"columnName",
")",
":",
"null",
";",
"if",
"(",
"$",
"criteria",
"->",
"isIgnoreCase",
"(",
")",
"&&",
"$",
"column",
"&&",
"$",
"column",
"->",
"isText",
"(",
")",
")",
"{",
"$",
"ignoreCaseColumn",
"=",
"$",
"db",
"->",
"ignoreCaseInOrderBy",
"(",
"\"$tableAlias.$columnAlias\"",
")",
";",
"$",
"orderByClause",
"[",
"]",
"=",
"$",
"ignoreCaseColumn",
".",
"$",
"direction",
";",
"$",
"selectSql",
".=",
"', '",
".",
"$",
"ignoreCaseColumn",
";",
"}",
"else",
"{",
"$",
"orderByClause",
"[",
"]",
"=",
"$",
"orderByColumn",
";",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"fromClause",
")",
"&&",
"$",
"criteria",
"->",
"getPrimaryTableName",
"(",
")",
")",
"{",
"$",
"fromClause",
"[",
"]",
"=",
"$",
"criteria",
"->",
"getPrimaryTableName",
"(",
")",
";",
"}",
"// tables should not exist as alias of subQuery",
"if",
"(",
"$",
"criteria",
"->",
"hasSelectQueries",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"fromClause",
"as",
"$",
"key",
"=>",
"$",
"ftable",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"ftable",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"realtable",
",",
"$",
"tableName",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"ftable",
")",
";",
"}",
"else",
"{",
"$",
"tableName",
"=",
"$",
"ftable",
";",
"}",
"if",
"(",
"$",
"criteria",
"->",
"hasSelectQuery",
"(",
"$",
"tableName",
")",
")",
"{",
"unset",
"(",
"$",
"fromClause",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"// from / join tables quoted if it is necessary",
"if",
"(",
"$",
"db",
"->",
"useQuoteIdentifier",
"(",
")",
")",
"{",
"$",
"fromClause",
"=",
"array_map",
"(",
"array",
"(",
"$",
"db",
",",
"'quoteIdentifierTable'",
")",
",",
"$",
"fromClause",
")",
";",
"$",
"joinClause",
"=",
"$",
"joinClause",
"?",
"$",
"joinClause",
":",
"array_map",
"(",
"array",
"(",
"$",
"db",
",",
"'quoteIdentifierTable'",
")",
",",
"$",
"joinClause",
")",
";",
"}",
"// add subQuery to From after adding quotes",
"foreach",
"(",
"$",
"criteria",
"->",
"getSelectQueries",
"(",
")",
"as",
"$",
"subQueryAlias",
"=>",
"$",
"subQueryCriteria",
")",
"{",
"$",
"fromClause",
"[",
"]",
"=",
"'('",
".",
"BasePeer",
"::",
"createSelectSql",
"(",
"$",
"subQueryCriteria",
",",
"$",
"params",
")",
".",
"') AS '",
".",
"$",
"subQueryAlias",
";",
"}",
"// build from-clause",
"$",
"from",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"joinClause",
")",
"&&",
"count",
"(",
"$",
"fromClause",
")",
">",
"1",
")",
"{",
"$",
"from",
".=",
"implode",
"(",
"\" CROSS JOIN \"",
",",
"$",
"fromClause",
")",
";",
"}",
"else",
"{",
"$",
"from",
".=",
"implode",
"(",
"\", \"",
",",
"$",
"fromClause",
")",
";",
"}",
"$",
"from",
".=",
"$",
"joinClause",
"?",
"' '",
".",
"implode",
"(",
"' '",
",",
"$",
"joinClause",
")",
":",
"''",
";",
"// Build the SQL from the arrays we compiled",
"$",
"sql",
"=",
"$",
"selectSql",
".",
"\" FROM \"",
".",
"$",
"from",
".",
"(",
"$",
"whereClause",
"?",
"\" WHERE \"",
".",
"implode",
"(",
"\" AND \"",
",",
"$",
"whereClause",
")",
":",
"\"\"",
")",
".",
"(",
"$",
"groupByClause",
"?",
"\" GROUP BY \"",
".",
"implode",
"(",
"\",\"",
",",
"$",
"groupByClause",
")",
":",
"\"\"",
")",
".",
"(",
"$",
"havingString",
"?",
"\" HAVING \"",
".",
"$",
"havingString",
":",
"\"\"",
")",
".",
"(",
"$",
"orderByClause",
"?",
"\" ORDER BY \"",
".",
"implode",
"(",
"\",\"",
",",
"$",
"orderByClause",
")",
":",
"\"\"",
")",
";",
"// APPLY OFFSET & LIMIT to the query.",
"if",
"(",
"$",
"criteria",
"->",
"getLimit",
"(",
")",
"||",
"$",
"criteria",
"->",
"getOffset",
"(",
")",
")",
"{",
"$",
"db",
"->",
"applyLimit",
"(",
"$",
"sql",
",",
"$",
"criteria",
"->",
"getOffset",
"(",
")",
",",
"$",
"criteria",
"->",
"getLimit",
"(",
")",
",",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"sql",
";",
"}"
] | Method to create an SQL query based on values in a Criteria.
This method creates only prepared statement SQL (using ? where values
will go). The second parameter ($params) stores the values that need
to be set before the statement is executed. The reason we do it this way
is to let the PDO layer handle all escaping & value formatting.
@param Criteria $criteria Criteria for the SELECT query.
@param array &$params Parameters that are to be replaced in prepared statement.
@return string
@throws PropelException Trouble creating the query string. | [
"Method",
"to",
"create",
"an",
"SQL",
"query",
"based",
"on",
"values",
"in",
"a",
"Criteria",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L659-L854 |
propelorm/Propel | runtime/lib/util/BasePeer.php | BasePeer.getValidator | public static function getValidator($classname)
{
try {
$v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null;
if ($v === null) {
$cls = Propel::importClass($classname);
$v = new $cls();
self::$validatorMap[$classname] = $v;
}
return $v;
} catch (Exception $e) {
Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR);
}
return null;
} | php | public static function getValidator($classname)
{
try {
$v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null;
if ($v === null) {
$cls = Propel::importClass($classname);
$v = new $cls();
self::$validatorMap[$classname] = $v;
}
return $v;
} catch (Exception $e) {
Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR);
}
return null;
} | [
"public",
"static",
"function",
"getValidator",
"(",
"$",
"classname",
")",
"{",
"try",
"{",
"$",
"v",
"=",
"isset",
"(",
"self",
"::",
"$",
"validatorMap",
"[",
"$",
"classname",
"]",
")",
"?",
"self",
"::",
"$",
"validatorMap",
"[",
"$",
"classname",
"]",
":",
"null",
";",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"cls",
"=",
"Propel",
"::",
"importClass",
"(",
"$",
"classname",
")",
";",
"$",
"v",
"=",
"new",
"$",
"cls",
"(",
")",
";",
"self",
"::",
"$",
"validatorMap",
"[",
"$",
"classname",
"]",
"=",
"$",
"v",
";",
"}",
"return",
"$",
"v",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"\"BasePeer::getValidator(): failed trying to instantiate \"",
".",
"$",
"classname",
".",
"\": \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"}",
"return",
"null",
";",
"}"
] | This function searches for the given validator $name under propel/validator/$name.php,
imports and caches it.
@param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator)
@return Validator|null object or null if not able to instantiate validator class (and error will be logged in this case) | [
"This",
"function",
"searches",
"for",
"the",
"given",
"validator",
"$name",
"under",
"propel",
"/",
"validator",
"/",
"$name",
".",
"php",
"imports",
"and",
"caches",
"it",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/BasePeer.php#L886-L902 |
propelorm/Propel | generator/lib/model/ColumnDefaultValue.php | ColumnDefaultValue.equals | public function equals(ColumnDefaultValue $other)
{
if ($this->getType() != $other->getType()) {
return false;
}
if ($this == $other) {
return true;
}
// special case for current timestamp
$equivalents = array('CURRENT_TIMESTAMP', 'NOW()');
if (in_array(strtoupper($this->getValue()), $equivalents) && in_array(strtoupper($other->getValue()), $equivalents)) {
return true;
}
return false; // Can't help, they are different
} | php | public function equals(ColumnDefaultValue $other)
{
if ($this->getType() != $other->getType()) {
return false;
}
if ($this == $other) {
return true;
}
// special case for current timestamp
$equivalents = array('CURRENT_TIMESTAMP', 'NOW()');
if (in_array(strtoupper($this->getValue()), $equivalents) && in_array(strtoupper($other->getValue()), $equivalents)) {
return true;
}
return false; // Can't help, they are different
} | [
"public",
"function",
"equals",
"(",
"ColumnDefaultValue",
"$",
"other",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"!=",
"$",
"other",
"->",
"getType",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"==",
"$",
"other",
")",
"{",
"return",
"true",
";",
"}",
"// special case for current timestamp",
"$",
"equivalents",
"=",
"array",
"(",
"'CURRENT_TIMESTAMP'",
",",
"'NOW()'",
")",
";",
"if",
"(",
"in_array",
"(",
"strtoupper",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
",",
"$",
"equivalents",
")",
"&&",
"in_array",
"(",
"strtoupper",
"(",
"$",
"other",
"->",
"getValue",
"(",
")",
")",
",",
"$",
"equivalents",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"// Can't help, they are different",
"}"
] | A method to compare if two Default values match
@param ColumnDefaultValue $other The value to compare to
@return boolean Whether this object represents same default value as $other
@author Niklas Närhinen <niklas@narhinen.net> | [
"A",
"method",
"to",
"compare",
"if",
"two",
"Default",
"values",
"match"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ColumnDefaultValue.php#L98-L113 |
propelorm/Propel | generator/lib/task/PropelDataDumpTask.php | PropelDataDumpTask.createDataDbMap | private function createDataDbMap()
{
if ($this->getDataDbMap() === null) {
return;
}
// Produce the sql -> database map
$datadbmap = new Properties();
// Check to see if the sqldbmap has already been created.
if ($this->getDataDbMap()->exists()) {
$datadbmap->load($this->getDataDbMap());
}
foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel
foreach ($dataModel->getDatabases() as $database) {
// if database name is specified, then we only want to dump that one db.
if (empty($this->databaseName) || ($this->databaseName && $database->getName() == $this->databaseName)) {
$outFile = $this->getMappedFile($dataModel->getName());
$datadbmap->setProperty($outFile->getName(), $database->getName());
}
}
}
try {
$datadbmap->store($this->getDataDbMap(), "Data XML file -> Database map");
} catch (IOException $e) {
throw new IOException("Unable to store properties: " . $e->getMessage());
}
} | php | private function createDataDbMap()
{
if ($this->getDataDbMap() === null) {
return;
}
// Produce the sql -> database map
$datadbmap = new Properties();
// Check to see if the sqldbmap has already been created.
if ($this->getDataDbMap()->exists()) {
$datadbmap->load($this->getDataDbMap());
}
foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel
foreach ($dataModel->getDatabases() as $database) {
// if database name is specified, then we only want to dump that one db.
if (empty($this->databaseName) || ($this->databaseName && $database->getName() == $this->databaseName)) {
$outFile = $this->getMappedFile($dataModel->getName());
$datadbmap->setProperty($outFile->getName(), $database->getName());
}
}
}
try {
$datadbmap->store($this->getDataDbMap(), "Data XML file -> Database map");
} catch (IOException $e) {
throw new IOException("Unable to store properties: " . $e->getMessage());
}
} | [
"private",
"function",
"createDataDbMap",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDataDbMap",
"(",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"// Produce the sql -> database map",
"$",
"datadbmap",
"=",
"new",
"Properties",
"(",
")",
";",
"// Check to see if the sqldbmap has already been created.",
"if",
"(",
"$",
"this",
"->",
"getDataDbMap",
"(",
")",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"datadbmap",
"->",
"load",
"(",
"$",
"this",
"->",
"getDataDbMap",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getDataModels",
"(",
")",
"as",
"$",
"dataModel",
")",
"{",
"// there is really one 1 db per datamodel",
"foreach",
"(",
"$",
"dataModel",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"database",
")",
"{",
"// if database name is specified, then we only want to dump that one db.",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"databaseName",
")",
"||",
"(",
"$",
"this",
"->",
"databaseName",
"&&",
"$",
"database",
"->",
"getName",
"(",
")",
"==",
"$",
"this",
"->",
"databaseName",
")",
")",
"{",
"$",
"outFile",
"=",
"$",
"this",
"->",
"getMappedFile",
"(",
"$",
"dataModel",
"->",
"getName",
"(",
")",
")",
";",
"$",
"datadbmap",
"->",
"setProperty",
"(",
"$",
"outFile",
"->",
"getName",
"(",
")",
",",
"$",
"database",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"try",
"{",
"$",
"datadbmap",
"->",
"store",
"(",
"$",
"this",
"->",
"getDataDbMap",
"(",
")",
",",
"\"Data XML file -> Database map\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"$",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unable to store properties: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Create the data XML -> database map.
This is necessary because there is currently no other method of knowing which
data XML files correspond to which database. This map allows us to convert multiple
data XML files into SQL.
@throws IOException - if unable to store properties | [
"Create",
"the",
"data",
"XML",
"-",
">",
"database",
"map",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelDataDumpTask.php#L218-L248 |
propelorm/Propel | generator/lib/task/PropelDataDumpTask.php | PropelDataDumpTask.main | public function main()
{
$this->validate();
$buf = "Database settings:\n"
. " driver: " . ($this->databaseDriver ? $this->databaseDriver : "(default)" ). "\n"
. " URL: " . $this->databaseUrl . "\n"
. ($this->databaseUser ? " user: " . $this->databaseUser . "\n" : "")
. ($this->databasePassword ? " password: " . $this->databasePassword . "\n" : "");
$this->log($buf, Project::MSG_VERBOSE);
// 1) First create the Data XML -> database name map.
$this->createDataDbMap();
// 2) Now go create the XML files from teh database(s)
foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel
foreach ($dataModel->getDatabases() as $database) {
// if database name is specified, then we only want to dump that one db.
if (empty($this->databaseName) || ($this->databaseName && $database->getName() == $this->databaseName)) {
$outFile = $this->getMappedFile($dataModel->getName());
$this->log("Dumping data to XML for database: " . $database->getName());
$this->log("Writing to XML file: " . $outFile->getName());
try {
$this->conn = $dataModel->getGeneratorConfig()->getBuildPDO($database->getName());
$doc = $this->createXMLDoc($database);
$doc->save($outFile->getAbsolutePath());
} catch (SQLException $se) {
$this->log("SQLException while connecting to DB: " . $se->getMessage(), Project::MSG_ERR);
throw new BuildException($se);
}
} // if databaseName && database->getName == databaseName
} // foreach database
} // foreach datamodel
} | php | public function main()
{
$this->validate();
$buf = "Database settings:\n"
. " driver: " . ($this->databaseDriver ? $this->databaseDriver : "(default)" ). "\n"
. " URL: " . $this->databaseUrl . "\n"
. ($this->databaseUser ? " user: " . $this->databaseUser . "\n" : "")
. ($this->databasePassword ? " password: " . $this->databasePassword . "\n" : "");
$this->log($buf, Project::MSG_VERBOSE);
// 1) First create the Data XML -> database name map.
$this->createDataDbMap();
// 2) Now go create the XML files from teh database(s)
foreach ($this->getDataModels() as $dataModel) { // there is really one 1 db per datamodel
foreach ($dataModel->getDatabases() as $database) {
// if database name is specified, then we only want to dump that one db.
if (empty($this->databaseName) || ($this->databaseName && $database->getName() == $this->databaseName)) {
$outFile = $this->getMappedFile($dataModel->getName());
$this->log("Dumping data to XML for database: " . $database->getName());
$this->log("Writing to XML file: " . $outFile->getName());
try {
$this->conn = $dataModel->getGeneratorConfig()->getBuildPDO($database->getName());
$doc = $this->createXMLDoc($database);
$doc->save($outFile->getAbsolutePath());
} catch (SQLException $se) {
$this->log("SQLException while connecting to DB: " . $se->getMessage(), Project::MSG_ERR);
throw new BuildException($se);
}
} // if databaseName && database->getName == databaseName
} // foreach database
} // foreach datamodel
} | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"$",
"buf",
"=",
"\"Database settings:\\n\"",
".",
"\" driver: \"",
".",
"(",
"$",
"this",
"->",
"databaseDriver",
"?",
"$",
"this",
"->",
"databaseDriver",
":",
"\"(default)\"",
")",
".",
"\"\\n\"",
".",
"\" URL: \"",
".",
"$",
"this",
"->",
"databaseUrl",
".",
"\"\\n\"",
".",
"(",
"$",
"this",
"->",
"databaseUser",
"?",
"\" user: \"",
".",
"$",
"this",
"->",
"databaseUser",
".",
"\"\\n\"",
":",
"\"\"",
")",
".",
"(",
"$",
"this",
"->",
"databasePassword",
"?",
"\" password: \"",
".",
"$",
"this",
"->",
"databasePassword",
".",
"\"\\n\"",
":",
"\"\"",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"buf",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"// 1) First create the Data XML -> database name map.",
"$",
"this",
"->",
"createDataDbMap",
"(",
")",
";",
"// 2) Now go create the XML files from teh database(s)",
"foreach",
"(",
"$",
"this",
"->",
"getDataModels",
"(",
")",
"as",
"$",
"dataModel",
")",
"{",
"// there is really one 1 db per datamodel",
"foreach",
"(",
"$",
"dataModel",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"database",
")",
"{",
"// if database name is specified, then we only want to dump that one db.",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"databaseName",
")",
"||",
"(",
"$",
"this",
"->",
"databaseName",
"&&",
"$",
"database",
"->",
"getName",
"(",
")",
"==",
"$",
"this",
"->",
"databaseName",
")",
")",
"{",
"$",
"outFile",
"=",
"$",
"this",
"->",
"getMappedFile",
"(",
"$",
"dataModel",
"->",
"getName",
"(",
")",
")",
";",
"$",
"this",
"->",
"log",
"(",
"\"Dumping data to XML for database: \"",
".",
"$",
"database",
"->",
"getName",
"(",
")",
")",
";",
"$",
"this",
"->",
"log",
"(",
"\"Writing to XML file: \"",
".",
"$",
"outFile",
"->",
"getName",
"(",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"conn",
"=",
"$",
"dataModel",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getBuildPDO",
"(",
"$",
"database",
"->",
"getName",
"(",
")",
")",
";",
"$",
"doc",
"=",
"$",
"this",
"->",
"createXMLDoc",
"(",
"$",
"database",
")",
";",
"$",
"doc",
"->",
"save",
"(",
"$",
"outFile",
"->",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"SQLException",
"$",
"se",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"SQLException while connecting to DB: \"",
".",
"$",
"se",
"->",
"getMessage",
"(",
")",
",",
"Project",
"::",
"MSG_ERR",
")",
";",
"throw",
"new",
"BuildException",
"(",
"$",
"se",
")",
";",
"}",
"}",
"// if databaseName && database->getName == databaseName",
"}",
"// foreach database",
"}",
"// foreach datamodel",
"}"
] | Iterates through each datamodel/database, dumps the contents of all tables and creates a DOM XML doc.
@return void
@throws BuildException | [
"Iterates",
"through",
"each",
"datamodel",
"/",
"database",
"dumps",
"the",
"contents",
"of",
"all",
"tables",
"and",
"creates",
"a",
"DOM",
"XML",
"doc",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelDataDumpTask.php#L256-L295 |
propelorm/Propel | generator/lib/task/PropelDataDumpTask.php | PropelDataDumpTask.getTableDataStmt | private function getTableDataStmt($tableName, PropelPlatformInterface $platform)
{
return $this->conn->query("SELECT * FROM " . $platform->quoteIdentifier($tableName));
} | php | private function getTableDataStmt($tableName, PropelPlatformInterface $platform)
{
return $this->conn->query("SELECT * FROM " . $platform->quoteIdentifier($tableName));
} | [
"private",
"function",
"getTableDataStmt",
"(",
"$",
"tableName",
",",
"PropelPlatformInterface",
"$",
"platform",
")",
"{",
"return",
"$",
"this",
"->",
"conn",
"->",
"query",
"(",
"\"SELECT * FROM \"",
".",
"$",
"platform",
"->",
"quoteIdentifier",
"(",
"$",
"tableName",
")",
")",
";",
"}"
] | Gets PDOStatement of query to fetch all data from a table.
@param string $tableName
@param PropelPlatformInterface $platform
@return PDOStatement | [
"Gets",
"PDOStatement",
"of",
"query",
"to",
"fetch",
"all",
"data",
"from",
"a",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelDataDumpTask.php#L305-L308 |
propelorm/Propel | generator/lib/task/PropelDataDumpTask.php | PropelDataDumpTask.createXMLDoc | private function createXMLDoc(Database $database)
{
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true; // pretty printing
$doc->appendChild($doc->createComment("Created by PropelDataDumpTask."));
$dsNode = $doc->createElement("dataset");
$dsNode->setAttribute("name", "all");
$doc->appendChild($dsNode);
$platform = $this->getGeneratorConfig()->getConfiguredPlatform($this->conn);
$this->log("Building DOM tree containing data from tables:");
foreach ($database->getTables() as $tbl) {
$this->log("\t+ " . $tbl->getName());
$stmt = $this->getTableDataStmt($tbl->getName(), $platform);
while ($row = $stmt->fetch()) {
$rowNode = $doc->createElement($tbl->getPhpName());
foreach ($tbl->getColumns() as $col) {
$cval = $row[$col->getName()];
if ($cval !== null) {
$rowNode->setAttribute($col->getPhpName(), iconv($this->dbEncoding, 'utf-8', $cval));
}
}
$dsNode->appendChild($rowNode);
unset($rowNode);
}
unset($stmt);
}
return $doc;
} | php | private function createXMLDoc(Database $database)
{
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true; // pretty printing
$doc->appendChild($doc->createComment("Created by PropelDataDumpTask."));
$dsNode = $doc->createElement("dataset");
$dsNode->setAttribute("name", "all");
$doc->appendChild($dsNode);
$platform = $this->getGeneratorConfig()->getConfiguredPlatform($this->conn);
$this->log("Building DOM tree containing data from tables:");
foreach ($database->getTables() as $tbl) {
$this->log("\t+ " . $tbl->getName());
$stmt = $this->getTableDataStmt($tbl->getName(), $platform);
while ($row = $stmt->fetch()) {
$rowNode = $doc->createElement($tbl->getPhpName());
foreach ($tbl->getColumns() as $col) {
$cval = $row[$col->getName()];
if ($cval !== null) {
$rowNode->setAttribute($col->getPhpName(), iconv($this->dbEncoding, 'utf-8', $cval));
}
}
$dsNode->appendChild($rowNode);
unset($rowNode);
}
unset($stmt);
}
return $doc;
} | [
"private",
"function",
"createXMLDoc",
"(",
"Database",
"$",
"database",
")",
"{",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"doc",
"->",
"formatOutput",
"=",
"true",
";",
"// pretty printing",
"$",
"doc",
"->",
"appendChild",
"(",
"$",
"doc",
"->",
"createComment",
"(",
"\"Created by PropelDataDumpTask.\"",
")",
")",
";",
"$",
"dsNode",
"=",
"$",
"doc",
"->",
"createElement",
"(",
"\"dataset\"",
")",
";",
"$",
"dsNode",
"->",
"setAttribute",
"(",
"\"name\"",
",",
"\"all\"",
")",
";",
"$",
"doc",
"->",
"appendChild",
"(",
"$",
"dsNode",
")",
";",
"$",
"platform",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredPlatform",
"(",
"$",
"this",
"->",
"conn",
")",
";",
"$",
"this",
"->",
"log",
"(",
"\"Building DOM tree containing data from tables:\"",
")",
";",
"foreach",
"(",
"$",
"database",
"->",
"getTables",
"(",
")",
"as",
"$",
"tbl",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"\\t+ \"",
".",
"$",
"tbl",
"->",
"getName",
"(",
")",
")",
";",
"$",
"stmt",
"=",
"$",
"this",
"->",
"getTableDataStmt",
"(",
"$",
"tbl",
"->",
"getName",
"(",
")",
",",
"$",
"platform",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
")",
")",
"{",
"$",
"rowNode",
"=",
"$",
"doc",
"->",
"createElement",
"(",
"$",
"tbl",
"->",
"getPhpName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"tbl",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"$",
"cval",
"=",
"$",
"row",
"[",
"$",
"col",
"->",
"getName",
"(",
")",
"]",
";",
"if",
"(",
"$",
"cval",
"!==",
"null",
")",
"{",
"$",
"rowNode",
"->",
"setAttribute",
"(",
"$",
"col",
"->",
"getPhpName",
"(",
")",
",",
"iconv",
"(",
"$",
"this",
"->",
"dbEncoding",
",",
"'utf-8'",
",",
"$",
"cval",
")",
")",
";",
"}",
"}",
"$",
"dsNode",
"->",
"appendChild",
"(",
"$",
"rowNode",
")",
";",
"unset",
"(",
"$",
"rowNode",
")",
";",
"}",
"unset",
"(",
"$",
"stmt",
")",
";",
"}",
"return",
"$",
"doc",
";",
"}"
] | Creates a DOM document containing data for specified database.
@param Database $database
@return DOMDocument | [
"Creates",
"a",
"DOM",
"document",
"containing",
"data",
"for",
"specified",
"database",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelDataDumpTask.php#L317-L349 |
propelorm/Propel | runtime/lib/adapter/DBMSSQL.php | DBMSSQL.applyLimit | public function applyLimit(&$sql, $offset, $limit)
{
// make sure offset and limit are numeric
if (!is_numeric($offset) || !is_numeric($limit)) {
throw new PropelException('DBMSSQL::applyLimit() expects a number for argument 2 and 3');
}
//split the select and from clauses out of the original query
$selectSegment = array();
$selectText = 'SELECT ';
preg_match('/\Aselect(.*)from(.*)/si', $sql, $selectSegment);
if (count($selectSegment) == 3) {
$selectStatement = trim($selectSegment[1]);
$fromStatement = trim($selectSegment[2]);
} else {
throw new Exception('DBMSSQL::applyLimit() could not locate the select statement at the start of the query.');
}
if (preg_match('/\Aselect(\s+)distinct/i', $sql)) {
$selectText .= 'DISTINCT ';
$selectStatement = str_ireplace('distinct ', '', $selectStatement);
}
// if we're starting at offset 0 then theres no need to simulate LIMIT,
// just grab the top $limit number of rows
if ($offset == 0) {
$sql = $selectText . 'TOP ' . $limit . ' ' . $selectStatement . ' FROM ' . $fromStatement;
return;
}
//get the ORDER BY clause if present
$orderStatement = stristr($fromStatement, 'ORDER BY');
$orders = '';
if ($orderStatement !== false) {
//remove order statement from the FROM statement
$fromStatement = trim(str_replace($orderStatement, '', $fromStatement));
$order = str_ireplace('ORDER BY', '', $orderStatement);
$orders = array_map('trim', explode(',', $order));
for ($i = 0; $i < count($orders); $i++) {
$orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = array(
'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC',
'key' => $i
);
}
}
//setup inner and outer select selects
$innerSelect = '';
$outerSelect = '';
foreach (explode(', ', $selectStatement) as $selCol) {
$selColArr = explode(' ', $selCol);
$selColCount = count($selColArr) - 1;
//make sure the current column isn't * or an aggregate
if ($selColArr[0] != '*' && !strstr($selColArr[0], '(') && strtoupper($selColArr[0]) !== 'CASE') {
// Aliases can be used in ORDER BY clauses on a SELECT,
// but aliases are not valid in the ORDER BY clause of ROW_NUMBER() OVER (...),
// so if we notice that part of $order is actually an alias,
// we replace it with the original Table.Column designation.
if ($selColCount) {
// column with alias
foreach (array(' ASC', ' DESC') as $sort) {
$index = array_search($selColArr[2] . $sort, $orders);
if ($index !== false) {
// replace alias with "Table.Column ASC/DESC"
$orders[$index] = $selColArr[0] . $sort;
break;
}
}
}
if (isset($orderArr[$selColArr[0]])) {
$orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort'];
}
//use the alias if one was present otherwise use the column name
$alias = (!stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount];
//don't quote the identifier if it is already quoted
if ($alias[0] != '[') {
$alias = $this->quoteIdentifier($alias);
}
//save the first non-aggregate column for use in ROW_NUMBER() if required
if (!isset($firstColumnOrderStatement)) {
$firstColumnOrderStatement = 'ORDER BY ' . $selColArr[0];
}
//add an alias to the inner select so all columns will be unique
$innerSelect .= $selColArr[0] . ' AS ' . $alias . ', ';
$outerSelect .= $alias . ', ';
} else {
//aggregate columns must always have an alias clause
if (!stristr($selCol, ' AS ')) {
throw new Exception('DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause');
}
//aggregate column alias can't be used as the count column you must use the entire aggregate statement
if (isset($orderArr[$selColArr[$selColCount]])) {
$orders[$orderArr[$selColArr[$selColCount]]['key']] = str_replace($selColArr[$selColCount - 1] . ' ' . $selColArr[$selColCount], '', $selCol) . $orderArr[$selColArr[$selColCount]]['sort'];
}
//quote the alias
$alias = $selColArr[$selColCount];
//don't quote the identifier if it is already quoted
if ($alias[0] != '[') {
$alias = $this->quoteIdentifier($alias);
}
$innerSelect .= str_replace($selColArr[$selColCount], $alias, $selCol) . ', ';
$outerSelect .= $alias . ', ';
}
}
if (is_array($orders)) {
$orderStatement = 'ORDER BY ' . implode(', ', $orders);
} else {
//use the first non aggregate column in our select statement if no ORDER BY clause present
if (isset($firstColumnOrderStatement)) {
$orderStatement = $firstColumnOrderStatement;
} else {
throw new Exception('DBMSSQL::applyLimit() unable to find column to use with ROW_NUMBER()');
}
}
//substring the select strings to get rid of the last comma and add our FROM and SELECT clauses
$innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS [RowNumber], ' . substr($innerSelect, 0, -2) . ' FROM';
//outer select can't use * because of the RowNumber column
$outerSelect = 'SELECT ' . substr($outerSelect, 0, -2) . ' FROM';
//ROW_NUMBER() starts at 1 not 0
$sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset);
} | php | public function applyLimit(&$sql, $offset, $limit)
{
// make sure offset and limit are numeric
if (!is_numeric($offset) || !is_numeric($limit)) {
throw new PropelException('DBMSSQL::applyLimit() expects a number for argument 2 and 3');
}
//split the select and from clauses out of the original query
$selectSegment = array();
$selectText = 'SELECT ';
preg_match('/\Aselect(.*)from(.*)/si', $sql, $selectSegment);
if (count($selectSegment) == 3) {
$selectStatement = trim($selectSegment[1]);
$fromStatement = trim($selectSegment[2]);
} else {
throw new Exception('DBMSSQL::applyLimit() could not locate the select statement at the start of the query.');
}
if (preg_match('/\Aselect(\s+)distinct/i', $sql)) {
$selectText .= 'DISTINCT ';
$selectStatement = str_ireplace('distinct ', '', $selectStatement);
}
// if we're starting at offset 0 then theres no need to simulate LIMIT,
// just grab the top $limit number of rows
if ($offset == 0) {
$sql = $selectText . 'TOP ' . $limit . ' ' . $selectStatement . ' FROM ' . $fromStatement;
return;
}
//get the ORDER BY clause if present
$orderStatement = stristr($fromStatement, 'ORDER BY');
$orders = '';
if ($orderStatement !== false) {
//remove order statement from the FROM statement
$fromStatement = trim(str_replace($orderStatement, '', $fromStatement));
$order = str_ireplace('ORDER BY', '', $orderStatement);
$orders = array_map('trim', explode(',', $order));
for ($i = 0; $i < count($orders); $i++) {
$orderArr[trim(preg_replace('/\s+(ASC|DESC)$/i', '', $orders[$i]))] = array(
'sort' => (stripos($orders[$i], ' DESC') !== false) ? 'DESC' : 'ASC',
'key' => $i
);
}
}
//setup inner and outer select selects
$innerSelect = '';
$outerSelect = '';
foreach (explode(', ', $selectStatement) as $selCol) {
$selColArr = explode(' ', $selCol);
$selColCount = count($selColArr) - 1;
//make sure the current column isn't * or an aggregate
if ($selColArr[0] != '*' && !strstr($selColArr[0], '(') && strtoupper($selColArr[0]) !== 'CASE') {
// Aliases can be used in ORDER BY clauses on a SELECT,
// but aliases are not valid in the ORDER BY clause of ROW_NUMBER() OVER (...),
// so if we notice that part of $order is actually an alias,
// we replace it with the original Table.Column designation.
if ($selColCount) {
// column with alias
foreach (array(' ASC', ' DESC') as $sort) {
$index = array_search($selColArr[2] . $sort, $orders);
if ($index !== false) {
// replace alias with "Table.Column ASC/DESC"
$orders[$index] = $selColArr[0] . $sort;
break;
}
}
}
if (isset($orderArr[$selColArr[0]])) {
$orders[$orderArr[$selColArr[0]]['key']] = $selColArr[0] . ' ' . $orderArr[$selColArr[0]]['sort'];
}
//use the alias if one was present otherwise use the column name
$alias = (!stristr($selCol, ' AS ')) ? $selColArr[0] : $selColArr[$selColCount];
//don't quote the identifier if it is already quoted
if ($alias[0] != '[') {
$alias = $this->quoteIdentifier($alias);
}
//save the first non-aggregate column for use in ROW_NUMBER() if required
if (!isset($firstColumnOrderStatement)) {
$firstColumnOrderStatement = 'ORDER BY ' . $selColArr[0];
}
//add an alias to the inner select so all columns will be unique
$innerSelect .= $selColArr[0] . ' AS ' . $alias . ', ';
$outerSelect .= $alias . ', ';
} else {
//aggregate columns must always have an alias clause
if (!stristr($selCol, ' AS ')) {
throw new Exception('DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause');
}
//aggregate column alias can't be used as the count column you must use the entire aggregate statement
if (isset($orderArr[$selColArr[$selColCount]])) {
$orders[$orderArr[$selColArr[$selColCount]]['key']] = str_replace($selColArr[$selColCount - 1] . ' ' . $selColArr[$selColCount], '', $selCol) . $orderArr[$selColArr[$selColCount]]['sort'];
}
//quote the alias
$alias = $selColArr[$selColCount];
//don't quote the identifier if it is already quoted
if ($alias[0] != '[') {
$alias = $this->quoteIdentifier($alias);
}
$innerSelect .= str_replace($selColArr[$selColCount], $alias, $selCol) . ', ';
$outerSelect .= $alias . ', ';
}
}
if (is_array($orders)) {
$orderStatement = 'ORDER BY ' . implode(', ', $orders);
} else {
//use the first non aggregate column in our select statement if no ORDER BY clause present
if (isset($firstColumnOrderStatement)) {
$orderStatement = $firstColumnOrderStatement;
} else {
throw new Exception('DBMSSQL::applyLimit() unable to find column to use with ROW_NUMBER()');
}
}
//substring the select strings to get rid of the last comma and add our FROM and SELECT clauses
$innerSelect = $selectText . 'ROW_NUMBER() OVER(' . $orderStatement . ') AS [RowNumber], ' . substr($innerSelect, 0, -2) . ' FROM';
//outer select can't use * because of the RowNumber column
$outerSelect = 'SELECT ' . substr($outerSelect, 0, -2) . ' FROM';
//ROW_NUMBER() starts at 1 not 0
$sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset);
} | [
"public",
"function",
"applyLimit",
"(",
"&",
"$",
"sql",
",",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"// make sure offset and limit are numeric",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"offset",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"limit",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'DBMSSQL::applyLimit() expects a number for argument 2 and 3'",
")",
";",
"}",
"//split the select and from clauses out of the original query",
"$",
"selectSegment",
"=",
"array",
"(",
")",
";",
"$",
"selectText",
"=",
"'SELECT '",
";",
"preg_match",
"(",
"'/\\Aselect(.*)from(.*)/si'",
",",
"$",
"sql",
",",
"$",
"selectSegment",
")",
";",
"if",
"(",
"count",
"(",
"$",
"selectSegment",
")",
"==",
"3",
")",
"{",
"$",
"selectStatement",
"=",
"trim",
"(",
"$",
"selectSegment",
"[",
"1",
"]",
")",
";",
"$",
"fromStatement",
"=",
"trim",
"(",
"$",
"selectSegment",
"[",
"2",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'DBMSSQL::applyLimit() could not locate the select statement at the start of the query.'",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/\\Aselect(\\s+)distinct/i'",
",",
"$",
"sql",
")",
")",
"{",
"$",
"selectText",
".=",
"'DISTINCT '",
";",
"$",
"selectStatement",
"=",
"str_ireplace",
"(",
"'distinct '",
",",
"''",
",",
"$",
"selectStatement",
")",
";",
"}",
"// if we're starting at offset 0 then theres no need to simulate LIMIT,",
"// just grab the top $limit number of rows",
"if",
"(",
"$",
"offset",
"==",
"0",
")",
"{",
"$",
"sql",
"=",
"$",
"selectText",
".",
"'TOP '",
".",
"$",
"limit",
".",
"' '",
".",
"$",
"selectStatement",
".",
"' FROM '",
".",
"$",
"fromStatement",
";",
"return",
";",
"}",
"//get the ORDER BY clause if present",
"$",
"orderStatement",
"=",
"stristr",
"(",
"$",
"fromStatement",
",",
"'ORDER BY'",
")",
";",
"$",
"orders",
"=",
"''",
";",
"if",
"(",
"$",
"orderStatement",
"!==",
"false",
")",
"{",
"//remove order statement from the FROM statement",
"$",
"fromStatement",
"=",
"trim",
"(",
"str_replace",
"(",
"$",
"orderStatement",
",",
"''",
",",
"$",
"fromStatement",
")",
")",
";",
"$",
"order",
"=",
"str_ireplace",
"(",
"'ORDER BY'",
",",
"''",
",",
"$",
"orderStatement",
")",
";",
"$",
"orders",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"','",
",",
"$",
"order",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"orders",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"orderArr",
"[",
"trim",
"(",
"preg_replace",
"(",
"'/\\s+(ASC|DESC)$/i'",
",",
"''",
",",
"$",
"orders",
"[",
"$",
"i",
"]",
")",
")",
"]",
"=",
"array",
"(",
"'sort'",
"=>",
"(",
"stripos",
"(",
"$",
"orders",
"[",
"$",
"i",
"]",
",",
"' DESC'",
")",
"!==",
"false",
")",
"?",
"'DESC'",
":",
"'ASC'",
",",
"'key'",
"=>",
"$",
"i",
")",
";",
"}",
"}",
"//setup inner and outer select selects",
"$",
"innerSelect",
"=",
"''",
";",
"$",
"outerSelect",
"=",
"''",
";",
"foreach",
"(",
"explode",
"(",
"', '",
",",
"$",
"selectStatement",
")",
"as",
"$",
"selCol",
")",
"{",
"$",
"selColArr",
"=",
"explode",
"(",
"' '",
",",
"$",
"selCol",
")",
";",
"$",
"selColCount",
"=",
"count",
"(",
"$",
"selColArr",
")",
"-",
"1",
";",
"//make sure the current column isn't * or an aggregate",
"if",
"(",
"$",
"selColArr",
"[",
"0",
"]",
"!=",
"'*'",
"&&",
"!",
"strstr",
"(",
"$",
"selColArr",
"[",
"0",
"]",
",",
"'('",
")",
"&&",
"strtoupper",
"(",
"$",
"selColArr",
"[",
"0",
"]",
")",
"!==",
"'CASE'",
")",
"{",
"// Aliases can be used in ORDER BY clauses on a SELECT,",
"// but aliases are not valid in the ORDER BY clause of ROW_NUMBER() OVER (...),",
"// so if we notice that part of $order is actually an alias,",
"// we replace it with the original Table.Column designation.",
"if",
"(",
"$",
"selColCount",
")",
"{",
"// column with alias",
"foreach",
"(",
"array",
"(",
"' ASC'",
",",
"' DESC'",
")",
"as",
"$",
"sort",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"selColArr",
"[",
"2",
"]",
".",
"$",
"sort",
",",
"$",
"orders",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"// replace alias with \"Table.Column ASC/DESC\"",
"$",
"orders",
"[",
"$",
"index",
"]",
"=",
"$",
"selColArr",
"[",
"0",
"]",
".",
"$",
"sort",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"orderArr",
"[",
"$",
"selColArr",
"[",
"0",
"]",
"]",
")",
")",
"{",
"$",
"orders",
"[",
"$",
"orderArr",
"[",
"$",
"selColArr",
"[",
"0",
"]",
"]",
"[",
"'key'",
"]",
"]",
"=",
"$",
"selColArr",
"[",
"0",
"]",
".",
"' '",
".",
"$",
"orderArr",
"[",
"$",
"selColArr",
"[",
"0",
"]",
"]",
"[",
"'sort'",
"]",
";",
"}",
"//use the alias if one was present otherwise use the column name",
"$",
"alias",
"=",
"(",
"!",
"stristr",
"(",
"$",
"selCol",
",",
"' AS '",
")",
")",
"?",
"$",
"selColArr",
"[",
"0",
"]",
":",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
";",
"//don't quote the identifier if it is already quoted",
"if",
"(",
"$",
"alias",
"[",
"0",
"]",
"!=",
"'['",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"alias",
")",
";",
"}",
"//save the first non-aggregate column for use in ROW_NUMBER() if required",
"if",
"(",
"!",
"isset",
"(",
"$",
"firstColumnOrderStatement",
")",
")",
"{",
"$",
"firstColumnOrderStatement",
"=",
"'ORDER BY '",
".",
"$",
"selColArr",
"[",
"0",
"]",
";",
"}",
"//add an alias to the inner select so all columns will be unique",
"$",
"innerSelect",
".=",
"$",
"selColArr",
"[",
"0",
"]",
".",
"' AS '",
".",
"$",
"alias",
".",
"', '",
";",
"$",
"outerSelect",
".=",
"$",
"alias",
".",
"', '",
";",
"}",
"else",
"{",
"//aggregate columns must always have an alias clause",
"if",
"(",
"!",
"stristr",
"(",
"$",
"selCol",
",",
"' AS '",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'DBMSSQL::applyLimit() requires aggregate columns to have an Alias clause'",
")",
";",
"}",
"//aggregate column alias can't be used as the count column you must use the entire aggregate statement",
"if",
"(",
"isset",
"(",
"$",
"orderArr",
"[",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
"]",
")",
")",
"{",
"$",
"orders",
"[",
"$",
"orderArr",
"[",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
"]",
"[",
"'key'",
"]",
"]",
"=",
"str_replace",
"(",
"$",
"selColArr",
"[",
"$",
"selColCount",
"-",
"1",
"]",
".",
"' '",
".",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
",",
"''",
",",
"$",
"selCol",
")",
".",
"$",
"orderArr",
"[",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
"]",
"[",
"'sort'",
"]",
";",
"}",
"//quote the alias",
"$",
"alias",
"=",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
";",
"//don't quote the identifier if it is already quoted",
"if",
"(",
"$",
"alias",
"[",
"0",
"]",
"!=",
"'['",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"alias",
")",
";",
"}",
"$",
"innerSelect",
".=",
"str_replace",
"(",
"$",
"selColArr",
"[",
"$",
"selColCount",
"]",
",",
"$",
"alias",
",",
"$",
"selCol",
")",
".",
"', '",
";",
"$",
"outerSelect",
".=",
"$",
"alias",
".",
"', '",
";",
"}",
"}",
"if",
"(",
"is_array",
"(",
"$",
"orders",
")",
")",
"{",
"$",
"orderStatement",
"=",
"'ORDER BY '",
".",
"implode",
"(",
"', '",
",",
"$",
"orders",
")",
";",
"}",
"else",
"{",
"//use the first non aggregate column in our select statement if no ORDER BY clause present",
"if",
"(",
"isset",
"(",
"$",
"firstColumnOrderStatement",
")",
")",
"{",
"$",
"orderStatement",
"=",
"$",
"firstColumnOrderStatement",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'DBMSSQL::applyLimit() unable to find column to use with ROW_NUMBER()'",
")",
";",
"}",
"}",
"//substring the select strings to get rid of the last comma and add our FROM and SELECT clauses",
"$",
"innerSelect",
"=",
"$",
"selectText",
".",
"'ROW_NUMBER() OVER('",
".",
"$",
"orderStatement",
".",
"') AS [RowNumber], '",
".",
"substr",
"(",
"$",
"innerSelect",
",",
"0",
",",
"-",
"2",
")",
".",
"' FROM'",
";",
"//outer select can't use * because of the RowNumber column",
"$",
"outerSelect",
"=",
"'SELECT '",
".",
"substr",
"(",
"$",
"outerSelect",
",",
"0",
",",
"-",
"2",
")",
".",
"' FROM'",
";",
"//ROW_NUMBER() starts at 1 not 0",
"$",
"sql",
"=",
"$",
"outerSelect",
".",
"' ('",
".",
"$",
"innerSelect",
".",
"' '",
".",
"$",
"fromStatement",
".",
"') AS derivedb WHERE RowNumber BETWEEN '",
".",
"(",
"$",
"offset",
"+",
"1",
")",
".",
"' AND '",
".",
"(",
"$",
"limit",
"+",
"$",
"offset",
")",
";",
"}"
] | Simulated Limit/Offset
This rewrites the $sql query to apply the offset and limit.
some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform
@see DBAdapter::applyLimit()
@author Benjamin Runnels <kraven@kraven.org>
@param string $sql
@param integer $offset
@param integer $limit
@return void
@throws PropelException
@throws Exception | [
"Simulated",
"Limit",
"/",
"Offset"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBMSSQL.php#L150-L287 |
propelorm/Propel | runtime/lib/adapter/DBMSSQL.php | DBMSSQL.cleanupSQL | public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap)
{
$i = 1;
$paramCols = array();
foreach ($params as $param) {
if (null !== $param['table']) {
$column = $dbMap->getTable($param['table'])->getColumn($param['column']);
/* MSSQL pdo_dblib and pdo_mssql blob values must be converted to hex and then the hex added
* to the query string directly. If it goes through PDOStatement::bindValue quotes will cause
* an error with the insert or update.
*/
if (is_resource($param['value']) && $column->isLob()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
rewind($param['value']);
$hexArr = unpack('H*hex', stream_get_contents($param['value']));
$sql = str_replace(":p$i", '0x' . $hexArr['hex'], $sql);
unset($hexArr);
fclose($param['value']);
} else {
$paramCols[] = $param;
}
}
$i++;
}
//if we made changes re-number the params
if ($params != $paramCols) {
$params = $paramCols;
unset($paramCols);
preg_match_all('/:p\d/', $sql, $matches);
foreach ($matches[0] as $key => $match) {
$sql = str_replace($match, ':p' . ($key + 1), $sql);
}
}
} | php | public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap)
{
$i = 1;
$paramCols = array();
foreach ($params as $param) {
if (null !== $param['table']) {
$column = $dbMap->getTable($param['table'])->getColumn($param['column']);
/* MSSQL pdo_dblib and pdo_mssql blob values must be converted to hex and then the hex added
* to the query string directly. If it goes through PDOStatement::bindValue quotes will cause
* an error with the insert or update.
*/
if (is_resource($param['value']) && $column->isLob()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
rewind($param['value']);
$hexArr = unpack('H*hex', stream_get_contents($param['value']));
$sql = str_replace(":p$i", '0x' . $hexArr['hex'], $sql);
unset($hexArr);
fclose($param['value']);
} else {
$paramCols[] = $param;
}
}
$i++;
}
//if we made changes re-number the params
if ($params != $paramCols) {
$params = $paramCols;
unset($paramCols);
preg_match_all('/:p\d/', $sql, $matches);
foreach ($matches[0] as $key => $match) {
$sql = str_replace($match, ':p' . ($key + 1), $sql);
}
}
} | [
"public",
"function",
"cleanupSQL",
"(",
"&",
"$",
"sql",
",",
"array",
"&",
"$",
"params",
",",
"Criteria",
"$",
"values",
",",
"DatabaseMap",
"$",
"dbMap",
")",
"{",
"$",
"i",
"=",
"1",
";",
"$",
"paramCols",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"param",
"[",
"'table'",
"]",
")",
"{",
"$",
"column",
"=",
"$",
"dbMap",
"->",
"getTable",
"(",
"$",
"param",
"[",
"'table'",
"]",
")",
"->",
"getColumn",
"(",
"$",
"param",
"[",
"'column'",
"]",
")",
";",
"/* MSSQL pdo_dblib and pdo_mssql blob values must be converted to hex and then the hex added\n * to the query string directly. If it goes through PDOStatement::bindValue quotes will cause\n * an error with the insert or update.\n */",
"if",
"(",
"is_resource",
"(",
"$",
"param",
"[",
"'value'",
"]",
")",
"&&",
"$",
"column",
"->",
"isLob",
"(",
")",
")",
"{",
"// we always need to make sure that the stream is rewound, otherwise nothing will",
"// get written to database.",
"rewind",
"(",
"$",
"param",
"[",
"'value'",
"]",
")",
";",
"$",
"hexArr",
"=",
"unpack",
"(",
"'H*hex'",
",",
"stream_get_contents",
"(",
"$",
"param",
"[",
"'value'",
"]",
")",
")",
";",
"$",
"sql",
"=",
"str_replace",
"(",
"\":p$i\"",
",",
"'0x'",
".",
"$",
"hexArr",
"[",
"'hex'",
"]",
",",
"$",
"sql",
")",
";",
"unset",
"(",
"$",
"hexArr",
")",
";",
"fclose",
"(",
"$",
"param",
"[",
"'value'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"paramCols",
"[",
"]",
"=",
"$",
"param",
";",
"}",
"}",
"$",
"i",
"++",
";",
"}",
"//if we made changes re-number the params",
"if",
"(",
"$",
"params",
"!=",
"$",
"paramCols",
")",
"{",
"$",
"params",
"=",
"$",
"paramCols",
";",
"unset",
"(",
"$",
"paramCols",
")",
";",
"preg_match_all",
"(",
"'/:p\\d/'",
",",
"$",
"sql",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"key",
"=>",
"$",
"match",
")",
"{",
"$",
"sql",
"=",
"str_replace",
"(",
"$",
"match",
",",
"':p'",
".",
"(",
"$",
"key",
"+",
"1",
")",
",",
"$",
"sql",
")",
";",
"}",
"}",
"}"
] | @see parent::cleanupSQL()
@param string $sql
@param array $params
@param Criteria $values
@param DatabaseMap $dbMap | [
"@see",
"parent",
"::",
"cleanupSQL",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBMSSQL.php#L297-L332 |
propelorm/Propel | generator/lib/task/PropelOMTask.php | PropelOMTask.ensureDirExists | protected function ensureDirExists($path)
{
$f = new PhingFile($this->getOutputDirectory(), $path);
if (!$f->exists()) {
if (!$f->mkdirs()) {
throw new BuildException("Error creating directories: " . $f->getPath());
}
}
} | php | protected function ensureDirExists($path)
{
$f = new PhingFile($this->getOutputDirectory(), $path);
if (!$f->exists()) {
if (!$f->mkdirs()) {
throw new BuildException("Error creating directories: " . $f->getPath());
}
}
} | [
"protected",
"function",
"ensureDirExists",
"(",
"$",
"path",
")",
"{",
"$",
"f",
"=",
"new",
"PhingFile",
"(",
"$",
"this",
"->",
"getOutputDirectory",
"(",
")",
",",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"f",
"->",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"f",
"->",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Error creating directories: \"",
".",
"$",
"f",
"->",
"getPath",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Utility method to create directory for package if it doesn't already exist.
@param string $path The [relative] package path.
@throws BuildException - if there is an error creating directories | [
"Utility",
"method",
"to",
"create",
"directory",
"for",
"package",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelOMTask.php#L58-L66 |
propelorm/Propel | generator/lib/task/PropelOMTask.php | PropelOMTask.build | protected function build(OMBuilder $builder, $overwrite = true)
{
$path = $builder->getClassFilePath();
$this->ensureDirExists(dirname($path));
$_f = new PhingFile($this->getOutputDirectory(), $path);
// skip files already created once
if ($_f->exists() && !$overwrite) {
$this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
return 0;
}
$script = $builder->build();
foreach ($builder->getWarnings() as $warning) {
$this->log($warning, Project::MSG_WARN);
}
// skip unchanged files
if ($_f->exists() && $script == $_f->contents()) {
$this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
return 0;
}
// write / overwrite new / changed files
$action = $_f->exists() ? 'Updating' : 'Creating';
$this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
file_put_contents($_f->getAbsolutePath(), $script);
return 1;
} | php | protected function build(OMBuilder $builder, $overwrite = true)
{
$path = $builder->getClassFilePath();
$this->ensureDirExists(dirname($path));
$_f = new PhingFile($this->getOutputDirectory(), $path);
// skip files already created once
if ($_f->exists() && !$overwrite) {
$this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
return 0;
}
$script = $builder->build();
foreach ($builder->getWarnings() as $warning) {
$this->log($warning, Project::MSG_WARN);
}
// skip unchanged files
if ($_f->exists() && $script == $_f->contents()) {
$this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
return 0;
}
// write / overwrite new / changed files
$action = $_f->exists() ? 'Updating' : 'Creating';
$this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
file_put_contents($_f->getAbsolutePath(), $script);
return 1;
} | [
"protected",
"function",
"build",
"(",
"OMBuilder",
"$",
"builder",
",",
"$",
"overwrite",
"=",
"true",
")",
"{",
"$",
"path",
"=",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
";",
"$",
"this",
"->",
"ensureDirExists",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"$",
"_f",
"=",
"new",
"PhingFile",
"(",
"$",
"this",
"->",
"getOutputDirectory",
"(",
")",
",",
"$",
"path",
")",
";",
"// skip files already created once",
"if",
"(",
"$",
"_f",
"->",
"exists",
"(",
")",
"&&",
"!",
"$",
"overwrite",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"\\t-> (exists) \"",
".",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"return",
"0",
";",
"}",
"$",
"script",
"=",
"$",
"builder",
"->",
"build",
"(",
")",
";",
"foreach",
"(",
"$",
"builder",
"->",
"getWarnings",
"(",
")",
"as",
"$",
"warning",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"warning",
",",
"Project",
"::",
"MSG_WARN",
")",
";",
"}",
"// skip unchanged files",
"if",
"(",
"$",
"_f",
"->",
"exists",
"(",
")",
"&&",
"$",
"script",
"==",
"$",
"_f",
"->",
"contents",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"\\t-> (unchanged) \"",
".",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"return",
"0",
";",
"}",
"// write / overwrite new / changed files",
"$",
"action",
"=",
"$",
"_f",
"->",
"exists",
"(",
")",
"?",
"'Updating'",
":",
"'Creating'",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"\"\\t-> %s %s (table: %s, builder: %s)\"",
",",
"$",
"action",
",",
"$",
"builder",
"->",
"getClassFilePath",
"(",
")",
",",
"$",
"builder",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
",",
"get_class",
"(",
"$",
"builder",
")",
")",
")",
";",
"file_put_contents",
"(",
"$",
"_f",
"->",
"getAbsolutePath",
"(",
")",
",",
"$",
"script",
")",
";",
"return",
"1",
";",
"}"
] | Uses a builder class to create the output class.
This method assumes that the DataModelBuilder class has been initialized with the build properties.
@param OMBuilder $builder
@param boolean $overwrite Whether to overwrite existing files with te new ones (default is YES).
@todo -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic).
@return int | [
"Uses",
"a",
"builder",
"class",
"to",
"create",
"the",
"output",
"class",
".",
"This",
"method",
"assumes",
"that",
"the",
"DataModelBuilder",
"class",
"has",
"been",
"initialized",
"with",
"the",
"build",
"properties",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelOMTask.php#L78-L110 |
propelorm/Propel | generator/lib/task/PropelOMTask.php | PropelOMTask.main | public function main()
{
// check to make sure task received all correct params
$this->validate();
$generatorConfig = $this->getGeneratorConfig();
$totalNbFiles = 0;
$dataModels = $this->getDataModels();
$this->log('Generating PHP files...');
foreach ($dataModels as $dataModel) {
$this->log("Datamodel: " . $dataModel->getName(), Project::MSG_VERBOSE);
foreach ($dataModel->getDatabases() as $database) {
if ($this->getGeneratorConfig()->getBuildProperty('disableIdentifierQuoting')) {
$database->getPlatform()->setIdentifierQuoting(false);
}
$this->log(" - Database: " . $database->getName(), Project::MSG_VERBOSE);
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
$nbWrittenFiles = 0;
$this->log(" + Table: " . $table->getName(), Project::MSG_VERBOSE);
// -----------------------------------------------------------------------------------------
// Create Peer, Object, and TableMap classes
// -----------------------------------------------------------------------------------------
// these files are always created / overwrite any existing files
foreach (array('peer', 'object', 'tablemap', 'query') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder);
}
// -----------------------------------------------------------------------------------------
// Create [empty] stub Peer and Object classes if they don't exist
// -----------------------------------------------------------------------------------------
// these classes are only generated if they don't already exist
foreach (array('peerstub', 'objectstub', 'querystub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
// -----------------------------------------------------------------------------------------
// Create [empty] stub child Object classes if they don't exist
// -----------------------------------------------------------------------------------------
// If table has enumerated children (uses inheritance) then create the empty child stub classes if they don't already exist.
if ($col = $table->getChildrenColumn()) {
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
foreach (array('queryinheritance') as $target) {
if (!$child->getAncestor()) {
continue;
}
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$nbWrittenFiles += $this->build($builder, $overwrite = true);
}
foreach (array('objectmultiextend', 'queryinheritancestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
} // foreach
} // if col->is enumerated
} // if tbl->getChildrenCol
// -----------------------------------------------------------------------------------------
// Create [empty] Interface if it doesn't exist
// -----------------------------------------------------------------------------------------
// Create [empty] interface if it does not already exist
if ($table->getInterface()) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
// -----------------------------------------------------------------------------------------
// Create tree Node classes
// -----------------------------------------------------------------------------------------
if ($table->treeMode()) {
switch ($table->treeMode()) {
case 'NestedSet':
foreach (array('nestedsetpeer', 'nestedset') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder);
}
break;
case 'MaterializedPath':
foreach (array('nodepeer', 'node') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder);
}
foreach (array('nodepeerstub', 'nodestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
break;
case 'AdjacencyList':
// No implementation for this yet.
default:
break;
}
} // if Table->treeMode()
// ----------------------------------
// Create classes added by behaviors
// ----------------------------------
if ($table->hasAdditionalBuilders()) {
foreach ($table->getAdditionalBuilders() as $builderClass) {
$builder = new $builderClass($table);
$builder->setGeneratorConfig($generatorConfig);
$nbWrittenFiles += $this->build($builder, isset($builder->overwrite) ? $builder->overwrite : true);
}
}
$totalNbFiles += $nbWrittenFiles;
if ($nbWrittenFiles == 0) {
$this->log("\t\t(no change)", Project::MSG_VERBOSE);
}
} // if !$table->isForReferenceOnly()
} // foreach table
} // foreach database
} // foreach dataModel
if ($totalNbFiles) {
$this->log(sprintf("Object model generation complete - %d files written", $totalNbFiles));
} else {
$this->log("Object model generation complete - All files already up to date");
}
} | php | public function main()
{
// check to make sure task received all correct params
$this->validate();
$generatorConfig = $this->getGeneratorConfig();
$totalNbFiles = 0;
$dataModels = $this->getDataModels();
$this->log('Generating PHP files...');
foreach ($dataModels as $dataModel) {
$this->log("Datamodel: " . $dataModel->getName(), Project::MSG_VERBOSE);
foreach ($dataModel->getDatabases() as $database) {
if ($this->getGeneratorConfig()->getBuildProperty('disableIdentifierQuoting')) {
$database->getPlatform()->setIdentifierQuoting(false);
}
$this->log(" - Database: " . $database->getName(), Project::MSG_VERBOSE);
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
$nbWrittenFiles = 0;
$this->log(" + Table: " . $table->getName(), Project::MSG_VERBOSE);
// -----------------------------------------------------------------------------------------
// Create Peer, Object, and TableMap classes
// -----------------------------------------------------------------------------------------
// these files are always created / overwrite any existing files
foreach (array('peer', 'object', 'tablemap', 'query') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder);
}
// -----------------------------------------------------------------------------------------
// Create [empty] stub Peer and Object classes if they don't exist
// -----------------------------------------------------------------------------------------
// these classes are only generated if they don't already exist
foreach (array('peerstub', 'objectstub', 'querystub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
// -----------------------------------------------------------------------------------------
// Create [empty] stub child Object classes if they don't exist
// -----------------------------------------------------------------------------------------
// If table has enumerated children (uses inheritance) then create the empty child stub classes if they don't already exist.
if ($col = $table->getChildrenColumn()) {
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
foreach (array('queryinheritance') as $target) {
if (!$child->getAncestor()) {
continue;
}
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$nbWrittenFiles += $this->build($builder, $overwrite = true);
}
foreach (array('objectmultiextend', 'queryinheritancestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
} // foreach
} // if col->is enumerated
} // if tbl->getChildrenCol
// -----------------------------------------------------------------------------------------
// Create [empty] Interface if it doesn't exist
// -----------------------------------------------------------------------------------------
// Create [empty] interface if it does not already exist
if ($table->getInterface()) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
// -----------------------------------------------------------------------------------------
// Create tree Node classes
// -----------------------------------------------------------------------------------------
if ($table->treeMode()) {
switch ($table->treeMode()) {
case 'NestedSet':
foreach (array('nestedsetpeer', 'nestedset') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder);
}
break;
case 'MaterializedPath':
foreach (array('nodepeer', 'node') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder);
}
foreach (array('nodepeerstub', 'nodestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$nbWrittenFiles += $this->build($builder, $overwrite = false);
}
break;
case 'AdjacencyList':
// No implementation for this yet.
default:
break;
}
} // if Table->treeMode()
// ----------------------------------
// Create classes added by behaviors
// ----------------------------------
if ($table->hasAdditionalBuilders()) {
foreach ($table->getAdditionalBuilders() as $builderClass) {
$builder = new $builderClass($table);
$builder->setGeneratorConfig($generatorConfig);
$nbWrittenFiles += $this->build($builder, isset($builder->overwrite) ? $builder->overwrite : true);
}
}
$totalNbFiles += $nbWrittenFiles;
if ($nbWrittenFiles == 0) {
$this->log("\t\t(no change)", Project::MSG_VERBOSE);
}
} // if !$table->isForReferenceOnly()
} // foreach table
} // foreach database
} // foreach dataModel
if ($totalNbFiles) {
$this->log(sprintf("Object model generation complete - %d files written", $totalNbFiles));
} else {
$this->log("Object model generation complete - All files already up to date");
}
} | [
"public",
"function",
"main",
"(",
")",
"{",
"// check to make sure task received all correct params",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"$",
"generatorConfig",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
";",
"$",
"totalNbFiles",
"=",
"0",
";",
"$",
"dataModels",
"=",
"$",
"this",
"->",
"getDataModels",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Generating PHP files...'",
")",
";",
"foreach",
"(",
"$",
"dataModels",
"as",
"$",
"dataModel",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Datamodel: \"",
".",
"$",
"dataModel",
"->",
"getName",
"(",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"foreach",
"(",
"$",
"dataModel",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"database",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getBuildProperty",
"(",
"'disableIdentifierQuoting'",
")",
")",
"{",
"$",
"database",
"->",
"getPlatform",
"(",
")",
"->",
"setIdentifierQuoting",
"(",
"false",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"\" - Database: \"",
".",
"$",
"database",
"->",
"getName",
"(",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"foreach",
"(",
"$",
"database",
"->",
"getTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"$",
"table",
"->",
"isForReferenceOnly",
"(",
")",
")",
"{",
"$",
"nbWrittenFiles",
"=",
"0",
";",
"$",
"this",
"->",
"log",
"(",
"\" + Table: \"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"// -----------------------------------------------------------------------------------------",
"// Create Peer, Object, and TableMap classes",
"// -----------------------------------------------------------------------------------------",
"// these files are always created / overwrite any existing files",
"foreach",
"(",
"array",
"(",
"'peer'",
",",
"'object'",
",",
"'tablemap'",
",",
"'query'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
")",
";",
"}",
"// -----------------------------------------------------------------------------------------",
"// Create [empty] stub Peer and Object classes if they don't exist",
"// -----------------------------------------------------------------------------------------",
"// these classes are only generated if they don't already exist",
"foreach",
"(",
"array",
"(",
"'peerstub'",
",",
"'objectstub'",
",",
"'querystub'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
",",
"$",
"overwrite",
"=",
"false",
")",
";",
"}",
"// -----------------------------------------------------------------------------------------",
"// Create [empty] stub child Object classes if they don't exist",
"// -----------------------------------------------------------------------------------------",
"// If table has enumerated children (uses inheritance) then create the empty child stub classes if they don't already exist.",
"if",
"(",
"$",
"col",
"=",
"$",
"table",
"->",
"getChildrenColumn",
"(",
")",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isEnumeratedClasses",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"col",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"foreach",
"(",
"array",
"(",
"'queryinheritance'",
")",
"as",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"$",
"child",
"->",
"getAncestor",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"builder",
"->",
"setChild",
"(",
"$",
"child",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
",",
"$",
"overwrite",
"=",
"true",
")",
";",
"}",
"foreach",
"(",
"array",
"(",
"'objectmultiextend'",
",",
"'queryinheritancestub'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"builder",
"->",
"setChild",
"(",
"$",
"child",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
",",
"$",
"overwrite",
"=",
"false",
")",
";",
"}",
"}",
"// foreach",
"}",
"// if col->is enumerated",
"}",
"// if tbl->getChildrenCol",
"// -----------------------------------------------------------------------------------------",
"// Create [empty] Interface if it doesn't exist",
"// -----------------------------------------------------------------------------------------",
"// Create [empty] interface if it does not already exist",
"if",
"(",
"$",
"table",
"->",
"getInterface",
"(",
")",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"'interface'",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
",",
"$",
"overwrite",
"=",
"false",
")",
";",
"}",
"// -----------------------------------------------------------------------------------------",
"// Create tree Node classes",
"// -----------------------------------------------------------------------------------------",
"if",
"(",
"$",
"table",
"->",
"treeMode",
"(",
")",
")",
"{",
"switch",
"(",
"$",
"table",
"->",
"treeMode",
"(",
")",
")",
"{",
"case",
"'NestedSet'",
":",
"foreach",
"(",
"array",
"(",
"'nestedsetpeer'",
",",
"'nestedset'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
")",
";",
"}",
"break",
";",
"case",
"'MaterializedPath'",
":",
"foreach",
"(",
"array",
"(",
"'nodepeer'",
",",
"'node'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
")",
";",
"}",
"foreach",
"(",
"array",
"(",
"'nodepeerstub'",
",",
"'nodestub'",
")",
"as",
"$",
"target",
")",
"{",
"$",
"builder",
"=",
"$",
"generatorConfig",
"->",
"getConfiguredBuilder",
"(",
"$",
"table",
",",
"$",
"target",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
",",
"$",
"overwrite",
"=",
"false",
")",
";",
"}",
"break",
";",
"case",
"'AdjacencyList'",
":",
"// No implementation for this yet.",
"default",
":",
"break",
";",
"}",
"}",
"// if Table->treeMode()",
"// ----------------------------------",
"// Create classes added by behaviors",
"// ----------------------------------",
"if",
"(",
"$",
"table",
"->",
"hasAdditionalBuilders",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"getAdditionalBuilders",
"(",
")",
"as",
"$",
"builderClass",
")",
"{",
"$",
"builder",
"=",
"new",
"$",
"builderClass",
"(",
"$",
"table",
")",
";",
"$",
"builder",
"->",
"setGeneratorConfig",
"(",
"$",
"generatorConfig",
")",
";",
"$",
"nbWrittenFiles",
"+=",
"$",
"this",
"->",
"build",
"(",
"$",
"builder",
",",
"isset",
"(",
"$",
"builder",
"->",
"overwrite",
")",
"?",
"$",
"builder",
"->",
"overwrite",
":",
"true",
")",
";",
"}",
"}",
"$",
"totalNbFiles",
"+=",
"$",
"nbWrittenFiles",
";",
"if",
"(",
"$",
"nbWrittenFiles",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"\\t\\t(no change)\"",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"}",
"}",
"// if !$table->isForReferenceOnly()",
"}",
"// foreach table",
"}",
"// foreach database",
"}",
"// foreach dataModel",
"if",
"(",
"$",
"totalNbFiles",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"\"Object model generation complete - %d files written\"",
",",
"$",
"totalNbFiles",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Object model generation complete - All files already up to date\"",
")",
";",
"}",
"}"
] | Main method builds all the targets for a typical propel project. | [
"Main",
"method",
"builds",
"all",
"the",
"targets",
"for",
"a",
"typical",
"propel",
"project",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelOMTask.php#L115-L260 |
propelorm/Propel | generator/lib/platform/OraclePlatform.php | OraclePlatform.initialize | protected function initialize()
{
parent::initialize();
$this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN_EMU, "NUMBER", "1", "0");
$this->schemaDomainMap[PropelTypes::CLOB] = new Domain(PropelTypes::CLOB_EMU, "CLOB");
$this->schemaDomainMap[PropelTypes::CLOB_EMU] = $this->schemaDomainMap[PropelTypes::CLOB];
$this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, "NUMBER", "3", "0"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, "NUMBER", "5", "0"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, "NUMBER", "20", "0"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, "FLOAT"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DECIMAL, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARCHAR, "NVARCHAR2"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "NVARCHAR2", "2000"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, "DATE"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATE"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, "TIMESTAMP"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "LONG RAW"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "BLOB"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONG RAW"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, "NVARCHAR2", "2000"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, "NVARCHAR2", "2000"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, "NUMBER", "3", "0"));
} | php | protected function initialize()
{
parent::initialize();
$this->schemaDomainMap[PropelTypes::BOOLEAN] = new Domain(PropelTypes::BOOLEAN_EMU, "NUMBER", "1", "0");
$this->schemaDomainMap[PropelTypes::CLOB] = new Domain(PropelTypes::CLOB_EMU, "CLOB");
$this->schemaDomainMap[PropelTypes::CLOB_EMU] = $this->schemaDomainMap[PropelTypes::CLOB];
$this->setSchemaDomainMapping(new Domain(PropelTypes::TINYINT, "NUMBER", "3", "0"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::SMALLINT, "NUMBER", "5", "0"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::INTEGER, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BIGINT, "NUMBER", "20", "0"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::REAL, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DOUBLE, "FLOAT"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DECIMAL, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, "NUMBER"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARCHAR, "NVARCHAR2"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, "NVARCHAR2", "2000"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIME, "DATE"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, "DATE"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::TIMESTAMP, "TIMESTAMP"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, "LONG RAW"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, "BLOB"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, "LONG RAW"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, "NVARCHAR2", "2000"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, "NVARCHAR2", "2000"));
$this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, "NUMBER", "3", "0"));
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"parent",
"::",
"initialize",
"(",
")",
";",
"$",
"this",
"->",
"schemaDomainMap",
"[",
"PropelTypes",
"::",
"BOOLEAN",
"]",
"=",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"BOOLEAN_EMU",
",",
"\"NUMBER\"",
",",
"\"1\"",
",",
"\"0\"",
")",
";",
"$",
"this",
"->",
"schemaDomainMap",
"[",
"PropelTypes",
"::",
"CLOB",
"]",
"=",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"CLOB_EMU",
",",
"\"CLOB\"",
")",
";",
"$",
"this",
"->",
"schemaDomainMap",
"[",
"PropelTypes",
"::",
"CLOB_EMU",
"]",
"=",
"$",
"this",
"->",
"schemaDomainMap",
"[",
"PropelTypes",
"::",
"CLOB",
"]",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"TINYINT",
",",
"\"NUMBER\"",
",",
"\"3\"",
",",
"\"0\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"SMALLINT",
",",
"\"NUMBER\"",
",",
"\"5\"",
",",
"\"0\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"INTEGER",
",",
"\"NUMBER\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"BIGINT",
",",
"\"NUMBER\"",
",",
"\"20\"",
",",
"\"0\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"REAL",
",",
"\"NUMBER\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"DOUBLE",
",",
"\"FLOAT\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"DECIMAL",
",",
"\"NUMBER\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"NUMERIC",
",",
"\"NUMBER\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"VARCHAR",
",",
"\"NVARCHAR2\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"LONGVARCHAR",
",",
"\"NVARCHAR2\"",
",",
"\"2000\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"TIME",
",",
"\"DATE\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"DATE",
",",
"\"DATE\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"TIMESTAMP",
",",
"\"TIMESTAMP\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"BINARY",
",",
"\"LONG RAW\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"VARBINARY",
",",
"\"BLOB\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"LONGVARBINARY",
",",
"\"LONG RAW\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"OBJECT",
",",
"\"NVARCHAR2\"",
",",
"\"2000\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"PHP_ARRAY",
",",
"\"NVARCHAR2\"",
",",
"\"2000\"",
")",
")",
";",
"$",
"this",
"->",
"setSchemaDomainMapping",
"(",
"new",
"Domain",
"(",
"PropelTypes",
"::",
"ENUM",
",",
"\"NUMBER\"",
",",
"\"3\"",
",",
"\"0\"",
")",
")",
";",
"}"
] | Initializes db specific domain mapping. | [
"Initializes",
"db",
"specific",
"domain",
"mapping",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/platform/OraclePlatform.php#L28-L53 |
propelorm/Propel | generator/lib/platform/OraclePlatform.php | OraclePlatform.generateBlockStorage | public function generateBlockStorage($object, $isPrimaryKey = false)
{
$vendorSpecific = $object->getVendorInfoForType('oracle');
if ($vendorSpecific->isEmpty()) {
return '';
}
if ($isPrimaryKey) {
$physicalParameters = "
USING INDEX
";
$prefix = "PK";
} else {
$physicalParameters = "\n";
$prefix = "";
}
if ($vendorSpecific->hasParameter($prefix . 'PCTFree')) {
$physicalParameters .= "PCTFREE " . $vendorSpecific->getParameter($prefix . 'PCTFree') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'InitTrans')) {
$physicalParameters .= "INITRANS " . $vendorSpecific->getParameter($prefix . 'InitTrans') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'MinExtents') || $vendorSpecific->hasParameter($prefix . 'MaxExtents') || $vendorSpecific->hasParameter($prefix . 'PCTIncrease')) {
$physicalParameters .= "STORAGE
(
";
if ($vendorSpecific->hasParameter($prefix . 'MinExtents')) {
$physicalParameters .= " MINEXTENTS " . $vendorSpecific->getParameter($prefix . 'MinExtents') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'MaxExtents')) {
$physicalParameters .= " MAXEXTENTS " . $vendorSpecific->getParameter($prefix . 'MaxExtents') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'PCTIncrease')) {
$physicalParameters .= " PCTINCREASE " . $vendorSpecific->getParameter($prefix . 'PCTIncrease') . "
";
}
$physicalParameters .= ")
";
}
if ($vendorSpecific->hasParameter($prefix . 'Tablespace')) {
$physicalParameters .= "TABLESPACE " . $vendorSpecific->getParameter($prefix . 'Tablespace');
}
return $physicalParameters;
} | php | public function generateBlockStorage($object, $isPrimaryKey = false)
{
$vendorSpecific = $object->getVendorInfoForType('oracle');
if ($vendorSpecific->isEmpty()) {
return '';
}
if ($isPrimaryKey) {
$physicalParameters = "
USING INDEX
";
$prefix = "PK";
} else {
$physicalParameters = "\n";
$prefix = "";
}
if ($vendorSpecific->hasParameter($prefix . 'PCTFree')) {
$physicalParameters .= "PCTFREE " . $vendorSpecific->getParameter($prefix . 'PCTFree') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'InitTrans')) {
$physicalParameters .= "INITRANS " . $vendorSpecific->getParameter($prefix . 'InitTrans') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'MinExtents') || $vendorSpecific->hasParameter($prefix . 'MaxExtents') || $vendorSpecific->hasParameter($prefix . 'PCTIncrease')) {
$physicalParameters .= "STORAGE
(
";
if ($vendorSpecific->hasParameter($prefix . 'MinExtents')) {
$physicalParameters .= " MINEXTENTS " . $vendorSpecific->getParameter($prefix . 'MinExtents') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'MaxExtents')) {
$physicalParameters .= " MAXEXTENTS " . $vendorSpecific->getParameter($prefix . 'MaxExtents') . "
";
}
if ($vendorSpecific->hasParameter($prefix . 'PCTIncrease')) {
$physicalParameters .= " PCTINCREASE " . $vendorSpecific->getParameter($prefix . 'PCTIncrease') . "
";
}
$physicalParameters .= ")
";
}
if ($vendorSpecific->hasParameter($prefix . 'Tablespace')) {
$physicalParameters .= "TABLESPACE " . $vendorSpecific->getParameter($prefix . 'Tablespace');
}
return $physicalParameters;
} | [
"public",
"function",
"generateBlockStorage",
"(",
"$",
"object",
",",
"$",
"isPrimaryKey",
"=",
"false",
")",
"{",
"$",
"vendorSpecific",
"=",
"$",
"object",
"->",
"getVendorInfoForType",
"(",
"'oracle'",
")",
";",
"if",
"(",
"$",
"vendorSpecific",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"isPrimaryKey",
")",
"{",
"$",
"physicalParameters",
"=",
"\"\nUSING INDEX\n\"",
";",
"$",
"prefix",
"=",
"\"PK\"",
";",
"}",
"else",
"{",
"$",
"physicalParameters",
"=",
"\"\\n\"",
";",
"$",
"prefix",
"=",
"\"\"",
";",
"}",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'PCTFree'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"PCTFREE \"",
".",
"$",
"vendorSpecific",
"->",
"getParameter",
"(",
"$",
"prefix",
".",
"'PCTFree'",
")",
".",
"\"\n\"",
";",
"}",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'InitTrans'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"INITRANS \"",
".",
"$",
"vendorSpecific",
"->",
"getParameter",
"(",
"$",
"prefix",
".",
"'InitTrans'",
")",
".",
"\"\n\"",
";",
"}",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'MinExtents'",
")",
"||",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'MaxExtents'",
")",
"||",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'PCTIncrease'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"STORAGE\n(\n\"",
";",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'MinExtents'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"\tMINEXTENTS \"",
".",
"$",
"vendorSpecific",
"->",
"getParameter",
"(",
"$",
"prefix",
".",
"'MinExtents'",
")",
".",
"\"\n\"",
";",
"}",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'MaxExtents'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"\tMAXEXTENTS \"",
".",
"$",
"vendorSpecific",
"->",
"getParameter",
"(",
"$",
"prefix",
".",
"'MaxExtents'",
")",
".",
"\"\n\"",
";",
"}",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'PCTIncrease'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"\tPCTINCREASE \"",
".",
"$",
"vendorSpecific",
"->",
"getParameter",
"(",
"$",
"prefix",
".",
"'PCTIncrease'",
")",
".",
"\"\n\"",
";",
"}",
"$",
"physicalParameters",
".=",
"\")\n\"",
";",
"}",
"if",
"(",
"$",
"vendorSpecific",
"->",
"hasParameter",
"(",
"$",
"prefix",
".",
"'Tablespace'",
")",
")",
"{",
"$",
"physicalParameters",
".=",
"\"TABLESPACE \"",
".",
"$",
"vendorSpecific",
"->",
"getParameter",
"(",
"$",
"prefix",
".",
"'Tablespace'",
")",
";",
"}",
"return",
"$",
"physicalParameters",
";",
"}"
] | Generate oracle block storage
@param Table|Index $object object with vendor parameters
@param bool $isPrimaryKey is a primary key vendor part
@return string oracle vendor sql part | [
"Generate",
"oracle",
"block",
"storage"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/platform/OraclePlatform.php#L265-L314 |
propelorm/Propel | generator/lib/platform/OraclePlatform.php | OraclePlatform.getAddIndexDDL | public function getAddIndexDDL(Index $index)
{
// don't create index form primary key
if ($this->getPrimaryKeyName($index->getTable()) == $this->quoteIdentifier($index->getName())) {
return "";
}
$pattern = "
CREATE %sINDEX %s ON %s (%s)%s;
";
return sprintf($pattern,
$index->getIsUnique() ? 'UNIQUE ' : '',
$this->quoteIdentifier($index->getName()),
$this->quoteIdentifier($index->getTable()->getName()),
$this->getColumnListDDL($index->getColumns()),
$this->generateBlockStorage($index)
);
} | php | public function getAddIndexDDL(Index $index)
{
// don't create index form primary key
if ($this->getPrimaryKeyName($index->getTable()) == $this->quoteIdentifier($index->getName())) {
return "";
}
$pattern = "
CREATE %sINDEX %s ON %s (%s)%s;
";
return sprintf($pattern,
$index->getIsUnique() ? 'UNIQUE ' : '',
$this->quoteIdentifier($index->getName()),
$this->quoteIdentifier($index->getTable()->getName()),
$this->getColumnListDDL($index->getColumns()),
$this->generateBlockStorage($index)
);
} | [
"public",
"function",
"getAddIndexDDL",
"(",
"Index",
"$",
"index",
")",
"{",
"// don't create index form primary key",
"if",
"(",
"$",
"this",
"->",
"getPrimaryKeyName",
"(",
"$",
"index",
"->",
"getTable",
"(",
")",
")",
"==",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"pattern",
"=",
"\"\nCREATE %sINDEX %s ON %s (%s)%s;\n\"",
";",
"return",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"index",
"->",
"getIsUnique",
"(",
")",
"?",
"'UNIQUE '",
":",
"''",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
")",
",",
"$",
"this",
"->",
"getColumnListDDL",
"(",
"$",
"index",
"->",
"getColumns",
"(",
")",
")",
",",
"$",
"this",
"->",
"generateBlockStorage",
"(",
"$",
"index",
")",
")",
";",
"}"
] | Builds the DDL SQL to add an Index.
@param Index $index
@return string | [
"Builds",
"the",
"DDL",
"SQL",
"to",
"add",
"an",
"Index",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/platform/OraclePlatform.php#L323-L341 |
propelorm/Propel | generator/lib/platform/OraclePlatform.php | OraclePlatform.getColumnBindingPHP | public function getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab = " ")
{
if ($column->getPDOType() == PropelTypes::CLOB_EMU) {
return sprintf(
"%s\$stmt->bindParam(%s, %s, %s, strlen(%s));
",
$tab,
$identifier,
$columnValueAccessor,
PropelTypes::getPdoTypeString($column->getType()),
$columnValueAccessor
);
}
return parent::getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab);
} | php | public function getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab = " ")
{
if ($column->getPDOType() == PropelTypes::CLOB_EMU) {
return sprintf(
"%s\$stmt->bindParam(%s, %s, %s, strlen(%s));
",
$tab,
$identifier,
$columnValueAccessor,
PropelTypes::getPdoTypeString($column->getType()),
$columnValueAccessor
);
}
return parent::getColumnBindingPHP($column, $identifier, $columnValueAccessor, $tab);
} | [
"public",
"function",
"getColumnBindingPHP",
"(",
"$",
"column",
",",
"$",
"identifier",
",",
"$",
"columnValueAccessor",
",",
"$",
"tab",
"=",
"\"\t\t\t\"",
")",
"{",
"if",
"(",
"$",
"column",
"->",
"getPDOType",
"(",
")",
"==",
"PropelTypes",
"::",
"CLOB_EMU",
")",
"{",
"return",
"sprintf",
"(",
"\"%s\\$stmt->bindParam(%s, %s, %s, strlen(%s));\n\"",
",",
"$",
"tab",
",",
"$",
"identifier",
",",
"$",
"columnValueAccessor",
",",
"PropelTypes",
"::",
"getPdoTypeString",
"(",
"$",
"column",
"->",
"getType",
"(",
")",
")",
",",
"$",
"columnValueAccessor",
")",
";",
"}",
"return",
"parent",
"::",
"getColumnBindingPHP",
"(",
"$",
"column",
",",
"$",
"identifier",
",",
"$",
"columnValueAccessor",
",",
"$",
"tab",
")",
";",
"}"
] | Get the PHP snippet for binding a value to a column.
Warning: duplicates logic from DBOracle::bindValue().
Any code modification here must be ported there. | [
"Get",
"the",
"PHP",
"snippet",
"for",
"binding",
"a",
"value",
"to",
"a",
"column",
".",
"Warning",
":",
"duplicates",
"logic",
"from",
"DBOracle",
"::",
"bindValue",
"()",
".",
"Any",
"code",
"modification",
"here",
"must",
"be",
"ported",
"there",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/platform/OraclePlatform.php#L348-L363 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.clear | public function clear()
{
$this->map = array();
$this->namedCriterions = array();
$this->ignoreCase = false;
$this->singleRecord = false;
$this->selectModifiers = array();
$this->selectColumns = array();
$this->orderByColumns = array();
$this->groupByColumns = array();
$this->having = null;
$this->asColumns = array();
$this->joins = array();
$this->selectQueries = array();
$this->dbName = $this->originalDbName;
$this->offset = 0;
$this->limit = 0;
$this->blobFlag = null;
$this->aliases = array();
$this->useTransaction = false;
$this->conditionalProxy = null;
$this->defaultCombineOperator = Criteria::LOGICAL_AND;
$this->primaryTableName = null;
$this->queryComment = null;
} | php | public function clear()
{
$this->map = array();
$this->namedCriterions = array();
$this->ignoreCase = false;
$this->singleRecord = false;
$this->selectModifiers = array();
$this->selectColumns = array();
$this->orderByColumns = array();
$this->groupByColumns = array();
$this->having = null;
$this->asColumns = array();
$this->joins = array();
$this->selectQueries = array();
$this->dbName = $this->originalDbName;
$this->offset = 0;
$this->limit = 0;
$this->blobFlag = null;
$this->aliases = array();
$this->useTransaction = false;
$this->conditionalProxy = null;
$this->defaultCombineOperator = Criteria::LOGICAL_AND;
$this->primaryTableName = null;
$this->queryComment = null;
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"map",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"namedCriterions",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"ignoreCase",
"=",
"false",
";",
"$",
"this",
"->",
"singleRecord",
"=",
"false",
";",
"$",
"this",
"->",
"selectModifiers",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"selectColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"orderByColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"groupByColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"having",
"=",
"null",
";",
"$",
"this",
"->",
"asColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"joins",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"selectQueries",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"dbName",
"=",
"$",
"this",
"->",
"originalDbName",
";",
"$",
"this",
"->",
"offset",
"=",
"0",
";",
"$",
"this",
"->",
"limit",
"=",
"0",
";",
"$",
"this",
"->",
"blobFlag",
"=",
"null",
";",
"$",
"this",
"->",
"aliases",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"useTransaction",
"=",
"false",
";",
"$",
"this",
"->",
"conditionalProxy",
"=",
"null",
";",
"$",
"this",
"->",
"defaultCombineOperator",
"=",
"Criteria",
"::",
"LOGICAL_AND",
";",
"$",
"this",
"->",
"primaryTableName",
"=",
"null",
";",
"$",
"this",
"->",
"queryComment",
"=",
"null",
";",
"}"
] | Brings this criteria back to its initial state, so that it
can be reused as if it was new. Except if the criteria has grown in
capacity, it is left at the current capacity.
@return void | [
"Brings",
"this",
"criteria",
"back",
"to",
"its",
"initial",
"state",
"so",
"that",
"it",
"can",
"be",
"reused",
"as",
"if",
"it",
"was",
"new",
".",
"Except",
"if",
"the",
"criteria",
"has",
"grown",
"in",
"capacity",
"it",
"is",
"left",
"at",
"the",
"current",
"capacity",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L304-L329 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.