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/model/ForeignKey.php | ForeignKey.isLocalPrimaryKey | public function isLocalPrimaryKey()
{
$localCols = $this->getLocalColumns();
$localPKColumnObjs = $this->getTable()->getPrimaryKey();
$localPKCols = array();
foreach ($localPKColumnObjs as $lPKCol) {
$localPKCols[] = $lPKCol->getName();
}
return ((count($localPKCols) === count($localCols)) && !array_diff($localPKCols, $localCols));
} | php | public function isLocalPrimaryKey()
{
$localCols = $this->getLocalColumns();
$localPKColumnObjs = $this->getTable()->getPrimaryKey();
$localPKCols = array();
foreach ($localPKColumnObjs as $lPKCol) {
$localPKCols[] = $lPKCol->getName();
}
return ((count($localPKCols) === count($localCols)) && !array_diff($localPKCols, $localCols));
} | [
"public",
"function",
"isLocalPrimaryKey",
"(",
")",
"{",
"$",
"localCols",
"=",
"$",
"this",
"->",
"getLocalColumns",
"(",
")",
";",
"$",
"localPKColumnObjs",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getPrimaryKey",
"(",
")",
";",
"$",
"localPKCols",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"localPKColumnObjs",
"as",
"$",
"lPKCol",
")",
"{",
"$",
"localPKCols",
"[",
"]",
"=",
"$",
"lPKCol",
"->",
"getName",
"(",
")",
";",
"}",
"return",
"(",
"(",
"count",
"(",
"$",
"localPKCols",
")",
"===",
"count",
"(",
"$",
"localCols",
")",
")",
"&&",
"!",
"array_diff",
"(",
"$",
"localPKCols",
",",
"$",
"localCols",
")",
")",
";",
"}"
] | Whether this foreign key is also the primary key of the local table.
@return boolean True if all local columns are at the same time a primary key | [
"Whether",
"this",
"foreign",
"key",
"is",
"also",
"the",
"primary",
"key",
"of",
"the",
"local",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L664-L676 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.isAtLeastOneLocalPrimaryKey | public function isAtLeastOneLocalPrimaryKey()
{
$localCols = $this->getLocalColumnObjects();
foreach ($localCols as $localCol) {
if ($this->getTable()->getColumn($localCol->getName())->isPrimaryKey()) {
return true;
}
}
return false;
} | php | public function isAtLeastOneLocalPrimaryKey()
{
$localCols = $this->getLocalColumnObjects();
foreach ($localCols as $localCol) {
if ($this->getTable()->getColumn($localCol->getName())->isPrimaryKey()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isAtLeastOneLocalPrimaryKey",
"(",
")",
"{",
"$",
"localCols",
"=",
"$",
"this",
"->",
"getLocalColumnObjects",
"(",
")",
";",
"foreach",
"(",
"$",
"localCols",
"as",
"$",
"localCol",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getColumn",
"(",
"$",
"localCol",
"->",
"getName",
"(",
")",
")",
"->",
"isPrimaryKey",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Whether at least one local column is also a primary key.
@return boolean True if there is at least one column that is a primary key | [
"Whether",
"at",
"least",
"one",
"local",
"column",
"is",
"also",
"a",
"primary",
"key",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L683-L694 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getOtherFks | public function getOtherFks()
{
$fks = array();
foreach ($this->getTable()->getForeignKeys() as $fk) {
if ($fk !== $this) {
$fks[] = $fk;
}
}
return $fks;
} | php | public function getOtherFks()
{
$fks = array();
foreach ($this->getTable()->getForeignKeys() as $fk) {
if ($fk !== $this) {
$fks[] = $fk;
}
}
return $fks;
} | [
"public",
"function",
"getOtherFks",
"(",
")",
"{",
"$",
"fks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getForeignKeys",
"(",
")",
"as",
"$",
"fk",
")",
"{",
"if",
"(",
"$",
"fk",
"!==",
"$",
"this",
")",
"{",
"$",
"fks",
"[",
"]",
"=",
"$",
"fk",
";",
"}",
"}",
"return",
"$",
"fks",
";",
"}"
] | Get the other foreign keys starting on the same table
Used in many-to-many relationships
@return ForeignKey | [
"Get",
"the",
"other",
"foreign",
"keys",
"starting",
"on",
"the",
"same",
"table",
"Used",
"in",
"many",
"-",
"to",
"-",
"many",
"relationships"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L753-L763 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.hasColumn | public function hasColumn($name, $normalize = true)
{
if ($name instanceof ColumnMap) {
$name = $name->getColumnName();
} elseif ($normalize) {
$name = ColumnMap::normalizeName($name);
}
return isset($this->columns[$name]);
} | php | public function hasColumn($name, $normalize = true)
{
if ($name instanceof ColumnMap) {
$name = $name->getColumnName();
} elseif ($normalize) {
$name = ColumnMap::normalizeName($name);
}
return isset($this->columns[$name]);
} | [
"public",
"function",
"hasColumn",
"(",
"$",
"name",
",",
"$",
"normalize",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"name",
"instanceof",
"ColumnMap",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"->",
"getColumnName",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"normalize",
")",
"{",
"$",
"name",
"=",
"ColumnMap",
"::",
"normalizeName",
"(",
"$",
"name",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Does this table contain the specified column?
@param mixed $name name of the column or ColumnMap instance
@param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
@return boolean True if the table contains the column. | [
"Does",
"this",
"table",
"contain",
"the",
"specified",
"column?"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L355-L364 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.getColumn | public function getColumn($name, $normalize = true)
{
if ($normalize) {
$name = ColumnMap::normalizeName($name);
}
if (!$this->hasColumn($name, false)) {
throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name);
}
return $this->columns[$name];
} | php | public function getColumn($name, $normalize = true)
{
if ($normalize) {
$name = ColumnMap::normalizeName($name);
}
if (!$this->hasColumn($name, false)) {
throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name);
}
return $this->columns[$name];
} | [
"public",
"function",
"getColumn",
"(",
"$",
"name",
",",
"$",
"normalize",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"normalize",
")",
"{",
"$",
"name",
"=",
"ColumnMap",
"::",
"normalizeName",
"(",
"$",
"name",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasColumn",
"(",
"$",
"name",
",",
"false",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot fetch ColumnMap for undefined column: \"",
".",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"columns",
"[",
"$",
"name",
"]",
";",
"}"
] | Get a ColumnMap for the table.
@param string $name A String with the name of the table.
@param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
@return ColumnMap A ColumnMap.
@throws PropelException if the column is undefined | [
"Get",
"a",
"ColumnMap",
"for",
"the",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L375-L385 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.getColumnByPhpName | public function getColumnByPhpName($phpName)
{
if (!isset($this->columnsByPhpName[$phpName])) {
throw new PropelException("Cannot fetch ColumnMap for undefined column phpName: " . $phpName);
}
return $this->columnsByPhpName[$phpName];
} | php | public function getColumnByPhpName($phpName)
{
if (!isset($this->columnsByPhpName[$phpName])) {
throw new PropelException("Cannot fetch ColumnMap for undefined column phpName: " . $phpName);
}
return $this->columnsByPhpName[$phpName];
} | [
"public",
"function",
"getColumnByPhpName",
"(",
"$",
"phpName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"columnsByPhpName",
"[",
"$",
"phpName",
"]",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot fetch ColumnMap for undefined column phpName: \"",
".",
"$",
"phpName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"columnsByPhpName",
"[",
"$",
"phpName",
"]",
";",
"}"
] | Get a ColumnMap for the table.
@param string $phpName A String with the name of the table.
@return ColumnMap A ColumnMap.
@throws PropelException if the column is undefined | [
"Get",
"a",
"ColumnMap",
"for",
"the",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L407-L414 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.addValidator | public function addValidator($columnName, $name, $classname, $value, $message)
{
if (false !== ($pos = strpos($columnName, '.'))) {
$columnName = substr($columnName, $pos + 1);
}
$col = $this->getColumn($columnName);
if ($col !== null) {
$validator = new ValidatorMap($col);
$validator->setName($name);
$validator->setClass($classname);
$validator->setValue($value);
$validator->setMessage($message);
$col->addValidator($validator);
}
} | php | public function addValidator($columnName, $name, $classname, $value, $message)
{
if (false !== ($pos = strpos($columnName, '.'))) {
$columnName = substr($columnName, $pos + 1);
}
$col = $this->getColumn($columnName);
if ($col !== null) {
$validator = new ValidatorMap($col);
$validator->setName($name);
$validator->setClass($classname);
$validator->setValue($value);
$validator->setMessage($message);
$col->addValidator($validator);
}
} | [
"public",
"function",
"addValidator",
"(",
"$",
"columnName",
",",
"$",
"name",
",",
"$",
"classname",
",",
"$",
"value",
",",
"$",
"message",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"columnName",
",",
"'.'",
")",
")",
")",
"{",
"$",
"columnName",
"=",
"substr",
"(",
"$",
"columnName",
",",
"$",
"pos",
"+",
"1",
")",
";",
"}",
"$",
"col",
"=",
"$",
"this",
"->",
"getColumn",
"(",
"$",
"columnName",
")",
";",
"if",
"(",
"$",
"col",
"!==",
"null",
")",
"{",
"$",
"validator",
"=",
"new",
"ValidatorMap",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"validator",
"->",
"setClass",
"(",
"$",
"classname",
")",
";",
"$",
"validator",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"validator",
"->",
"setMessage",
"(",
"$",
"message",
")",
";",
"$",
"col",
"->",
"addValidator",
"(",
"$",
"validator",
")",
";",
"}",
"}"
] | Add a validator to a table's column
@param string $columnName The name of the validator's column
@param string $name The rule name of this validator
@param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
@param string $value
@param string $message The error message which is returned on invalid values
@return void | [
"Add",
"a",
"validator",
"to",
"a",
"table",
"s",
"column"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L545-L560 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.addRelation | public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null, $pluralName = null)
{
// note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName()
// and this method autoloads the TableMap if the table isn't loaded yet
$relation = new RelationMap($name);
$relation->setType($type);
$relation->setOnUpdate($onUpdate);
$relation->setOnDelete($onDelete);
if (null !== $pluralName) {
$relation->setPluralName($pluralName);
}
// set tables
if ($type == RelationMap::MANY_TO_ONE) {
$relation->setLocalTable($this);
$relation->setForeignTable($this->dbMap->getTableByPhpName($tablePhpName));
} else {
$relation->setLocalTable($this->dbMap->getTableByPhpName($tablePhpName));
$relation->setForeignTable($this);
$columnMapping = array_flip($columnMapping);
}
// set columns
foreach ($columnMapping as $local => $foreign) {
$relation->addColumnMapping(
$relation->getLocalTable()->getColumn($local),
$relation->getForeignTable()->getColumn($foreign)
);
}
$this->relations[$name] = $relation;
return $relation;
} | php | public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null, $pluralName = null)
{
// note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName()
// and this method autoloads the TableMap if the table isn't loaded yet
$relation = new RelationMap($name);
$relation->setType($type);
$relation->setOnUpdate($onUpdate);
$relation->setOnDelete($onDelete);
if (null !== $pluralName) {
$relation->setPluralName($pluralName);
}
// set tables
if ($type == RelationMap::MANY_TO_ONE) {
$relation->setLocalTable($this);
$relation->setForeignTable($this->dbMap->getTableByPhpName($tablePhpName));
} else {
$relation->setLocalTable($this->dbMap->getTableByPhpName($tablePhpName));
$relation->setForeignTable($this);
$columnMapping = array_flip($columnMapping);
}
// set columns
foreach ($columnMapping as $local => $foreign) {
$relation->addColumnMapping(
$relation->getLocalTable()->getColumn($local),
$relation->getForeignTable()->getColumn($foreign)
);
}
$this->relations[$name] = $relation;
return $relation;
} | [
"public",
"function",
"addRelation",
"(",
"$",
"name",
",",
"$",
"tablePhpName",
",",
"$",
"type",
",",
"$",
"columnMapping",
"=",
"array",
"(",
")",
",",
"$",
"onDelete",
"=",
"null",
",",
"$",
"onUpdate",
"=",
"null",
",",
"$",
"pluralName",
"=",
"null",
")",
"{",
"// note: using phpName for the second table allows the use of DatabaseMap::getTableByPhpName()",
"// and this method autoloads the TableMap if the table isn't loaded yet",
"$",
"relation",
"=",
"new",
"RelationMap",
"(",
"$",
"name",
")",
";",
"$",
"relation",
"->",
"setType",
"(",
"$",
"type",
")",
";",
"$",
"relation",
"->",
"setOnUpdate",
"(",
"$",
"onUpdate",
")",
";",
"$",
"relation",
"->",
"setOnDelete",
"(",
"$",
"onDelete",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"pluralName",
")",
"{",
"$",
"relation",
"->",
"setPluralName",
"(",
"$",
"pluralName",
")",
";",
"}",
"// set tables",
"if",
"(",
"$",
"type",
"==",
"RelationMap",
"::",
"MANY_TO_ONE",
")",
"{",
"$",
"relation",
"->",
"setLocalTable",
"(",
"$",
"this",
")",
";",
"$",
"relation",
"->",
"setForeignTable",
"(",
"$",
"this",
"->",
"dbMap",
"->",
"getTableByPhpName",
"(",
"$",
"tablePhpName",
")",
")",
";",
"}",
"else",
"{",
"$",
"relation",
"->",
"setLocalTable",
"(",
"$",
"this",
"->",
"dbMap",
"->",
"getTableByPhpName",
"(",
"$",
"tablePhpName",
")",
")",
";",
"$",
"relation",
"->",
"setForeignTable",
"(",
"$",
"this",
")",
";",
"$",
"columnMapping",
"=",
"array_flip",
"(",
"$",
"columnMapping",
")",
";",
"}",
"// set columns",
"foreach",
"(",
"$",
"columnMapping",
"as",
"$",
"local",
"=>",
"$",
"foreign",
")",
"{",
"$",
"relation",
"->",
"addColumnMapping",
"(",
"$",
"relation",
"->",
"getLocalTable",
"(",
")",
"->",
"getColumn",
"(",
"$",
"local",
")",
",",
"$",
"relation",
"->",
"getForeignTable",
"(",
")",
"->",
"getColumn",
"(",
"$",
"foreign",
")",
")",
";",
"}",
"$",
"this",
"->",
"relations",
"[",
"$",
"name",
"]",
"=",
"$",
"relation",
";",
"return",
"$",
"relation",
";",
"}"
] | Adds a RelationMap to the table
@param string $name The relation name
@param string $tablePhpName The related table name
@param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE)
@param array $columnMapping An associative array mapping column names (local => foreign)
@param string $onDelete SQL behavior upon deletion ('SET NULL', 'CASCADE', ...)
@param string $onUpdate SQL behavior upon update ('SET NULL', 'CASCADE', ...)
@param string $pluralName Optional plural name for *_TO_MANY relationships
@return RelationMap the built RelationMap object | [
"Adds",
"a",
"RelationMap",
"to",
"the",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L584-L614 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.getRelation | public function getRelation($name)
{
if (!array_key_exists($name, $this->getRelations())) {
throw new PropelException('Calling getRelation() on an unknown relation, ' . $name);
}
return $this->relations[$name];
} | php | public function getRelation($name)
{
if (!array_key_exists($name, $this->getRelations())) {
throw new PropelException('Calling getRelation() on an unknown relation, ' . $name);
}
return $this->relations[$name];
} | [
"public",
"function",
"getRelation",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getRelations",
"(",
")",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Calling getRelation() on an unknown relation, '",
".",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"relations",
"[",
"$",
"name",
"]",
";",
"}"
] | Gets a RelationMap of the table by relation name
This method will build the relations if they are not built yet
@param String $name The relation name
@return RelationMap The relation object
@throws PropelException When called on an inexistent relation | [
"Gets",
"a",
"RelationMap",
"of",
"the",
"table",
"by",
"relation",
"name",
"This",
"method",
"will",
"build",
"the",
"relations",
"if",
"they",
"are",
"not",
"built",
"yet"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L638-L645 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.removePrefix | protected function removePrefix($data)
{
return $this->hasPrefix($data) ? substr($data, strlen($this->prefix)) : $data;
} | php | protected function removePrefix($data)
{
return $this->hasPrefix($data) ? substr($data, strlen($this->prefix)) : $data;
} | [
"protected",
"function",
"removePrefix",
"(",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"hasPrefix",
"(",
"$",
"data",
")",
"?",
"substr",
"(",
"$",
"data",
",",
"strlen",
"(",
"$",
"this",
"->",
"prefix",
")",
")",
":",
"$",
"data",
";",
"}"
] | Removes the PREFIX if found
@deprecated Not used anywhere in Propel
@param string $data A String.
@return string A String with data, but with prefix removed. | [
"Removes",
"the",
"PREFIX",
"if",
"found"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L801-L804 |
propelorm/Propel | runtime/lib/map/TableMap.php | TableMap.removeUnderScores | final public function removeUnderScores($data)
{
$out = '';
$tmp = $this->removePrefix($data);
$tok = strtok($tmp, '_');
while ($tok) {
$out .= ucfirst($tok);
$tok = strtok('_');
}
return $out;
} | php | final public function removeUnderScores($data)
{
$out = '';
$tmp = $this->removePrefix($data);
$tok = strtok($tmp, '_');
while ($tok) {
$out .= ucfirst($tok);
$tok = strtok('_');
}
return $out;
} | [
"final",
"public",
"function",
"removeUnderScores",
"(",
"$",
"data",
")",
"{",
"$",
"out",
"=",
"''",
";",
"$",
"tmp",
"=",
"$",
"this",
"->",
"removePrefix",
"(",
"$",
"data",
")",
";",
"$",
"tok",
"=",
"strtok",
"(",
"$",
"tmp",
",",
"'_'",
")",
";",
"while",
"(",
"$",
"tok",
")",
"{",
"$",
"out",
".=",
"ucfirst",
"(",
"$",
"tok",
")",
";",
"$",
"tok",
"=",
"strtok",
"(",
"'_'",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | Removes the PREFIX, removes the underscores and makes
first letter caps.
SCARAB_FOO_BAR becomes FooBar.
@deprecated Not used anywhere in Propel. At buildtime, use Column::generatePhpName() for that purpose
@param string $data
@return string A String with data processed. | [
"Removes",
"the",
"PREFIX",
"removes",
"the",
"underscores",
"and",
"makes",
"first",
"letter",
"caps",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/TableMap.php#L818-L829 |
propelorm/Propel | runtime/lib/adapter/DBMySQL.php | DBMySQL.prepareParams | public function prepareParams($params)
{
$params = parent::prepareParams($params);
// Whitelist based on https://bugs.php.net/bug.php?id=47802
// And https://bugs.php.net/bug.php?id=47802
$whitelist = array(
'ASCII',
'CP1250',
'CP1251',
'CP1252',
'CP1256',
'CP1257',
'GREEK',
'HEBREW',
'LATIN1',
'LATIN2',
'LATIN5',
'LATIN7',
'SWE7',
'UTF8',
'UTF-8',
);
if (isset($params['settings']['charset']['value'])) {
if (version_compare(PHP_VERSION, '5.3.6', '<')) {
$charset = strtoupper($params['settings']['charset']['value']);
if (!in_array($charset, $whitelist)) {
throw new PropelException(<<<EXCEPTION
Connection option "charset" cannot be used for MySQL connections in PHP versions older than 5.3.6.
Please refer to http://www.propelorm.org/ticket/1360 for instructions and details about the implications of
using a SET NAMES statement in the "queries" setting.
EXCEPTION
);
}
} else {
if (strpos($params['dsn'], ';charset=') === false) {
$params['dsn'] .= ';charset=' . $params['settings']['charset']['value'];
unset($params['settings']['charset']);
}
}
}
return $params;
} | php | public function prepareParams($params)
{
$params = parent::prepareParams($params);
// Whitelist based on https://bugs.php.net/bug.php?id=47802
// And https://bugs.php.net/bug.php?id=47802
$whitelist = array(
'ASCII',
'CP1250',
'CP1251',
'CP1252',
'CP1256',
'CP1257',
'GREEK',
'HEBREW',
'LATIN1',
'LATIN2',
'LATIN5',
'LATIN7',
'SWE7',
'UTF8',
'UTF-8',
);
if (isset($params['settings']['charset']['value'])) {
if (version_compare(PHP_VERSION, '5.3.6', '<')) {
$charset = strtoupper($params['settings']['charset']['value']);
if (!in_array($charset, $whitelist)) {
throw new PropelException(<<<EXCEPTION
Connection option "charset" cannot be used for MySQL connections in PHP versions older than 5.3.6.
Please refer to http://www.propelorm.org/ticket/1360 for instructions and details about the implications of
using a SET NAMES statement in the "queries" setting.
EXCEPTION
);
}
} else {
if (strpos($params['dsn'], ';charset=') === false) {
$params['dsn'] .= ';charset=' . $params['settings']['charset']['value'];
unset($params['settings']['charset']);
}
}
}
return $params;
} | [
"public",
"function",
"prepareParams",
"(",
"$",
"params",
")",
"{",
"$",
"params",
"=",
"parent",
"::",
"prepareParams",
"(",
"$",
"params",
")",
";",
"// Whitelist based on https://bugs.php.net/bug.php?id=47802",
"// And https://bugs.php.net/bug.php?id=47802",
"$",
"whitelist",
"=",
"array",
"(",
"'ASCII'",
",",
"'CP1250'",
",",
"'CP1251'",
",",
"'CP1252'",
",",
"'CP1256'",
",",
"'CP1257'",
",",
"'GREEK'",
",",
"'HEBREW'",
",",
"'LATIN1'",
",",
"'LATIN2'",
",",
"'LATIN5'",
",",
"'LATIN7'",
",",
"'SWE7'",
",",
"'UTF8'",
",",
"'UTF-8'",
",",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'settings'",
"]",
"[",
"'charset'",
"]",
"[",
"'value'",
"]",
")",
")",
"{",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.3.6'",
",",
"'<'",
")",
")",
"{",
"$",
"charset",
"=",
"strtoupper",
"(",
"$",
"params",
"[",
"'settings'",
"]",
"[",
"'charset'",
"]",
"[",
"'value'",
"]",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"charset",
",",
"$",
"whitelist",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"<<<EXCEPTION\nConnection option \"charset\" cannot be used for MySQL connections in PHP versions older than 5.3.6.\n Please refer to http://www.propelorm.org/ticket/1360 for instructions and details about the implications of\n using a SET NAMES statement in the \"queries\" setting.\nEXCEPTION",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"strpos",
"(",
"$",
"params",
"[",
"'dsn'",
"]",
",",
"';charset='",
")",
"===",
"false",
")",
"{",
"$",
"params",
"[",
"'dsn'",
"]",
".=",
"';charset='",
".",
"$",
"params",
"[",
"'settings'",
"]",
"[",
"'charset'",
"]",
"[",
"'value'",
"]",
";",
"unset",
"(",
"$",
"params",
"[",
"'settings'",
"]",
"[",
"'charset'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"params",
";",
"}"
] | Prepare connection parameters.
See: http://www.propelorm.org/ticket/1360
@param array $params
@return array
@throws PropelException | [
"Prepare",
"connection",
"parameters",
".",
"See",
":",
"http",
":",
"//",
"www",
".",
"propelorm",
".",
"org",
"/",
"ticket",
"/",
"1360"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBMySQL.php#L217-L261 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getPeerBuilder | public function getPeerBuilder()
{
if (!isset($this->peerBuilder)) {
$this->peerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'peer');
}
return $this->peerBuilder;
} | php | public function getPeerBuilder()
{
if (!isset($this->peerBuilder)) {
$this->peerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'peer');
}
return $this->peerBuilder;
} | [
"public",
"function",
"getPeerBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"peerBuilder",
")",
")",
"{",
"$",
"this",
"->",
"peerBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'peer'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"peerBuilder",
";",
"}"
] | Returns new or existing Peer builder class for this table.
@return PeerBuilder | [
"Returns",
"new",
"or",
"existing",
"Peer",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L190-L197 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getStubPeerBuilder | public function getStubPeerBuilder()
{
if (!isset($this->stubPeerBuilder)) {
$this->stubPeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'peerstub');
}
return $this->stubPeerBuilder;
} | php | public function getStubPeerBuilder()
{
if (!isset($this->stubPeerBuilder)) {
$this->stubPeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'peerstub');
}
return $this->stubPeerBuilder;
} | [
"public",
"function",
"getStubPeerBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"stubPeerBuilder",
")",
")",
"{",
"$",
"this",
"->",
"stubPeerBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'peerstub'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stubPeerBuilder",
";",
"}"
] | Returns new or existing stub Peer builder class for this table.
@return PeerBuilder | [
"Returns",
"new",
"or",
"existing",
"stub",
"Peer",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L218-L225 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getNodeBuilder | public function getNodeBuilder()
{
if (!isset($this->nodeBuilder)) {
$this->nodeBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'node');
}
return $this->nodeBuilder;
} | php | public function getNodeBuilder()
{
if (!isset($this->nodeBuilder)) {
$this->nodeBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'node');
}
return $this->nodeBuilder;
} | [
"public",
"function",
"getNodeBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nodeBuilder",
")",
")",
"{",
"$",
"this",
"->",
"nodeBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'node'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"nodeBuilder",
";",
"}"
] | Returns new or existing node Object builder class for this table.
@return ObjectBuilder | [
"Returns",
"new",
"or",
"existing",
"node",
"Object",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L330-L337 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getNodePeerBuilder | public function getNodePeerBuilder()
{
if (!isset($this->nodePeerBuilder)) {
$this->nodePeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nodepeer');
}
return $this->nodePeerBuilder;
} | php | public function getNodePeerBuilder()
{
if (!isset($this->nodePeerBuilder)) {
$this->nodePeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nodepeer');
}
return $this->nodePeerBuilder;
} | [
"public",
"function",
"getNodePeerBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nodePeerBuilder",
")",
")",
"{",
"$",
"this",
"->",
"nodePeerBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'nodepeer'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"nodePeerBuilder",
";",
"}"
] | Returns new or existing node Peer builder class for this table.
@return PeerBuilder | [
"Returns",
"new",
"or",
"existing",
"node",
"Peer",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L344-L351 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getStubNodeBuilder | public function getStubNodeBuilder()
{
if (!isset($this->stubNodeBuilder)) {
$this->stubNodeBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nodestub');
}
return $this->stubNodeBuilder;
} | php | public function getStubNodeBuilder()
{
if (!isset($this->stubNodeBuilder)) {
$this->stubNodeBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nodestub');
}
return $this->stubNodeBuilder;
} | [
"public",
"function",
"getStubNodeBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"stubNodeBuilder",
")",
")",
"{",
"$",
"this",
"->",
"stubNodeBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'nodestub'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stubNodeBuilder",
";",
"}"
] | Returns new or existing stub node Object builder class for this table.
@return ObjectBuilder | [
"Returns",
"new",
"or",
"existing",
"stub",
"node",
"Object",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L358-L365 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getStubNodePeerBuilder | public function getStubNodePeerBuilder()
{
if (!isset($this->stubNodePeerBuilder)) {
$this->stubNodePeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nodepeerstub');
}
return $this->stubNodePeerBuilder;
} | php | public function getStubNodePeerBuilder()
{
if (!isset($this->stubNodePeerBuilder)) {
$this->stubNodePeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nodepeerstub');
}
return $this->stubNodePeerBuilder;
} | [
"public",
"function",
"getStubNodePeerBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"stubNodePeerBuilder",
")",
")",
"{",
"$",
"this",
"->",
"stubNodePeerBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'nodepeerstub'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stubNodePeerBuilder",
";",
"}"
] | Returns new or existing stub node Peer builder class for this table.
@return PeerBuilder | [
"Returns",
"new",
"or",
"existing",
"stub",
"node",
"Peer",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L372-L379 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getNestedSetBuilder | public function getNestedSetBuilder()
{
if (!isset($this->nestedSetBuilder)) {
$this->nestedSetBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nestedset');
}
return $this->nestedSetBuilder;
} | php | public function getNestedSetBuilder()
{
if (!isset($this->nestedSetBuilder)) {
$this->nestedSetBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nestedset');
}
return $this->nestedSetBuilder;
} | [
"public",
"function",
"getNestedSetBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nestedSetBuilder",
")",
")",
"{",
"$",
"this",
"->",
"nestedSetBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'nestedset'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"nestedSetBuilder",
";",
"}"
] | Returns new or existing nested set object builder class for this table.
@return ObjectBuilder | [
"Returns",
"new",
"or",
"existing",
"nested",
"set",
"object",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L386-L393 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getNestedSetPeerBuilder | public function getNestedSetPeerBuilder()
{
if (!isset($this->nestedSetPeerBuilder)) {
$this->nestedSetPeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nestedsetpeer');
}
return $this->nestedSetPeerBuilder;
} | php | public function getNestedSetPeerBuilder()
{
if (!isset($this->nestedSetPeerBuilder)) {
$this->nestedSetPeerBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'nestedsetpeer');
}
return $this->nestedSetPeerBuilder;
} | [
"public",
"function",
"getNestedSetPeerBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nestedSetPeerBuilder",
")",
")",
"{",
"$",
"this",
"->",
"nestedSetPeerBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'nestedsetpeer'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"nestedSetPeerBuilder",
";",
"}"
] | Returns new or existing nested set Peer builder class for this table.
@return PeerBuilder | [
"Returns",
"new",
"or",
"existing",
"nested",
"set",
"Peer",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L400-L407 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getDataSQLBuilder | public function getDataSQLBuilder()
{
if (!isset($this->dataSqlBuilder)) {
$this->dataSqlBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'datasql');
}
return $this->dataSqlBuilder;
} | php | public function getDataSQLBuilder()
{
if (!isset($this->dataSqlBuilder)) {
$this->dataSqlBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'datasql');
}
return $this->dataSqlBuilder;
} | [
"public",
"function",
"getDataSQLBuilder",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dataSqlBuilder",
")",
")",
"{",
"$",
"this",
"->",
"dataSqlBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'datasql'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"dataSqlBuilder",
";",
"}"
] | Returns new or existing data sql builder class for this table.
@return DataSQLBuilder | [
"Returns",
"new",
"or",
"existing",
"data",
"sql",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L414-L421 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getNewQueryInheritanceBuilder | public function getNewQueryInheritanceBuilder($child)
{
$queryInheritanceBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'queryinheritance');
$queryInheritanceBuilder->setChild($child);
return $queryInheritanceBuilder;
} | php | public function getNewQueryInheritanceBuilder($child)
{
$queryInheritanceBuilder = $this->getGeneratorConfig()->getConfiguredBuilder($this->getTable(), 'queryinheritance');
$queryInheritanceBuilder->setChild($child);
return $queryInheritanceBuilder;
} | [
"public",
"function",
"getNewQueryInheritanceBuilder",
"(",
"$",
"child",
")",
"{",
"$",
"queryInheritanceBuilder",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredBuilder",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
",",
"'queryinheritance'",
")",
";",
"$",
"queryInheritanceBuilder",
"->",
"setChild",
"(",
"$",
"child",
")",
";",
"return",
"$",
"queryInheritanceBuilder",
";",
"}"
] | Returns new Query Inheritance builder class for this table.
@return ObjectBuilder | [
"Returns",
"new",
"Query",
"Inheritance",
"builder",
"class",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L534-L540 |
propelorm/Propel | generator/lib/builder/DataModelBuilder.php | DataModelBuilder.getPlatform | public function getPlatform()
{
if (null === $this->platform) {
// try to load the platform from the table
if ($this->getTable() && $this->getTable()->getDatabase()) {
$this->setPlatform($this->getTable()->getDatabase()->getPlatform());
}
}
return $this->platform;
} | php | public function getPlatform()
{
if (null === $this->platform) {
// try to load the platform from the table
if ($this->getTable() && $this->getTable()->getDatabase()) {
$this->setPlatform($this->getTable()->getDatabase()->getPlatform());
}
}
return $this->platform;
} | [
"public",
"function",
"getPlatform",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"platform",
")",
"{",
"// try to load the platform from the table",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"&&",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setPlatform",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getPlatform",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"platform",
";",
"}"
] | Convenience method to returns the Platform class for this table (database).
@return PropelPlatformInterface | [
"Convenience",
"method",
"to",
"returns",
"the",
"Platform",
"class",
"for",
"this",
"table",
"(",
"database",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/DataModelBuilder.php#L616-L626 |
propelorm/Propel | runtime/lib/formatter/PropelFormatter.php | PropelFormatter.init | public function init(ModelCriteria $criteria)
{
$this->dbName = $criteria->getDbName();
$this->setClass($criteria->getModelName());
$this->setWith($criteria->getWith());
$this->asColumns = $criteria->getAsColumns();
$this->hasLimit = $criteria->getLimit() != 0;
return $this;
} | php | public function init(ModelCriteria $criteria)
{
$this->dbName = $criteria->getDbName();
$this->setClass($criteria->getModelName());
$this->setWith($criteria->getWith());
$this->asColumns = $criteria->getAsColumns();
$this->hasLimit = $criteria->getLimit() != 0;
return $this;
} | [
"public",
"function",
"init",
"(",
"ModelCriteria",
"$",
"criteria",
")",
"{",
"$",
"this",
"->",
"dbName",
"=",
"$",
"criteria",
"->",
"getDbName",
"(",
")",
";",
"$",
"this",
"->",
"setClass",
"(",
"$",
"criteria",
"->",
"getModelName",
"(",
")",
")",
";",
"$",
"this",
"->",
"setWith",
"(",
"$",
"criteria",
"->",
"getWith",
"(",
")",
")",
";",
"$",
"this",
"->",
"asColumns",
"=",
"$",
"criteria",
"->",
"getAsColumns",
"(",
")",
";",
"$",
"this",
"->",
"hasLimit",
"=",
"$",
"criteria",
"->",
"getLimit",
"(",
")",
"!=",
"0",
";",
"return",
"$",
"this",
";",
"}"
] | Define the hydration schema based on a query object.
Fills the Formatter's properties using a Criteria as source
@param ModelCriteria $criteria
@return PropelFormatter The current formatter object | [
"Define",
"the",
"hydration",
"schema",
"based",
"on",
"a",
"query",
"object",
".",
"Fills",
"the",
"Formatter",
"s",
"properties",
"using",
"a",
"Criteria",
"as",
"source"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/formatter/PropelFormatter.php#L44-L53 |
propelorm/Propel | runtime/lib/formatter/PropelFormatter.php | PropelFormatter.getWorkerObject | protected function getWorkerObject($col, $class)
{
$key = $col . '_' . $class;
if (isset($this->currentObjects[$key])) {
$this->currentObjects[$key]->clear();
} else {
$this->currentObjects[$key] = new $class();
}
return $this->currentObjects[$key];
} | php | protected function getWorkerObject($col, $class)
{
$key = $col . '_' . $class;
if (isset($this->currentObjects[$key])) {
$this->currentObjects[$key]->clear();
} else {
$this->currentObjects[$key] = new $class();
}
return $this->currentObjects[$key];
} | [
"protected",
"function",
"getWorkerObject",
"(",
"$",
"col",
",",
"$",
"class",
")",
"{",
"$",
"key",
"=",
"$",
"col",
".",
"'_'",
".",
"$",
"class",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"currentObjects",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentObjects",
"[",
"$",
"key",
"]",
"->",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"currentObjects",
"[",
"$",
"key",
"]",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"currentObjects",
"[",
"$",
"key",
"]",
";",
"}"
] | Gets the worker object for the class.
To save memory, we don't create a new object for each row,
But we keep hydrating a single object per class.
The column offset in the row is used to index the array of classes
As there may be more than one object of the same class in the chain
@param int $col Offset of the object in the list of objects to hydrate
@param string $class Propel model object class
@return BaseObject | [
"Gets",
"the",
"worker",
"object",
"for",
"the",
"class",
".",
"To",
"save",
"memory",
"we",
"don",
"t",
"create",
"a",
"new",
"object",
"for",
"each",
"row",
"But",
"we",
"keep",
"hydrating",
"a",
"single",
"object",
"per",
"class",
".",
"The",
"column",
"offset",
"in",
"the",
"row",
"is",
"used",
"to",
"index",
"the",
"array",
"of",
"classes",
"As",
"there",
"may",
"be",
"more",
"than",
"one",
"object",
"of",
"the",
"same",
"class",
"in",
"the",
"chain"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/formatter/PropelFormatter.php#L171-L182 |
propelorm/Propel | runtime/lib/formatter/PropelFormatter.php | PropelFormatter.getSingleObjectFromRow | public function getSingleObjectFromRow($row, $class, &$col = 0)
{
$obj = $this->getWorkerObject($col, $class);
$col = $obj->hydrate($row, $col);
return $obj;
} | php | public function getSingleObjectFromRow($row, $class, &$col = 0)
{
$obj = $this->getWorkerObject($col, $class);
$col = $obj->hydrate($row, $col);
return $obj;
} | [
"public",
"function",
"getSingleObjectFromRow",
"(",
"$",
"row",
",",
"$",
"class",
",",
"&",
"$",
"col",
"=",
"0",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"getWorkerObject",
"(",
"$",
"col",
",",
"$",
"class",
")",
";",
"$",
"col",
"=",
"$",
"obj",
"->",
"hydrate",
"(",
"$",
"row",
",",
"$",
"col",
")",
";",
"return",
"$",
"obj",
";",
"}"
] | Gets a Propel object hydrated from a selection of columns in statement row
@param array $row associative array indexed by column number,
as returned by PDOStatement::fetch(PDO::FETCH_NUM)
@param string $class The classname of the object to create
@param int $col The start column for the hydration (modified)
@return BaseObject | [
"Gets",
"a",
"Propel",
"object",
"hydrated",
"from",
"a",
"selection",
"of",
"columns",
"in",
"statement",
"row"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/formatter/PropelFormatter.php#L194-L200 |
propelorm/Propel | generator/lib/platform/MysqlPlatform.php | MysqlPlatform.getIndexColumnListDDL | protected function getIndexColumnListDDL(Index $index)
{
$list = array();
foreach ($index->getColumns() as $col) {
$list[] = $this->quoteIdentifier($col) . ($index->hasColumnSize($col) ? '(' . $index->getColumnSize($col) . ')' : '');
}
return implode(', ', $list);
} | php | protected function getIndexColumnListDDL(Index $index)
{
$list = array();
foreach ($index->getColumns() as $col) {
$list[] = $this->quoteIdentifier($col) . ($index->hasColumnSize($col) ? '(' . $index->getColumnSize($col) . ')' : '');
}
return implode(', ', $list);
} | [
"protected",
"function",
"getIndexColumnListDDL",
"(",
"Index",
"$",
"index",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"index",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"col",
")",
".",
"(",
"$",
"index",
"->",
"hasColumnSize",
"(",
"$",
"col",
")",
"?",
"'('",
".",
"$",
"index",
"->",
"getColumnSize",
"(",
"$",
"col",
")",
".",
"')'",
":",
"''",
")",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"list",
")",
";",
"}"
] | Creates a comma-separated list of column names for the index.
For MySQL unique indexes there is the option of specifying size, so we cannot simply use
the getColumnsList() method.
@param Index $index
@return string | [
"Creates",
"a",
"comma",
"-",
"separated",
"list",
"of",
"column",
"names",
"for",
"the",
"index",
".",
"For",
"MySQL",
"unique",
"indexes",
"there",
"is",
"the",
"option",
"of",
"specifying",
"size",
"so",
"we",
"cannot",
"simply",
"use",
"the",
"getColumnsList",
"()",
"method",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/platform/MysqlPlatform.php#L388-L396 |
propelorm/Propel | generator/lib/platform/MysqlPlatform.php | MysqlPlatform.getAddIndexDDL | public function getAddIndexDDL(Index $index)
{
$pattern = "
CREATE %sINDEX %s ON %s (%s);
";
return sprintf($pattern,
$this->getIndexType($index),
$this->quoteIdentifier($index->getName()),
$this->quoteIdentifier($index->getTable()->getName()),
$this->getColumnListDDL($index->getColumns())
);
} | php | public function getAddIndexDDL(Index $index)
{
$pattern = "
CREATE %sINDEX %s ON %s (%s);
";
return sprintf($pattern,
$this->getIndexType($index),
$this->quoteIdentifier($index->getName()),
$this->quoteIdentifier($index->getTable()->getName()),
$this->getColumnListDDL($index->getColumns())
);
} | [
"public",
"function",
"getAddIndexDDL",
"(",
"Index",
"$",
"index",
")",
"{",
"$",
"pattern",
"=",
"\"\nCREATE %sINDEX %s ON %s (%s);\n\"",
";",
"return",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"getIndexType",
"(",
"$",
"index",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"getName",
"(",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"index",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
")",
",",
"$",
"this",
"->",
"getColumnListDDL",
"(",
"$",
"index",
"->",
"getColumns",
"(",
")",
")",
")",
";",
"}"
] | 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/MysqlPlatform.php#L423-L435 |
propelorm/Propel | generator/lib/platform/MysqlPlatform.php | MysqlPlatform.getChangeColumnDDL | public function getChangeColumnDDL($fromColumn, $toColumn)
{
$pattern = "
ALTER TABLE %s CHANGE %s %s;
";
return sprintf($pattern,
$this->quoteIdentifier($fromColumn->getTable()->getName()),
$this->quoteIdentifier($fromColumn->getName()),
$this->getColumnDDL($toColumn)
);
} | php | public function getChangeColumnDDL($fromColumn, $toColumn)
{
$pattern = "
ALTER TABLE %s CHANGE %s %s;
";
return sprintf($pattern,
$this->quoteIdentifier($fromColumn->getTable()->getName()),
$this->quoteIdentifier($fromColumn->getName()),
$this->getColumnDDL($toColumn)
);
} | [
"public",
"function",
"getChangeColumnDDL",
"(",
"$",
"fromColumn",
",",
"$",
"toColumn",
")",
"{",
"$",
"pattern",
"=",
"\"\nALTER TABLE %s CHANGE %s %s;\n\"",
";",
"return",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"fromColumn",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
")",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"fromColumn",
"->",
"getName",
"(",
")",
")",
",",
"$",
"this",
"->",
"getColumnDDL",
"(",
"$",
"toColumn",
")",
")",
";",
"}"
] | Builds the DDL SQL to change a column
@return string | [
"Builds",
"the",
"DDL",
"SQL",
"to",
"change",
"a",
"column"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/platform/MysqlPlatform.php#L630-L641 |
propelorm/Propel | generator/lib/model/diff/PropelColumnComparator.php | PropelColumnComparator.computeDiff | public static function computeDiff(Column $fromColumn, Column $toColumn)
{
if ($changedProperties = self::compareColumns($fromColumn, $toColumn)) {
if ($fromColumn->hasPlatform() || $toColumn->hasPlatform()) {
$platform = $fromColumn->hasPlatform() ? $fromColumn->getPlatform() : $toColumn->getPlatform();
if ($platform->getColumnDDL($fromColumn) == $platform->getColumnDDl($toColumn)) {
return false;
}
}
$columnDiff = new PropelColumnDiff();
$columnDiff->setFromColumn($fromColumn);
$columnDiff->setToColumn($toColumn);
$columnDiff->setChangedProperties($changedProperties);
return $columnDiff;
} else {
return false;
}
} | php | public static function computeDiff(Column $fromColumn, Column $toColumn)
{
if ($changedProperties = self::compareColumns($fromColumn, $toColumn)) {
if ($fromColumn->hasPlatform() || $toColumn->hasPlatform()) {
$platform = $fromColumn->hasPlatform() ? $fromColumn->getPlatform() : $toColumn->getPlatform();
if ($platform->getColumnDDL($fromColumn) == $platform->getColumnDDl($toColumn)) {
return false;
}
}
$columnDiff = new PropelColumnDiff();
$columnDiff->setFromColumn($fromColumn);
$columnDiff->setToColumn($toColumn);
$columnDiff->setChangedProperties($changedProperties);
return $columnDiff;
} else {
return false;
}
} | [
"public",
"static",
"function",
"computeDiff",
"(",
"Column",
"$",
"fromColumn",
",",
"Column",
"$",
"toColumn",
")",
"{",
"if",
"(",
"$",
"changedProperties",
"=",
"self",
"::",
"compareColumns",
"(",
"$",
"fromColumn",
",",
"$",
"toColumn",
")",
")",
"{",
"if",
"(",
"$",
"fromColumn",
"->",
"hasPlatform",
"(",
")",
"||",
"$",
"toColumn",
"->",
"hasPlatform",
"(",
")",
")",
"{",
"$",
"platform",
"=",
"$",
"fromColumn",
"->",
"hasPlatform",
"(",
")",
"?",
"$",
"fromColumn",
"->",
"getPlatform",
"(",
")",
":",
"$",
"toColumn",
"->",
"getPlatform",
"(",
")",
";",
"if",
"(",
"$",
"platform",
"->",
"getColumnDDL",
"(",
"$",
"fromColumn",
")",
"==",
"$",
"platform",
"->",
"getColumnDDl",
"(",
"$",
"toColumn",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"$",
"columnDiff",
"=",
"new",
"PropelColumnDiff",
"(",
")",
";",
"$",
"columnDiff",
"->",
"setFromColumn",
"(",
"$",
"fromColumn",
")",
";",
"$",
"columnDiff",
"->",
"setToColumn",
"(",
"$",
"toColumn",
")",
";",
"$",
"columnDiff",
"->",
"setChangedProperties",
"(",
"$",
"changedProperties",
")",
";",
"return",
"$",
"columnDiff",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Compute and return the difference between two column objects
@param Column $fromColumn
@param Column $toColumn
@return PropelColumnDiff|boolean return false if the two columns are similar | [
"Compute",
"and",
"return",
"the",
"difference",
"between",
"two",
"column",
"objects"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelColumnComparator.php#L31-L49 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.setFormatter | public function setFormatter($formatter)
{
if (is_string($formatter)) {
$formatter = new $formatter();
}
if (!$formatter instanceof PropelFormatter) {
throw new PropelException('setFormatter() only accepts classes extending PropelFormatter');
}
$this->formatter = $formatter;
return $this;
} | php | public function setFormatter($formatter)
{
if (is_string($formatter)) {
$formatter = new $formatter();
}
if (!$formatter instanceof PropelFormatter) {
throw new PropelException('setFormatter() only accepts classes extending PropelFormatter');
}
$this->formatter = $formatter;
return $this;
} | [
"public",
"function",
"setFormatter",
"(",
"$",
"formatter",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"formatter",
")",
")",
"{",
"$",
"formatter",
"=",
"new",
"$",
"formatter",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"formatter",
"instanceof",
"PropelFormatter",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'setFormatter() only accepts classes extending PropelFormatter'",
")",
";",
"}",
"$",
"this",
"->",
"formatter",
"=",
"$",
"formatter",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the formatter to use for the find() output
Formatters must extend PropelFormatter
Use the ModelCriteria constants for class names:
<code>
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
</code>
@param string|PropelFormatter $formatter a formatter class name, or a formatter instance
@return ModelCriteria The current object, for fluid interface
@throws PropelException | [
"Sets",
"the",
"formatter",
"to",
"use",
"for",
"the",
"find",
"()",
"output",
"Formatters",
"must",
"extend",
"PropelFormatter",
"Use",
"the",
"ModelCriteria",
"constants",
"for",
"class",
"names",
":",
"<code",
">",
"$c",
"-",
">",
"setFormatter",
"(",
"ModelCriteria",
"::",
"FORMAT_ARRAY",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L168-L179 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.orWhere | public function orWhere($clause, $value = null, $bindingType = null)
{
return $this
->_or()
->where($clause, $value, $bindingType);
} | php | public function orWhere($clause, $value = null, $bindingType = null)
{
return $this
->_or()
->where($clause, $value, $bindingType);
} | [
"public",
"function",
"orWhere",
"(",
"$",
"clause",
",",
"$",
"value",
"=",
"null",
",",
"$",
"bindingType",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_or",
"(",
")",
"->",
"where",
"(",
"$",
"clause",
",",
"$",
"value",
",",
"$",
"bindingType",
")",
";",
"}"
] | Adds a condition on a column based on a pseudo SQL clause
Uses introspection to translate the column phpName into a fully qualified name
<code>
// simple clause
$c->orWhere('b.Title = ?', 'foo');
// named conditions
$c->condition('cond1', 'b.Title = ?', 'foo');
$c->condition('cond2', 'b.ISBN = ?', 12345);
$c->orWhere(array('cond1', 'cond2'), Criteria::LOGICAL_OR);
</code>
@see Criteria::addOr()
@deprecated Use _or()->where() instead
@param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
@param mixed $value A value for the condition
@param string $bindingType
@return ModelCriteria The current object, for fluid interface | [
"Adds",
"a",
"condition",
"on",
"a",
"column",
"based",
"on",
"a",
"pseudo",
"SQL",
"clause",
"Uses",
"introspection",
"to",
"translate",
"the",
"column",
"phpName",
"into",
"a",
"fully",
"qualified",
"name",
"<code",
">",
"//",
"simple",
"clause",
"$c",
"-",
">",
"orWhere",
"(",
"b",
".",
"Title",
"=",
"?",
"foo",
")",
";",
"//",
"named",
"conditions",
"$c",
"-",
">",
"condition",
"(",
"cond1",
"b",
".",
"Title",
"=",
"?",
"foo",
")",
";",
"$c",
"-",
">",
"condition",
"(",
"cond2",
"b",
".",
"ISBN",
"=",
"?",
"12345",
")",
";",
"$c",
"-",
">",
"orWhere",
"(",
"array",
"(",
"cond1",
"cond2",
")",
"Criteria",
"::",
"LOGICAL_OR",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L325-L330 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.groupBy | public function groupBy($columnName)
{
list(, $realColumnName) = $this->getColumnFromName($columnName, false);
$this->addGroupByColumn($realColumnName);
return $this;
} | php | public function groupBy($columnName)
{
list(, $realColumnName) = $this->getColumnFromName($columnName, false);
$this->addGroupByColumn($realColumnName);
return $this;
} | [
"public",
"function",
"groupBy",
"(",
"$",
"columnName",
")",
"{",
"list",
"(",
",",
"$",
"realColumnName",
")",
"=",
"$",
"this",
"->",
"getColumnFromName",
"(",
"$",
"columnName",
",",
"false",
")",
";",
"$",
"this",
"->",
"addGroupByColumn",
"(",
"$",
"realColumnName",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a GROUB BY clause to the query
Usability layer on top of Criteria::addGroupByColumn()
Infers $column $columnName
Examples:
$c->groupBy('Book.AuthorId')
=> $c->addGroupByColumn(BookPeer::AUTHOR_ID)
@param string $columnName The column to group by
@return ModelCriteria The current object, for fluid interface | [
"Adds",
"a",
"GROUB",
"BY",
"clause",
"to",
"the",
"query",
"Usability",
"layer",
"on",
"top",
"of",
"Criteria",
"::",
"addGroupByColumn",
"()",
"Infers",
"$column",
"$columnName",
"Examples",
":",
"$c",
"-",
">",
"groupBy",
"(",
"Book",
".",
"AuthorId",
")",
"=",
">",
"$c",
"-",
">",
"addGroupByColumn",
"(",
"BookPeer",
"::",
"AUTHOR_ID",
")"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L414-L420 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.groupByClass | public function groupByClass($class)
{
if ($class == $this->getModelAliasOrName()) {
// column of the Criteria's model
$tableMap = $this->getTableMap();
} elseif (isset($this->joins[$class])) {
// column of a relations's model
$tableMap = $this->joins[$class]->getTableMap();
} else {
throw new PropelException('Unknown model or alias ' . $class);
}
foreach ($tableMap->getColumns() as $column) {
if (isset($this->aliases[$class])) {
$this->addGroupByColumn($class . '.' . $column->getName());
} else {
$this->addGroupByColumn($column->getFullyQualifiedName());
}
}
return $this;
} | php | public function groupByClass($class)
{
if ($class == $this->getModelAliasOrName()) {
// column of the Criteria's model
$tableMap = $this->getTableMap();
} elseif (isset($this->joins[$class])) {
// column of a relations's model
$tableMap = $this->joins[$class]->getTableMap();
} else {
throw new PropelException('Unknown model or alias ' . $class);
}
foreach ($tableMap->getColumns() as $column) {
if (isset($this->aliases[$class])) {
$this->addGroupByColumn($class . '.' . $column->getName());
} else {
$this->addGroupByColumn($column->getFullyQualifiedName());
}
}
return $this;
} | [
"public",
"function",
"groupByClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"==",
"$",
"this",
"->",
"getModelAliasOrName",
"(",
")",
")",
"{",
"// column of the Criteria's model",
"$",
"tableMap",
"=",
"$",
"this",
"->",
"getTableMap",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"joins",
"[",
"$",
"class",
"]",
")",
")",
"{",
"// column of a relations's model",
"$",
"tableMap",
"=",
"$",
"this",
"->",
"joins",
"[",
"$",
"class",
"]",
"->",
"getTableMap",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unknown model or alias '",
".",
"$",
"class",
")",
";",
"}",
"foreach",
"(",
"$",
"tableMap",
"->",
"getColumns",
"(",
")",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addGroupByColumn",
"(",
"$",
"class",
".",
"'.'",
".",
"$",
"column",
"->",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addGroupByColumn",
"(",
"$",
"column",
"->",
"getFullyQualifiedName",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a GROUB BY clause for all columns of a model to the query
Examples:
$c->groupBy('Book');
=> $c->addGroupByColumn(BookPeer::ID);
=> $c->addGroupByColumn(BookPeer::TITLE);
=> $c->addGroupByColumn(BookPeer::AUTHOR_ID);
=> $c->addGroupByColumn(BookPeer::PUBLISHER_ID);
@param string $class The class name or alias
@return ModelCriteria The current object, for fluid interface
@throws PropelException | [
"Adds",
"a",
"GROUB",
"BY",
"clause",
"for",
"all",
"columns",
"of",
"a",
"model",
"to",
"the",
"query",
"Examples",
":",
"$c",
"-",
">",
"groupBy",
"(",
"Book",
")",
";",
"=",
">",
"$c",
"-",
">",
"addGroupByColumn",
"(",
"BookPeer",
"::",
"ID",
")",
";",
"=",
">",
"$c",
"-",
">",
"addGroupByColumn",
"(",
"BookPeer",
"::",
"TITLE",
")",
";",
"=",
">",
"$c",
"-",
">",
"addGroupByColumn",
"(",
"BookPeer",
"::",
"AUTHOR_ID",
")",
";",
"=",
">",
"$c",
"-",
">",
"addGroupByColumn",
"(",
"BookPeer",
"::",
"PUBLISHER_ID",
")",
";"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L437-L457 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.select | public function select($columnArray)
{
if (!count($columnArray) || $columnArray == '') {
throw new PropelException('You must ask for at least one column');
}
if ($columnArray == '*') {
$columnArray = array();
foreach (call_user_func(array($this->modelPeerName, 'getFieldNames'), BasePeer::TYPE_PHPNAME) as $column) {
$columnArray[] = $this->modelName . '.' . $column;
}
}
$this->select = $columnArray;
return $this;
} | php | public function select($columnArray)
{
if (!count($columnArray) || $columnArray == '') {
throw new PropelException('You must ask for at least one column');
}
if ($columnArray == '*') {
$columnArray = array();
foreach (call_user_func(array($this->modelPeerName, 'getFieldNames'), BasePeer::TYPE_PHPNAME) as $column) {
$columnArray[] = $this->modelName . '.' . $column;
}
}
$this->select = $columnArray;
return $this;
} | [
"public",
"function",
"select",
"(",
"$",
"columnArray",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"columnArray",
")",
"||",
"$",
"columnArray",
"==",
"''",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'You must ask for at least one column'",
")",
";",
"}",
"if",
"(",
"$",
"columnArray",
"==",
"'*'",
")",
"{",
"$",
"columnArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"modelPeerName",
",",
"'getFieldNames'",
")",
",",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"as",
"$",
"column",
")",
"{",
"$",
"columnArray",
"[",
"]",
"=",
"$",
"this",
"->",
"modelName",
".",
"'.'",
".",
"$",
"column",
";",
"}",
"}",
"$",
"this",
"->",
"select",
"=",
"$",
"columnArray",
";",
"return",
"$",
"this",
";",
"}"
] | Makes the ModelCriteria return a string, array, or PropelArrayCollection
Examples:
ArticleQuery::create()->select('Name')->find();
=> PropelArrayCollection Object ('Foo', 'Bar')
ArticleQuery::create()->select('Name')->findOne();
=> string 'Foo'
ArticleQuery::create()->select(array('Id', 'Name'))->find();
=> PropelArrayCollection Object (
array('Id' => 1, 'Name' => 'Foo'),
array('Id' => 2, 'Name' => 'Bar')
)
ArticleQuery::create()->select(array('Id', 'Name'))->findOne();
=> array('Id' => 1, 'Name' => 'Foo')
@param mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name')
@return ModelCriteria The current object, for fluid interface
@throws PropelException | [
"Makes",
"the",
"ModelCriteria",
"return",
"a",
"string",
"array",
"or",
"PropelArrayCollection",
"Examples",
":",
"ArticleQuery",
"::",
"create",
"()",
"-",
">",
"select",
"(",
"Name",
")",
"-",
">",
"find",
"()",
";",
"=",
">",
"PropelArrayCollection",
"Object",
"(",
"Foo",
"Bar",
")"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L526-L542 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.with | public function with($relation)
{
if (!isset($this->joins[$relation])) {
throw new PropelException('Unknown relation name or alias ' . $relation);
}
$join = $this->joins[$relation];
if ($join->getRelationMap()->getType() == RelationMap::MANY_TO_MANY) {
throw new PropelException('with() does not allow hydration for many-to-many relationships');
} elseif ($join->getRelationMap()->getType() == RelationMap::ONE_TO_MANY) {
// For performance reasons, the formatters will use a special routine in this case
$this->isWithOneToMany = true;
}
// check that the columns of the main class are already added (but only if this isn't a useQuery)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
// add the columns of the related class
$this->addRelationSelectColumns($relation);
// list the join for later hydration in the formatter
$this->with[$relation] = new ModelWith($join);
return $this;
} | php | public function with($relation)
{
if (!isset($this->joins[$relation])) {
throw new PropelException('Unknown relation name or alias ' . $relation);
}
$join = $this->joins[$relation];
if ($join->getRelationMap()->getType() == RelationMap::MANY_TO_MANY) {
throw new PropelException('with() does not allow hydration for many-to-many relationships');
} elseif ($join->getRelationMap()->getType() == RelationMap::ONE_TO_MANY) {
// For performance reasons, the formatters will use a special routine in this case
$this->isWithOneToMany = true;
}
// check that the columns of the main class are already added (but only if this isn't a useQuery)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
// add the columns of the related class
$this->addRelationSelectColumns($relation);
// list the join for later hydration in the formatter
$this->with[$relation] = new ModelWith($join);
return $this;
} | [
"public",
"function",
"with",
"(",
"$",
"relation",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"joins",
"[",
"$",
"relation",
"]",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unknown relation name or alias '",
".",
"$",
"relation",
")",
";",
"}",
"$",
"join",
"=",
"$",
"this",
"->",
"joins",
"[",
"$",
"relation",
"]",
";",
"if",
"(",
"$",
"join",
"->",
"getRelationMap",
"(",
")",
"->",
"getType",
"(",
")",
"==",
"RelationMap",
"::",
"MANY_TO_MANY",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'with() does not allow hydration for many-to-many relationships'",
")",
";",
"}",
"elseif",
"(",
"$",
"join",
"->",
"getRelationMap",
"(",
")",
"->",
"getType",
"(",
")",
"==",
"RelationMap",
"::",
"ONE_TO_MANY",
")",
"{",
"// For performance reasons, the formatters will use a special routine in this case",
"$",
"this",
"->",
"isWithOneToMany",
"=",
"true",
";",
"}",
"// check that the columns of the main class are already added (but only if this isn't a useQuery)",
"if",
"(",
"!",
"$",
"this",
"->",
"hasSelectClause",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getPrimaryCriteria",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addSelfSelectColumns",
"(",
")",
";",
"}",
"// add the columns of the related class",
"$",
"this",
"->",
"addRelationSelectColumns",
"(",
"$",
"relation",
")",
";",
"// list the join for later hydration in the formatter",
"$",
"this",
"->",
"with",
"[",
"$",
"relation",
"]",
"=",
"new",
"ModelWith",
"(",
"$",
"join",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a relation to hydrate together with the main object
The relation must be initialized via a join() prior to calling with()
Examples:
<code>
$c->join('Book.Author');
$c->with('Author');
$c->join('Book.Author a', Criteria::RIGHT_JOIN);
$c->with('a');
</code>
WARNING: on a one-to-many relationship, the use of with() combined with limit()
will return a wrong number of results for the related objects
@param string $relation Relation to use for the join
@return ModelCriteria The current object, for fluid interface
@throws PropelException | [
"Adds",
"a",
"relation",
"to",
"hydrate",
"together",
"with",
"the",
"main",
"object",
"The",
"relation",
"must",
"be",
"initialized",
"via",
"a",
"join",
"()",
"prior",
"to",
"calling",
"with",
"()",
"Examples",
":",
"<code",
">",
"$c",
"-",
">",
"join",
"(",
"Book",
".",
"Author",
")",
";",
"$c",
"-",
">",
"with",
"(",
"Author",
")",
";"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L855-L879 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.withColumn | public function withColumn($clause, $name = null)
{
if (null === $name) {
$name = str_replace(array('.', '(', ')'), '', $clause);
}
$clause = trim($clause);
$this->replaceNames($clause);
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$this->addAsColumn($name, $clause);
return $this;
} | php | public function withColumn($clause, $name = null)
{
if (null === $name) {
$name = str_replace(array('.', '(', ')'), '', $clause);
}
$clause = trim($clause);
$this->replaceNames($clause);
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$this->addAsColumn($name, $clause);
return $this;
} | [
"public",
"function",
"withColumn",
"(",
"$",
"clause",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"array",
"(",
"'.'",
",",
"'('",
",",
"')'",
")",
",",
"''",
",",
"$",
"clause",
")",
";",
"}",
"$",
"clause",
"=",
"trim",
"(",
"$",
"clause",
")",
";",
"$",
"this",
"->",
"replaceNames",
"(",
"$",
"clause",
")",
";",
"// check that the columns of the main class are already added (if this is the primary ModelCriteria)",
"if",
"(",
"!",
"$",
"this",
"->",
"hasSelectClause",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getPrimaryCriteria",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addSelfSelectColumns",
"(",
")",
";",
"}",
"$",
"this",
"->",
"addAsColumn",
"(",
"$",
"name",
",",
"$",
"clause",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a supplementary column to the select clause
These columns can later be retrieved from the hydrated objects using getVirtualColumn()
@param string $clause The SQL clause with object model column names
e.g. 'UPPER(Author.FirstName)'
@param string $name Optional alias for the added column
If no alias is provided, the clause is used as a column alias
This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias)
@return ModelCriteria The current object, for fluid interface | [
"Adds",
"a",
"supplementary",
"column",
"to",
"the",
"select",
"clause",
"These",
"columns",
"can",
"later",
"be",
"retrieved",
"from",
"the",
"hydrated",
"objects",
"using",
"getVirtualColumn",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L925-L939 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.useQuery | public function useQuery($relationName, $secondaryCriteriaClass = null)
{
if (!isset($this->joins[$relationName])) {
throw new PropelException('Unknown class or alias ' . $relationName);
}
$className = $this->joins[$relationName]->getTableMap()->getPhpName();
if (null === $secondaryCriteriaClass) {
$secondaryCriteria = PropelQuery::from($className);
} else {
$secondaryCriteria = new $secondaryCriteriaClass();
}
if ($className != $relationName) {
$secondaryCriteria->setModelAlias($relationName, $relationName == $this->joins[$relationName]->getRelationMap()->getName() ? false : true);
}
$secondaryCriteria->setPrimaryCriteria($this, $this->joins[$relationName]);
return $secondaryCriteria;
} | php | public function useQuery($relationName, $secondaryCriteriaClass = null)
{
if (!isset($this->joins[$relationName])) {
throw new PropelException('Unknown class or alias ' . $relationName);
}
$className = $this->joins[$relationName]->getTableMap()->getPhpName();
if (null === $secondaryCriteriaClass) {
$secondaryCriteria = PropelQuery::from($className);
} else {
$secondaryCriteria = new $secondaryCriteriaClass();
}
if ($className != $relationName) {
$secondaryCriteria->setModelAlias($relationName, $relationName == $this->joins[$relationName]->getRelationMap()->getName() ? false : true);
}
$secondaryCriteria->setPrimaryCriteria($this, $this->joins[$relationName]);
return $secondaryCriteria;
} | [
"public",
"function",
"useQuery",
"(",
"$",
"relationName",
",",
"$",
"secondaryCriteriaClass",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"joins",
"[",
"$",
"relationName",
"]",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unknown class or alias '",
".",
"$",
"relationName",
")",
";",
"}",
"$",
"className",
"=",
"$",
"this",
"->",
"joins",
"[",
"$",
"relationName",
"]",
"->",
"getTableMap",
"(",
")",
"->",
"getPhpName",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"secondaryCriteriaClass",
")",
"{",
"$",
"secondaryCriteria",
"=",
"PropelQuery",
"::",
"from",
"(",
"$",
"className",
")",
";",
"}",
"else",
"{",
"$",
"secondaryCriteria",
"=",
"new",
"$",
"secondaryCriteriaClass",
"(",
")",
";",
"}",
"if",
"(",
"$",
"className",
"!=",
"$",
"relationName",
")",
"{",
"$",
"secondaryCriteria",
"->",
"setModelAlias",
"(",
"$",
"relationName",
",",
"$",
"relationName",
"==",
"$",
"this",
"->",
"joins",
"[",
"$",
"relationName",
"]",
"->",
"getRelationMap",
"(",
")",
"->",
"getName",
"(",
")",
"?",
"false",
":",
"true",
")",
";",
"}",
"$",
"secondaryCriteria",
"->",
"setPrimaryCriteria",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"joins",
"[",
"$",
"relationName",
"]",
")",
";",
"return",
"$",
"secondaryCriteria",
";",
"}"
] | Initializes a secondary ModelCriteria object, to be later merged with the current object
@see ModelCriteria::endUse()
@param string $relationName Relation name or alias
@param string $secondaryCriteriaClass Classname for the ModelCriteria to be used
@return ModelCriteria The secondary criteria object
@throws PropelException | [
"Initializes",
"a",
"secondary",
"ModelCriteria",
"object",
"to",
"be",
"later",
"merged",
"with",
"the",
"current",
"object"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L953-L970 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.clear | public function clear()
{
parent::clear();
$this->with = array();
$this->primaryCriteria = null;
$this->formatter = null;
$this->select = null;
$this->modelAlias = $this->originalModelAlias;
$this->currentAlias = null;
$this->setDbName($this->originalDbName);
$this->useAliasInSQL = false;
$this->isKeepQuery = true;
$this->previousJoin = null;
$this->isWithOneToMany = false;
$this->replacedColumns = array();
$this->foundMatch = false;
return $this;
} | php | public function clear()
{
parent::clear();
$this->with = array();
$this->primaryCriteria = null;
$this->formatter = null;
$this->select = null;
$this->modelAlias = $this->originalModelAlias;
$this->currentAlias = null;
$this->setDbName($this->originalDbName);
$this->useAliasInSQL = false;
$this->isKeepQuery = true;
$this->previousJoin = null;
$this->isWithOneToMany = false;
$this->replacedColumns = array();
$this->foundMatch = false;
return $this;
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"parent",
"::",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"with",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"primaryCriteria",
"=",
"null",
";",
"$",
"this",
"->",
"formatter",
"=",
"null",
";",
"$",
"this",
"->",
"select",
"=",
"null",
";",
"$",
"this",
"->",
"modelAlias",
"=",
"$",
"this",
"->",
"originalModelAlias",
";",
"$",
"this",
"->",
"currentAlias",
"=",
"null",
";",
"$",
"this",
"->",
"setDbName",
"(",
"$",
"this",
"->",
"originalDbName",
")",
";",
"$",
"this",
"->",
"useAliasInSQL",
"=",
"false",
";",
"$",
"this",
"->",
"isKeepQuery",
"=",
"true",
";",
"$",
"this",
"->",
"previousJoin",
"=",
"null",
";",
"$",
"this",
"->",
"isWithOneToMany",
"=",
"false",
";",
"$",
"this",
"->",
"replacedColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"foundMatch",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Clear the conditions to allow the reuse of the query object.
The ModelCriteria's Model and alias 'all the properties set by construct) will remain.
@return ModelCriteria The primary criteria object | [
"Clear",
"the",
"conditions",
"to",
"allow",
"the",
"reuse",
"of",
"the",
"query",
"object",
".",
"The",
"ModelCriteria",
"s",
"Model",
"and",
"alias",
"all",
"the",
"properties",
"set",
"by",
"construct",
")",
"will",
"remain",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1020-L1039 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.addSelfSelectColumns | public function addSelfSelectColumns()
{
call_user_func(array($this->modelPeerName, 'addSelectColumns'), $this, $this->useAliasInSQL ? $this->modelAlias : null);
return $this;
} | php | public function addSelfSelectColumns()
{
call_user_func(array($this->modelPeerName, 'addSelectColumns'), $this, $this->useAliasInSQL ? $this->modelAlias : null);
return $this;
} | [
"public",
"function",
"addSelfSelectColumns",
"(",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"modelPeerName",
",",
"'addSelectColumns'",
")",
",",
"$",
"this",
",",
"$",
"this",
"->",
"useAliasInSQL",
"?",
"$",
"this",
"->",
"modelAlias",
":",
"null",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the select columns for a the current table
@return ModelCriteria The current object, for fluid interface | [
"Adds",
"the",
"select",
"columns",
"for",
"a",
"the",
"current",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1100-L1105 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.addRelationSelectColumns | public function addRelationSelectColumns($relation)
{
$join = $this->joins[$relation];
call_user_func(array($join->getTableMap()->getPeerClassname(), 'addSelectColumns'), $this, $join->getRelationAlias());
return $this;
} | php | public function addRelationSelectColumns($relation)
{
$join = $this->joins[$relation];
call_user_func(array($join->getTableMap()->getPeerClassname(), 'addSelectColumns'), $this, $join->getRelationAlias());
return $this;
} | [
"public",
"function",
"addRelationSelectColumns",
"(",
"$",
"relation",
")",
"{",
"$",
"join",
"=",
"$",
"this",
"->",
"joins",
"[",
"$",
"relation",
"]",
";",
"call_user_func",
"(",
"array",
"(",
"$",
"join",
"->",
"getTableMap",
"(",
")",
"->",
"getPeerClassname",
"(",
")",
",",
"'addSelectColumns'",
")",
",",
"$",
"this",
",",
"$",
"join",
"->",
"getRelationAlias",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the select columns for a relation
@param string $relation The relation name or alias, as defined in join()
@return ModelCriteria The current object, for fluid interface | [
"Adds",
"the",
"select",
"columns",
"for",
"a",
"relation"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1114-L1120 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.find | public function find($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
} | php | public function find($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
} | [
"public",
"function",
"find",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"doSelect",
"(",
"$",
"con",
")",
";",
"return",
"$",
"criteria",
"->",
"getFormatter",
"(",
")",
"->",
"init",
"(",
"$",
"criteria",
")",
"->",
"format",
"(",
"$",
"stmt",
")",
";",
"}"
] | Issue a SELECT query based on the current ModelCriteria
and format the list of results with the current formatter
By default, returns an array of model objects
@param PropelPDO $con an optional connection object
@return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter | [
"Issue",
"a",
"SELECT",
"query",
"based",
"on",
"the",
"current",
"ModelCriteria",
"and",
"format",
"the",
"list",
"of",
"results",
"with",
"the",
"current",
"formatter",
"By",
"default",
"returns",
"an",
"array",
"of",
"model",
"objects"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1220-L1230 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findOne | public function findOne($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->limit(1);
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
} | php | public function findOne($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->limit(1);
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
} | [
"public",
"function",
"findOne",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"criteria",
"->",
"limit",
"(",
"1",
")",
";",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"doSelect",
"(",
"$",
"con",
")",
";",
"return",
"$",
"criteria",
"->",
"getFormatter",
"(",
")",
"->",
"init",
"(",
"$",
"criteria",
")",
"->",
"formatOne",
"(",
"$",
"stmt",
")",
";",
"}"
] | 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 | [
"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"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1241-L1252 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findPk | public function findPk($key, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
// As the query uses a PK condition, no limit(1) is necessary.
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$pkCols = $this->getTableMap()->getPrimaryKeyColumns();
if (count($pkCols) == 1) {
// simple primary key
$pkCol = $pkCols[0];
$criteria->add($pkCol->getFullyQualifiedName(), $key);
} else {
// composite primary key
foreach ($pkCols as $pkCol) {
$keyPart = array_shift($key);
$criteria->add($pkCol->getFullyQualifiedName(), $keyPart);
}
}
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
} | php | public function findPk($key, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
// As the query uses a PK condition, no limit(1) is necessary.
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$pkCols = $this->getTableMap()->getPrimaryKeyColumns();
if (count($pkCols) == 1) {
// simple primary key
$pkCol = $pkCols[0];
$criteria->add($pkCol->getFullyQualifiedName(), $key);
} else {
// composite primary key
foreach ($pkCols as $pkCol) {
$keyPart = array_shift($key);
$criteria->add($pkCol->getFullyQualifiedName(), $keyPart);
}
}
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
} | [
"public",
"function",
"findPk",
"(",
"$",
"key",
",",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"// As the query uses a PK condition, no limit(1) is necessary.",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"pkCols",
"=",
"$",
"this",
"->",
"getTableMap",
"(",
")",
"->",
"getPrimaryKeyColumns",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"pkCols",
")",
"==",
"1",
")",
"{",
"// simple primary key",
"$",
"pkCol",
"=",
"$",
"pkCols",
"[",
"0",
"]",
";",
"$",
"criteria",
"->",
"add",
"(",
"$",
"pkCol",
"->",
"getFullyQualifiedName",
"(",
")",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"// composite primary key",
"foreach",
"(",
"$",
"pkCols",
"as",
"$",
"pkCol",
")",
"{",
"$",
"keyPart",
"=",
"array_shift",
"(",
"$",
"key",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"$",
"pkCol",
"->",
"getFullyQualifiedName",
"(",
")",
",",
"$",
"keyPart",
")",
";",
"}",
"}",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"doSelect",
"(",
"$",
"con",
")",
";",
"return",
"$",
"criteria",
"->",
"getFormatter",
"(",
")",
"->",
"init",
"(",
"$",
"criteria",
")",
"->",
"formatOne",
"(",
"$",
"stmt",
")",
";",
"}"
] | Find object by primary key
Behaves differently if the model has simple or composite primary key
<code>
// simple primary key
$book = $c->findPk(12, $con);
// composite primary key
$bookOpinion = $c->findPk(array(34, 634), $con);
</code>
@param mixed $key Primary key to use for the query
@param PropelPDO $con an optional connection object
@return mixed the result, formatted by the current formatter | [
"Find",
"object",
"by",
"primary",
"key",
"Behaves",
"differently",
"if",
"the",
"model",
"has",
"simple",
"or",
"composite",
"primary",
"key",
"<code",
">",
"//",
"simple",
"primary",
"key",
"$book",
"=",
"$c",
"-",
">",
"findPk",
"(",
"12",
"$con",
")",
";",
"//",
"composite",
"primary",
"key",
"$bookOpinion",
"=",
"$c",
"-",
">",
"findPk",
"(",
"array",
"(",
"34",
"634",
")",
"$con",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1297-L1320 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findPks | public function findPks($keys, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
// As the query uses a PK condition, no limit(1) is necessary.
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$pkCols = $this->getTableMap()->getPrimaryKeyColumns();
if (count($pkCols) == 1) {
// simple primary key
$pkCol = array_shift($pkCols);
$criteria->add($pkCol->getFullyQualifiedName(), $keys, Criteria::IN);
} else {
// composite primary key
throw new PropelException('Multiple object retrieval is not implemented for composite primary keys');
}
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
} | php | public function findPks($keys, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
// As the query uses a PK condition, no limit(1) is necessary.
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$pkCols = $this->getTableMap()->getPrimaryKeyColumns();
if (count($pkCols) == 1) {
// simple primary key
$pkCol = array_shift($pkCols);
$criteria->add($pkCol->getFullyQualifiedName(), $keys, Criteria::IN);
} else {
// composite primary key
throw new PropelException('Multiple object retrieval is not implemented for composite primary keys');
}
$stmt = $criteria->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
} | [
"public",
"function",
"findPks",
"(",
"$",
"keys",
",",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"// As the query uses a PK condition, no limit(1) is necessary.",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"pkCols",
"=",
"$",
"this",
"->",
"getTableMap",
"(",
")",
"->",
"getPrimaryKeyColumns",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"pkCols",
")",
"==",
"1",
")",
"{",
"// simple primary key",
"$",
"pkCol",
"=",
"array_shift",
"(",
"$",
"pkCols",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"$",
"pkCol",
"->",
"getFullyQualifiedName",
"(",
")",
",",
"$",
"keys",
",",
"Criteria",
"::",
"IN",
")",
";",
"}",
"else",
"{",
"// composite primary key",
"throw",
"new",
"PropelException",
"(",
"'Multiple object retrieval is not implemented for composite primary keys'",
")",
";",
"}",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"doSelect",
"(",
"$",
"con",
")",
";",
"return",
"$",
"criteria",
"->",
"getFormatter",
"(",
")",
"->",
"init",
"(",
"$",
"criteria",
")",
"->",
"format",
"(",
"$",
"stmt",
")",
";",
"}"
] | Find objects by primary key
Behaves differently if the model has simple or composite primary key
<code>
// simple primary key
$books = $c->findPks(array(12, 56, 832), $con);
// composite primary key
$bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con);
</code>
@param array $keys Primary keys to use for the query
@param PropelPDO $con an optional connection object
@return mixed the list of results, formatted by the current formatter
@throws PropelException | [
"Find",
"objects",
"by",
"primary",
"key",
"Behaves",
"differently",
"if",
"the",
"model",
"has",
"simple",
"or",
"composite",
"primary",
"key",
"<code",
">",
"//",
"simple",
"primary",
"key",
"$books",
"=",
"$c",
"-",
">",
"findPks",
"(",
"array",
"(",
"12",
"56",
"832",
")",
"$con",
")",
";",
"//",
"composite",
"primary",
"key",
"$bookOpinion",
"=",
"$c",
"-",
">",
"findPks",
"(",
"array",
"(",
"array",
"(",
"34",
"634",
")",
"array",
"(",
"45",
"518",
")",
"array",
"(",
"34",
"765",
"))",
"$con",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1339-L1359 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.doSelect | protected function doSelect($con)
{
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$this->configureSelectColumns();
$dbMap = Propel::getDatabaseMap($this->getDbName());
$db = Propel::getDB($this->getDbName());
$params = array();
$sql = BasePeer::createSelectSql($this, $params);
try {
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
}
return $stmt;
} | php | protected function doSelect($con)
{
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$this->configureSelectColumns();
$dbMap = Propel::getDatabaseMap($this->getDbName());
$db = Propel::getDB($this->getDbName());
$params = array();
$sql = BasePeer::createSelectSql($this, $params);
try {
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
}
return $stmt;
} | [
"protected",
"function",
"doSelect",
"(",
"$",
"con",
")",
"{",
"// check that the columns of the main class are already added (if this is the primary ModelCriteria)",
"if",
"(",
"!",
"$",
"this",
"->",
"hasSelectClause",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getPrimaryCriteria",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addSelfSelectColumns",
"(",
")",
";",
"}",
"$",
"this",
"->",
"configureSelectColumns",
"(",
")",
";",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"sql",
"=",
"BasePeer",
"::",
"createSelectSql",
"(",
"$",
"this",
",",
"$",
"params",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"db",
"->",
"bindValues",
"(",
"$",
"stmt",
",",
"$",
"params",
",",
"$",
"dbMap",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute SELECT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"stmt",
";",
"}"
] | Builds, binds and executes a SELECT query based on the current object.
@param PropelPDO $con A connection object
@return PDOStatement A PDO statement executed using the connection, ready to be fetched
@throws PropelException | [
"Builds",
"binds",
"and",
"executes",
"a",
"SELECT",
"query",
"based",
"on",
"the",
"current",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1370-L1393 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findBy | public function findBy($column, $value, $con = null)
{
$method = 'filterBy' . $column;
$this->$method($value);
return $this->find($con);
} | php | public function findBy($column, $value, $con = null)
{
$method = 'filterBy' . $column;
$this->$method($value);
return $this->find($con);
} | [
"public",
"function",
"findBy",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"'filterBy'",
".",
"$",
"column",
";",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}"
] | Apply a condition on a column and issues the SELECT query
@see filterBy()
@see find()
@param string $column A string representing the column phpName, e.g. 'AuthorId'
@param mixed $value A value for the condition
@param PropelPDO $con An optional connection object
@return mixed the list of results, formatted by the current formatter | [
"Apply",
"a",
"condition",
"on",
"a",
"column",
"and",
"issues",
"the",
"SELECT",
"query"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1407-L1413 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findByArray | public function findByArray($conditions, $con = null)
{
$this->filterByArray($conditions);
return $this->find($con);
} | php | public function findByArray($conditions, $con = null)
{
$this->filterByArray($conditions);
return $this->find($con);
} | [
"public",
"function",
"findByArray",
"(",
"$",
"conditions",
",",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"filterByArray",
"(",
"$",
"conditions",
")",
";",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"con",
")",
";",
"}"
] | Apply a list of conditions on columns and issues the SELECT query
<code>
$c->findByArray(array(
'Title' => 'War And Peace',
'Publisher' => $publisher
), $con);
</code>
@see filterByArray()
@see find()
@param mixed $conditions An array of conditions, using column phpNames as key
@param PropelPDO $con an optional connection object
@return mixed the list of results, formatted by the current formatter | [
"Apply",
"a",
"list",
"of",
"conditions",
"on",
"columns",
"and",
"issues",
"the",
"SELECT",
"query",
"<code",
">",
"$c",
"-",
">",
"findByArray",
"(",
"array",
"(",
"Title",
"=",
">",
"War",
"And",
"Peace",
"Publisher",
"=",
">",
"$publisher",
")",
"$con",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1432-L1437 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findOneBy | public function findOneBy($column, $value, $con = null)
{
$method = 'filterBy' . $column;
$this->$method($value);
return $this->findOne($con);
} | php | public function findOneBy($column, $value, $con = null)
{
$method = 'filterBy' . $column;
$this->$method($value);
return $this->findOne($con);
} | [
"public",
"function",
"findOneBy",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"'filterBy'",
".",
"$",
"column",
";",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Apply a condition on a column and issues the SELECT ... LIMIT 1 query
@see filterBy()
@see findOne()
@param mixed $column A string representing thecolumn phpName, e.g. 'AuthorId'
@param mixed $value A value for the condition
@param PropelPDO $con an optional connection object
@return mixed the result, formatted by the current formatter | [
"Apply",
"a",
"condition",
"on",
"a",
"column",
"and",
"issues",
"the",
"SELECT",
"...",
"LIMIT",
"1",
"query"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1451-L1457 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.findOneByArray | public function findOneByArray($conditions, $con = null)
{
$this->filterByArray($conditions);
return $this->findOne($con);
} | php | public function findOneByArray($conditions, $con = null)
{
$this->filterByArray($conditions);
return $this->findOne($con);
} | [
"public",
"function",
"findOneByArray",
"(",
"$",
"conditions",
",",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"filterByArray",
"(",
"$",
"conditions",
")",
";",
"return",
"$",
"this",
"->",
"findOne",
"(",
"$",
"con",
")",
";",
"}"
] | Apply a list of conditions on columns and issues the SELECT ... LIMIT 1 query
<code>
$c->findOneByArray(array(
'Title' => 'War And Peace',
'Publisher' => $publisher
), $con);
</code>
@see filterByArray()
@see findOne()
@param mixed $conditions An array of conditions, using column phpNames as key
@param PropelPDO $con an optional connection object
@return mixed the list of results, formatted by the current formatter | [
"Apply",
"a",
"list",
"of",
"conditions",
"on",
"columns",
"and",
"issues",
"the",
"SELECT",
"...",
"LIMIT",
"1",
"query",
"<code",
">",
"$c",
"-",
">",
"findOneByArray",
"(",
"array",
"(",
"Title",
"=",
">",
"War",
"And",
"Peace",
"Publisher",
"=",
">",
"$publisher",
")",
"$con",
")",
";",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1476-L1481 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.count | public function count($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->setDbName($this->getDbName()); // Set the correct dbName
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME'));
$stmt = $criteria->doCount($con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
} | php | public function count($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->setDbName($this->getDbName()); // Set the correct dbName
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
// We need to set the primary table name, since in the case that there are no WHERE columns
// it will be impossible for the BasePeer::createSelectSql() method to determine which
// tables go into the FROM clause.
$criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME'));
$stmt = $criteria->doCount($con);
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$count = (int) $row[0];
} else {
$count = 0; // no rows returned; we infer that means 0 matches.
}
$stmt->closeCursor();
return $count;
} | [
"public",
"function",
"count",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"criteria",
"->",
"setDbName",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
")",
";",
"// Set the correct dbName",
"$",
"criteria",
"->",
"clearOrderByColumns",
"(",
")",
";",
"// ORDER BY won't ever affect the count",
"// We need to set the primary table name, since in the case that there are no WHERE columns",
"// it will be impossible for the BasePeer::createSelectSql() method to determine which",
"// tables go into the FROM clause.",
"$",
"criteria",
"->",
"setPrimaryTableName",
"(",
"constant",
"(",
"$",
"this",
"->",
"modelPeerName",
".",
"'::TABLE_NAME'",
")",
")",
";",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"doCount",
"(",
"$",
"con",
")",
";",
"if",
"(",
"$",
"row",
"=",
"$",
"stmt",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_NUM",
")",
")",
"{",
"$",
"count",
"=",
"(",
"int",
")",
"$",
"row",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"count",
"=",
"0",
";",
"// no rows returned; we infer that means 0 matches.",
"}",
"$",
"stmt",
"->",
"closeCursor",
"(",
")",
";",
"return",
"$",
"count",
";",
"}"
] | Issue a SELECT COUNT(*) query based on the current ModelCriteria
@param PropelPDO $con an optional connection object
@return integer the number of results | [
"Issue",
"a",
"SELECT",
"COUNT",
"(",
"*",
")",
"query",
"based",
"on",
"the",
"current",
"ModelCriteria"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1490-L1514 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.delete | public function delete($con = null)
{
if (count($this->getMap()) == 0) {
throw new PropelException('delete() expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table');
}
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE);
}
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->setDbName($this->getDbName());
$con->beginTransaction();
try {
if (!$affectedRows = $criteria->basePreDelete($con)) {
$affectedRows = $criteria->doDelete($con);
}
$criteria->basePostDelete($affectedRows, $con);
$con->commit();
} catch (Exception $e) {
$con->rollback();
throw $e;
}
return $affectedRows;
} | php | public function delete($con = null)
{
if (count($this->getMap()) == 0) {
throw new PropelException('delete() expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table');
}
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE);
}
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->setDbName($this->getDbName());
$con->beginTransaction();
try {
if (!$affectedRows = $criteria->basePreDelete($con)) {
$affectedRows = $criteria->doDelete($con);
}
$criteria->basePostDelete($affectedRows, $con);
$con->commit();
} catch (Exception $e) {
$con->rollback();
throw $e;
}
return $affectedRows;
} | [
"public",
"function",
"delete",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getMap",
"(",
")",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'delete() expects a Criteria with at least one condition. Use deleteAll() to delete all the rows of a table'",
")",
";",
"}",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"criteria",
"->",
"setDbName",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
")",
";",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"affectedRows",
"=",
"$",
"criteria",
"->",
"basePreDelete",
"(",
"$",
"con",
")",
")",
"{",
"$",
"affectedRows",
"=",
"$",
"criteria",
"->",
"doDelete",
"(",
"$",
"con",
")",
";",
"}",
"$",
"criteria",
"->",
"basePostDelete",
"(",
"$",
"affectedRows",
",",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"affectedRows",
";",
"}"
] | Issue a DELETE query based on the current ModelCriteria
An optional hook on basePreDelete() can prevent the actual deletion
@param PropelPDO $con an optional connection object
@return integer the number of deleted rows
@throws PropelException | [
"Issue",
"a",
"DELETE",
"query",
"based",
"on",
"the",
"current",
"ModelCriteria",
"An",
"optional",
"hook",
"on",
"basePreDelete",
"()",
"can",
"prevent",
"the",
"actual",
"deletion"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1639-L1665 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.deleteAll | public function deleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
if (!$affectedRows = $this->basePreDelete($con)) {
$affectedRows = $this->doDeleteAll($con);
}
$this->basePostDelete($affectedRows, $con);
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | php | public function deleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
if (!$affectedRows = $this->basePreDelete($con)) {
$affectedRows = $this->doDeleteAll($con);
}
$this->basePostDelete($affectedRows, $con);
$con->commit();
return $affectedRows;
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
} | [
"public",
"function",
"deleteAll",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"affectedRows",
"=",
"$",
"this",
"->",
"basePreDelete",
"(",
"$",
"con",
")",
")",
"{",
"$",
"affectedRows",
"=",
"$",
"this",
"->",
"doDeleteAll",
"(",
"$",
"con",
")",
";",
"}",
"$",
"this",
"->",
"basePostDelete",
"(",
"$",
"affectedRows",
",",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"return",
"$",
"affectedRows",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Issue a DELETE query based on the current ModelCriteria deleting all rows in the table
An optional hook on basePreDelete() can prevent the actual deletion
@param PropelPDO $con an optional connection object
@return integer the number of deleted rows
@throws Exception|PropelException | [
"Issue",
"a",
"DELETE",
"query",
"based",
"on",
"the",
"current",
"ModelCriteria",
"deleting",
"all",
"rows",
"in",
"the",
"table",
"An",
"optional",
"hook",
"on",
"basePreDelete",
"()",
"can",
"prevent",
"the",
"actual",
"deletion"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1692-L1710 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.basePreUpdate | protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false)
{
return $this->preUpdate($values, $con, $forceIndividualSaves);
} | php | protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false)
{
return $this->preUpdate($values, $con, $forceIndividualSaves);
} | [
"protected",
"function",
"basePreUpdate",
"(",
"&",
"$",
"values",
",",
"PropelPDO",
"$",
"con",
",",
"$",
"forceIndividualSaves",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"preUpdate",
"(",
"$",
"values",
",",
"$",
"con",
",",
"$",
"forceIndividualSaves",
")",
";",
"}"
] | Code to execute before every UPDATE statement
@param array $values The associative array of columns and values for the update
@param PropelPDO $con The connection object used by the query
@param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects | [
"Code",
"to",
"execute",
"before",
"every",
"UPDATE",
"statement"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1734-L1737 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.update | public function update($values, $con = null, $forceIndividualSaves = false)
{
if (!is_array($values)) {
throw new PropelException('set() expects an array as first argument');
}
if (count($this->getJoins())) {
throw new PropelException('set() does not support multitable updates, please do not use join()');
}
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE);
}
/* @var $criteria ModelCriteria */
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME'));
$con->beginTransaction();
try {
if (!$affectedRows = $criteria->basePreUpdate($values, $con, $forceIndividualSaves)) {
$affectedRows = $criteria->doUpdate($values, $con, $forceIndividualSaves);
}
$criteria->basePostUpdate($affectedRows, $con);
$con->commit();
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
} | php | public function update($values, $con = null, $forceIndividualSaves = false)
{
if (!is_array($values)) {
throw new PropelException('set() expects an array as first argument');
}
if (count($this->getJoins())) {
throw new PropelException('set() does not support multitable updates, please do not use join()');
}
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_WRITE);
}
/* @var $criteria ModelCriteria */
$criteria = $this->isKeepQuery() ? clone $this : $this;
$criteria->setPrimaryTableName(constant($this->modelPeerName . '::TABLE_NAME'));
$con->beginTransaction();
try {
if (!$affectedRows = $criteria->basePreUpdate($values, $con, $forceIndividualSaves)) {
$affectedRows = $criteria->doUpdate($values, $con, $forceIndividualSaves);
}
$criteria->basePostUpdate($affectedRows, $con);
$con->commit();
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
return $affectedRows;
} | [
"public",
"function",
"update",
"(",
"$",
"values",
",",
"$",
"con",
"=",
"null",
",",
"$",
"forceIndividualSaves",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'set() expects an array as first argument'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getJoins",
"(",
")",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'set() does not support multitable updates, please do not use join()'",
")",
";",
"}",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"/* @var $criteria ModelCriteria */",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"criteria",
"->",
"setPrimaryTableName",
"(",
"constant",
"(",
"$",
"this",
"->",
"modelPeerName",
".",
"'::TABLE_NAME'",
")",
")",
";",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"affectedRows",
"=",
"$",
"criteria",
"->",
"basePreUpdate",
"(",
"$",
"values",
",",
"$",
"con",
",",
"$",
"forceIndividualSaves",
")",
")",
"{",
"$",
"affectedRows",
"=",
"$",
"criteria",
"->",
"doUpdate",
"(",
"$",
"values",
",",
"$",
"con",
",",
"$",
"forceIndividualSaves",
")",
";",
"}",
"$",
"criteria",
"->",
"basePostUpdate",
"(",
"$",
"affectedRows",
",",
"$",
"con",
")",
";",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollBack",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"affectedRows",
";",
"}"
] | Issue an UPDATE query based the current ModelCriteria and a list of changes.
An optional hook on basePreUpdate() can prevent the actual update.
Beware that behaviors based on hooks in the object's save() method
will only be triggered if you force individual saves, i.e. if you pass true as second argument.
@param array $values Associative array of keys and values to replace
@param PropelPDO $con an optional connection object
@param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), otherwise it is a series of save() calls on all the found objects
@return Integer Number of updated rows
@throws PropelException | [
"Issue",
"an",
"UPDATE",
"query",
"based",
"the",
"current",
"ModelCriteria",
"and",
"a",
"list",
"of",
"changes",
".",
"An",
"optional",
"hook",
"on",
"basePreUpdate",
"()",
"can",
"prevent",
"the",
"actual",
"update",
".",
"Beware",
"that",
"behaviors",
"based",
"on",
"hooks",
"in",
"the",
"object",
"s",
"save",
"()",
"method",
"will",
"only",
"be",
"triggered",
"if",
"you",
"force",
"individual",
"saves",
"i",
".",
"e",
".",
"if",
"you",
"pass",
"true",
"as",
"second",
"argument",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1772-L1804 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.getCriterionForClause | protected function getCriterionForClause($clause, $value, $bindingType = null)
{
$clause = trim($clause);
if ($this->replaceNames($clause)) {
// at least one column name was found and replaced in the clause
// this is enough to determine the type to bind the parameter to
if (null !== $bindingType) {
$operator = ModelCriteria::MODEL_CLAUSE_RAW;
} elseif (preg_match('/IN \?$/i', $clause) !== 0) {
$operator = ModelCriteria::MODEL_CLAUSE_ARRAY;
} elseif (preg_match('/LIKE \?$/i', $clause) !== 0) {
$operator = ModelCriteria::MODEL_CLAUSE_LIKE;
} elseif (substr_count($clause, '?') > 1) {
$operator = ModelCriteria::MODEL_CLAUSE_SEVERAL;
} else {
$operator = ModelCriteria::MODEL_CLAUSE;
}
$colMap = $this->replacedColumns[0];
$value = $this->convertValueForColumn($value, $colMap);
$criterion = new ModelCriterion($this, $colMap, $value, $operator, $clause, $bindingType);
if ($this->currentAlias != '') {
$criterion->setTable($this->currentAlias);
}
} else {
// no column match in clause, must be an expression like '1=1'
if (strpos($clause, '?') !== false) {
if (null === $bindingType) {
throw new PropelException("Cannot determine the column to bind to the parameter in clause '$clause'");
}
$criterion = new Criterion($this, $clause, $value, Criteria::RAW, $bindingType);
} else {
$criterion = new Criterion($this, null, $clause, Criteria::CUSTOM);
}
}
return $criterion;
} | php | protected function getCriterionForClause($clause, $value, $bindingType = null)
{
$clause = trim($clause);
if ($this->replaceNames($clause)) {
// at least one column name was found and replaced in the clause
// this is enough to determine the type to bind the parameter to
if (null !== $bindingType) {
$operator = ModelCriteria::MODEL_CLAUSE_RAW;
} elseif (preg_match('/IN \?$/i', $clause) !== 0) {
$operator = ModelCriteria::MODEL_CLAUSE_ARRAY;
} elseif (preg_match('/LIKE \?$/i', $clause) !== 0) {
$operator = ModelCriteria::MODEL_CLAUSE_LIKE;
} elseif (substr_count($clause, '?') > 1) {
$operator = ModelCriteria::MODEL_CLAUSE_SEVERAL;
} else {
$operator = ModelCriteria::MODEL_CLAUSE;
}
$colMap = $this->replacedColumns[0];
$value = $this->convertValueForColumn($value, $colMap);
$criterion = new ModelCriterion($this, $colMap, $value, $operator, $clause, $bindingType);
if ($this->currentAlias != '') {
$criterion->setTable($this->currentAlias);
}
} else {
// no column match in clause, must be an expression like '1=1'
if (strpos($clause, '?') !== false) {
if (null === $bindingType) {
throw new PropelException("Cannot determine the column to bind to the parameter in clause '$clause'");
}
$criterion = new Criterion($this, $clause, $value, Criteria::RAW, $bindingType);
} else {
$criterion = new Criterion($this, null, $clause, Criteria::CUSTOM);
}
}
return $criterion;
} | [
"protected",
"function",
"getCriterionForClause",
"(",
"$",
"clause",
",",
"$",
"value",
",",
"$",
"bindingType",
"=",
"null",
")",
"{",
"$",
"clause",
"=",
"trim",
"(",
"$",
"clause",
")",
";",
"if",
"(",
"$",
"this",
"->",
"replaceNames",
"(",
"$",
"clause",
")",
")",
"{",
"// at least one column name was found and replaced in the clause",
"// this is enough to determine the type to bind the parameter to",
"if",
"(",
"null",
"!==",
"$",
"bindingType",
")",
"{",
"$",
"operator",
"=",
"ModelCriteria",
"::",
"MODEL_CLAUSE_RAW",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/IN \\?$/i'",
",",
"$",
"clause",
")",
"!==",
"0",
")",
"{",
"$",
"operator",
"=",
"ModelCriteria",
"::",
"MODEL_CLAUSE_ARRAY",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/LIKE \\?$/i'",
",",
"$",
"clause",
")",
"!==",
"0",
")",
"{",
"$",
"operator",
"=",
"ModelCriteria",
"::",
"MODEL_CLAUSE_LIKE",
";",
"}",
"elseif",
"(",
"substr_count",
"(",
"$",
"clause",
",",
"'?'",
")",
">",
"1",
")",
"{",
"$",
"operator",
"=",
"ModelCriteria",
"::",
"MODEL_CLAUSE_SEVERAL",
";",
"}",
"else",
"{",
"$",
"operator",
"=",
"ModelCriteria",
"::",
"MODEL_CLAUSE",
";",
"}",
"$",
"colMap",
"=",
"$",
"this",
"->",
"replacedColumns",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"convertValueForColumn",
"(",
"$",
"value",
",",
"$",
"colMap",
")",
";",
"$",
"criterion",
"=",
"new",
"ModelCriterion",
"(",
"$",
"this",
",",
"$",
"colMap",
",",
"$",
"value",
",",
"$",
"operator",
",",
"$",
"clause",
",",
"$",
"bindingType",
")",
";",
"if",
"(",
"$",
"this",
"->",
"currentAlias",
"!=",
"''",
")",
"{",
"$",
"criterion",
"->",
"setTable",
"(",
"$",
"this",
"->",
"currentAlias",
")",
";",
"}",
"}",
"else",
"{",
"// no column match in clause, must be an expression like '1=1'",
"if",
"(",
"strpos",
"(",
"$",
"clause",
",",
"'?'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"bindingType",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Cannot determine the column to bind to the parameter in clause '$clause'\"",
")",
";",
"}",
"$",
"criterion",
"=",
"new",
"Criterion",
"(",
"$",
"this",
",",
"$",
"clause",
",",
"$",
"value",
",",
"Criteria",
"::",
"RAW",
",",
"$",
"bindingType",
")",
";",
"}",
"else",
"{",
"$",
"criterion",
"=",
"new",
"Criterion",
"(",
"$",
"this",
",",
"null",
",",
"$",
"clause",
",",
"Criteria",
"::",
"CUSTOM",
")",
";",
"}",
"}",
"return",
"$",
"criterion",
";",
"}"
] | Creates a Criterion object based on a SQL clause and a value
Uses introspection to translate the column phpName into a fully qualified name
@param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
@param mixed $value A value for the condition
@param string $bindingType
@return Criterion a Criterion or ModelCriterion object
@throws PropelException | [
"Creates",
"a",
"Criterion",
"object",
"based",
"on",
"a",
"SQL",
"clause",
"and",
"a",
"value",
"Uses",
"introspection",
"to",
"translate",
"the",
"column",
"phpName",
"into",
"a",
"fully",
"qualified",
"name"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1875-L1911 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.convertValueForColumn | protected function convertValueForColumn($value, ColumnMap $colMap)
{
if ($colMap->getType() == 'OBJECT' && is_object($value)) {
if (is_array($value)) {
$value = array_map('serialize', $value);
} else {
$value = serialize($value);
}
} elseif ($colMap->getType() == 'ARRAY' && is_array($value)) {
$value = '| ' . implode(' | ', $value) . ' |';
} elseif ($colMap->getType() == 'ENUM') {
if (is_array($value)) {
$value = array_map(array($colMap, 'getValueSetKey'), $value);
} else {
$value = $colMap->getValueSetKey($value);
}
}
return $value;
} | php | protected function convertValueForColumn($value, ColumnMap $colMap)
{
if ($colMap->getType() == 'OBJECT' && is_object($value)) {
if (is_array($value)) {
$value = array_map('serialize', $value);
} else {
$value = serialize($value);
}
} elseif ($colMap->getType() == 'ARRAY' && is_array($value)) {
$value = '| ' . implode(' | ', $value) . ' |';
} elseif ($colMap->getType() == 'ENUM') {
if (is_array($value)) {
$value = array_map(array($colMap, 'getValueSetKey'), $value);
} else {
$value = $colMap->getValueSetKey($value);
}
}
return $value;
} | [
"protected",
"function",
"convertValueForColumn",
"(",
"$",
"value",
",",
"ColumnMap",
"$",
"colMap",
")",
"{",
"if",
"(",
"$",
"colMap",
"->",
"getType",
"(",
")",
"==",
"'OBJECT'",
"&&",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"'serialize'",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"serialize",
"(",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"colMap",
"->",
"getType",
"(",
")",
"==",
"'ARRAY'",
"&&",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"'| '",
".",
"implode",
"(",
"' | '",
",",
"$",
"value",
")",
".",
"' |'",
";",
"}",
"elseif",
"(",
"$",
"colMap",
"->",
"getType",
"(",
")",
"==",
"'ENUM'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"array",
"(",
"$",
"colMap",
",",
"'getValueSetKey'",
")",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"colMap",
"->",
"getValueSetKey",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Converts value for some column types
@param mixed $value The value to convert
@param ColumnMap $colMap The ColumnMap object
@return mixed The converted value | [
"Converts",
"value",
"for",
"some",
"column",
"types"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1921-L1940 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.replaceNames | protected function replaceNames(&$clause)
{
$this->replacedColumns = array();
$this->currentAlias = '';
$this->foundMatch = false;
$isAfterBackslash = false;
$isInString = false;
$stringQuotes = '';
$parsedString = '';
$stringToTransform = '';
$len = strlen($clause);
$pos = 0;
while ($pos < $len) {
$char = $clause[$pos];
// check flags for strings or escaper
switch ($char) {
case "\\":
$isAfterBackslash = true;
break;
case "'":
case "\"":
if ($isInString && $stringQuotes == $char) {
if (!$isAfterBackslash) {
$isInString = false;
}
} elseif (!$isInString) {
$parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
$stringToTransform = '';
$stringQuotes = $char;
$isInString = true;
}
break;
}
if ($char !== "\\") {
$isAfterBackslash = false;
}
if ($isInString) {
$parsedString .= $char;
} else {
$stringToTransform .= $char;
}
$pos++;
}
if ($stringToTransform) {
$parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
}
$clause = $parsedString;
return $this->foundMatch;
} | php | protected function replaceNames(&$clause)
{
$this->replacedColumns = array();
$this->currentAlias = '';
$this->foundMatch = false;
$isAfterBackslash = false;
$isInString = false;
$stringQuotes = '';
$parsedString = '';
$stringToTransform = '';
$len = strlen($clause);
$pos = 0;
while ($pos < $len) {
$char = $clause[$pos];
// check flags for strings or escaper
switch ($char) {
case "\\":
$isAfterBackslash = true;
break;
case "'":
case "\"":
if ($isInString && $stringQuotes == $char) {
if (!$isAfterBackslash) {
$isInString = false;
}
} elseif (!$isInString) {
$parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
$stringToTransform = '';
$stringQuotes = $char;
$isInString = true;
}
break;
}
if ($char !== "\\") {
$isAfterBackslash = false;
}
if ($isInString) {
$parsedString .= $char;
} else {
$stringToTransform .= $char;
}
$pos++;
}
if ($stringToTransform) {
$parsedString .= preg_replace_callback("/[\w\\\]+\.\w+/", array($this, 'doReplaceNameInExpression'), $stringToTransform);
}
$clause = $parsedString;
return $this->foundMatch;
} | [
"protected",
"function",
"replaceNames",
"(",
"&",
"$",
"clause",
")",
"{",
"$",
"this",
"->",
"replacedColumns",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"currentAlias",
"=",
"''",
";",
"$",
"this",
"->",
"foundMatch",
"=",
"false",
";",
"$",
"isAfterBackslash",
"=",
"false",
";",
"$",
"isInString",
"=",
"false",
";",
"$",
"stringQuotes",
"=",
"''",
";",
"$",
"parsedString",
"=",
"''",
";",
"$",
"stringToTransform",
"=",
"''",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"clause",
")",
";",
"$",
"pos",
"=",
"0",
";",
"while",
"(",
"$",
"pos",
"<",
"$",
"len",
")",
"{",
"$",
"char",
"=",
"$",
"clause",
"[",
"$",
"pos",
"]",
";",
"// check flags for strings or escaper",
"switch",
"(",
"$",
"char",
")",
"{",
"case",
"\"\\\\\"",
":",
"$",
"isAfterBackslash",
"=",
"true",
";",
"break",
";",
"case",
"\"'\"",
":",
"case",
"\"\\\"\"",
":",
"if",
"(",
"$",
"isInString",
"&&",
"$",
"stringQuotes",
"==",
"$",
"char",
")",
"{",
"if",
"(",
"!",
"$",
"isAfterBackslash",
")",
"{",
"$",
"isInString",
"=",
"false",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"isInString",
")",
"{",
"$",
"parsedString",
".=",
"preg_replace_callback",
"(",
"\"/[\\w\\\\\\]+\\.\\w+/\"",
",",
"array",
"(",
"$",
"this",
",",
"'doReplaceNameInExpression'",
")",
",",
"$",
"stringToTransform",
")",
";",
"$",
"stringToTransform",
"=",
"''",
";",
"$",
"stringQuotes",
"=",
"$",
"char",
";",
"$",
"isInString",
"=",
"true",
";",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"char",
"!==",
"\"\\\\\"",
")",
"{",
"$",
"isAfterBackslash",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"isInString",
")",
"{",
"$",
"parsedString",
".=",
"$",
"char",
";",
"}",
"else",
"{",
"$",
"stringToTransform",
".=",
"$",
"char",
";",
"}",
"$",
"pos",
"++",
";",
"}",
"if",
"(",
"$",
"stringToTransform",
")",
"{",
"$",
"parsedString",
".=",
"preg_replace_callback",
"(",
"\"/[\\w\\\\\\]+\\.\\w+/\"",
",",
"array",
"(",
"$",
"this",
",",
"'doReplaceNameInExpression'",
")",
",",
"$",
"stringToTransform",
")",
";",
"}",
"$",
"clause",
"=",
"$",
"parsedString",
";",
"return",
"$",
"this",
"->",
"foundMatch",
";",
"}"
] | Replaces complete column names (like Article.AuthorId) in an SQL clause
by their exact Propel column fully qualified name (e.g. article.AUTHOR_ID)
but ignores the column names inside quotes
e.g. 'CONCAT(Book.Title, "Book.Title") = ?'
=> 'CONCAT(book.TITLE, "Book.Title") = ?'
@param string $clause SQL clause to inspect (modified by the method)
@return boolean Whether the method managed to find and replace at least one column name | [
"Replaces",
"complete",
"column",
"names",
"(",
"like",
"Article",
".",
"AuthorId",
")",
"in",
"an",
"SQL",
"clause",
"by",
"their",
"exact",
"Propel",
"column",
"fully",
"qualified",
"name",
"(",
"e",
".",
"g",
".",
"article",
".",
"AUTHOR_ID",
")",
"but",
"ignores",
"the",
"column",
"names",
"inside",
"quotes",
"e",
".",
"g",
".",
"CONCAT",
"(",
"Book",
".",
"Title",
"Book",
".",
"Title",
")",
"=",
"?",
"=",
">",
"CONCAT",
"(",
"book",
".",
"TITLE",
"Book",
".",
"Title",
")",
"=",
"?"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L1953-L2003 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.doReplaceNameInExpression | protected function doReplaceNameInExpression($matches)
{
$key = $matches[0];
list($column, $realColumnName) = $this->getColumnFromName($key);
if ($column instanceof ColumnMap) {
$this->replacedColumns[] = $column;
$this->foundMatch = true;
return $realColumnName;
} else {
return $key;
}
} | php | protected function doReplaceNameInExpression($matches)
{
$key = $matches[0];
list($column, $realColumnName) = $this->getColumnFromName($key);
if ($column instanceof ColumnMap) {
$this->replacedColumns[] = $column;
$this->foundMatch = true;
return $realColumnName;
} else {
return $key;
}
} | [
"protected",
"function",
"doReplaceNameInExpression",
"(",
"$",
"matches",
")",
"{",
"$",
"key",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"list",
"(",
"$",
"column",
",",
"$",
"realColumnName",
")",
"=",
"$",
"this",
"->",
"getColumnFromName",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"column",
"instanceof",
"ColumnMap",
")",
"{",
"$",
"this",
"->",
"replacedColumns",
"[",
"]",
"=",
"$",
"column",
";",
"$",
"this",
"->",
"foundMatch",
"=",
"true",
";",
"return",
"$",
"realColumnName",
";",
"}",
"else",
"{",
"return",
"$",
"key",
";",
"}",
"}"
] | Callback function to replace column names by their real name in a clause
e.g. 'Book.Title IN ?'
=> 'book.TITLE IN ?'
@param array $matches Matches found by preg_replace_callback
@return string the column name replacement | [
"Callback",
"function",
"to",
"replace",
"column",
"names",
"by",
"their",
"real",
"name",
"in",
"a",
"clause",
"e",
".",
"g",
".",
"Book",
".",
"Title",
"IN",
"?",
"=",
">",
"book",
".",
"TITLE",
"IN",
"?"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L2014-L2026 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.getColumnFromName | protected function getColumnFromName($phpName, $failSilently = true)
{
if (strpos($phpName, '.') === false) {
$prefix = $this->getModelAliasOrName();
} else {
// $prefix could be either class name or table name
list($prefix, $phpName) = explode('.', $phpName);
}
if ($prefix == $this->getModelAliasOrName() || $prefix == $this->getTableMap()->getName()) {
// column of the Criteria's model, or column name from Criteria's peer
$tableMap = $this->getTableMap();
} elseif (isset($this->joins[$prefix])) {
// column of a relations's model
$tableMap = $this->joins[$prefix]->getTableMap();
} elseif ($this->hasSelectQuery($prefix)) {
return $this->getColumnFromSubQuery($prefix, $phpName, $failSilently);
} elseif ($failSilently) {
return array(null, null);
} else {
throw new PropelException(sprintf('Unknown model, alias or table "%s"', $prefix));
}
if ($tableMap->hasColumnByPhpName($phpName)) {
$column = $tableMap->getColumnByPhpName($phpName);
if (isset($this->aliases[$prefix])) {
$this->currentAlias = $prefix;
$realColumnName = $prefix . '.' . $column->getName();
} else {
$realColumnName = $column->getFullyQualifiedName();
}
return array($column, $realColumnName);
} elseif ($tableMap->hasColumn($phpName, false)) {
$column = $tableMap->getColumn($phpName, false);
$realColumnName = $column->getFullyQualifiedName();
return array($column, $realColumnName);
} elseif (isset($this->asColumns[$phpName])) {
// aliased column
return array(null, $phpName);
} elseif ($tableMap->hasColumnByInsensitiveCase($phpName)) {
$column = $tableMap->getColumnByInsensitiveCase($phpName);
$realColumnName = $column->getFullyQualifiedName();
return array($column, $realColumnName);
} elseif ($failSilently) {
return array(null, null);
} else {
throw new PropelException(sprintf('Unknown column "%s" on model, alias or table "%s"', $phpName, $prefix));
}
} | php | protected function getColumnFromName($phpName, $failSilently = true)
{
if (strpos($phpName, '.') === false) {
$prefix = $this->getModelAliasOrName();
} else {
// $prefix could be either class name or table name
list($prefix, $phpName) = explode('.', $phpName);
}
if ($prefix == $this->getModelAliasOrName() || $prefix == $this->getTableMap()->getName()) {
// column of the Criteria's model, or column name from Criteria's peer
$tableMap = $this->getTableMap();
} elseif (isset($this->joins[$prefix])) {
// column of a relations's model
$tableMap = $this->joins[$prefix]->getTableMap();
} elseif ($this->hasSelectQuery($prefix)) {
return $this->getColumnFromSubQuery($prefix, $phpName, $failSilently);
} elseif ($failSilently) {
return array(null, null);
} else {
throw new PropelException(sprintf('Unknown model, alias or table "%s"', $prefix));
}
if ($tableMap->hasColumnByPhpName($phpName)) {
$column = $tableMap->getColumnByPhpName($phpName);
if (isset($this->aliases[$prefix])) {
$this->currentAlias = $prefix;
$realColumnName = $prefix . '.' . $column->getName();
} else {
$realColumnName = $column->getFullyQualifiedName();
}
return array($column, $realColumnName);
} elseif ($tableMap->hasColumn($phpName, false)) {
$column = $tableMap->getColumn($phpName, false);
$realColumnName = $column->getFullyQualifiedName();
return array($column, $realColumnName);
} elseif (isset($this->asColumns[$phpName])) {
// aliased column
return array(null, $phpName);
} elseif ($tableMap->hasColumnByInsensitiveCase($phpName)) {
$column = $tableMap->getColumnByInsensitiveCase($phpName);
$realColumnName = $column->getFullyQualifiedName();
return array($column, $realColumnName);
} elseif ($failSilently) {
return array(null, null);
} else {
throw new PropelException(sprintf('Unknown column "%s" on model, alias or table "%s"', $phpName, $prefix));
}
} | [
"protected",
"function",
"getColumnFromName",
"(",
"$",
"phpName",
",",
"$",
"failSilently",
"=",
"true",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"phpName",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getModelAliasOrName",
"(",
")",
";",
"}",
"else",
"{",
"// $prefix could be either class name or table name",
"list",
"(",
"$",
"prefix",
",",
"$",
"phpName",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"phpName",
")",
";",
"}",
"if",
"(",
"$",
"prefix",
"==",
"$",
"this",
"->",
"getModelAliasOrName",
"(",
")",
"||",
"$",
"prefix",
"==",
"$",
"this",
"->",
"getTableMap",
"(",
")",
"->",
"getName",
"(",
")",
")",
"{",
"// column of the Criteria's model, or column name from Criteria's peer",
"$",
"tableMap",
"=",
"$",
"this",
"->",
"getTableMap",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"joins",
"[",
"$",
"prefix",
"]",
")",
")",
"{",
"// column of a relations's model",
"$",
"tableMap",
"=",
"$",
"this",
"->",
"joins",
"[",
"$",
"prefix",
"]",
"->",
"getTableMap",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"hasSelectQuery",
"(",
"$",
"prefix",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getColumnFromSubQuery",
"(",
"$",
"prefix",
",",
"$",
"phpName",
",",
"$",
"failSilently",
")",
";",
"}",
"elseif",
"(",
"$",
"failSilently",
")",
"{",
"return",
"array",
"(",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unknown model, alias or table \"%s\"'",
",",
"$",
"prefix",
")",
")",
";",
"}",
"if",
"(",
"$",
"tableMap",
"->",
"hasColumnByPhpName",
"(",
"$",
"phpName",
")",
")",
"{",
"$",
"column",
"=",
"$",
"tableMap",
"->",
"getColumnByPhpName",
"(",
"$",
"phpName",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"prefix",
"]",
")",
")",
"{",
"$",
"this",
"->",
"currentAlias",
"=",
"$",
"prefix",
";",
"$",
"realColumnName",
"=",
"$",
"prefix",
".",
"'.'",
".",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"realColumnName",
"=",
"$",
"column",
"->",
"getFullyQualifiedName",
"(",
")",
";",
"}",
"return",
"array",
"(",
"$",
"column",
",",
"$",
"realColumnName",
")",
";",
"}",
"elseif",
"(",
"$",
"tableMap",
"->",
"hasColumn",
"(",
"$",
"phpName",
",",
"false",
")",
")",
"{",
"$",
"column",
"=",
"$",
"tableMap",
"->",
"getColumn",
"(",
"$",
"phpName",
",",
"false",
")",
";",
"$",
"realColumnName",
"=",
"$",
"column",
"->",
"getFullyQualifiedName",
"(",
")",
";",
"return",
"array",
"(",
"$",
"column",
",",
"$",
"realColumnName",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"asColumns",
"[",
"$",
"phpName",
"]",
")",
")",
"{",
"// aliased column",
"return",
"array",
"(",
"null",
",",
"$",
"phpName",
")",
";",
"}",
"elseif",
"(",
"$",
"tableMap",
"->",
"hasColumnByInsensitiveCase",
"(",
"$",
"phpName",
")",
")",
"{",
"$",
"column",
"=",
"$",
"tableMap",
"->",
"getColumnByInsensitiveCase",
"(",
"$",
"phpName",
")",
";",
"$",
"realColumnName",
"=",
"$",
"column",
"->",
"getFullyQualifiedName",
"(",
")",
";",
"return",
"array",
"(",
"$",
"column",
",",
"$",
"realColumnName",
")",
";",
"}",
"elseif",
"(",
"$",
"failSilently",
")",
"{",
"return",
"array",
"(",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unknown column \"%s\" on model, alias or table \"%s\"'",
",",
"$",
"phpName",
",",
"$",
"prefix",
")",
")",
";",
"}",
"}"
] | Finds a column and a SQL translation for a pseudo SQL column name
Respects table aliases previously registered in a join() or addAlias()
Examples:
<code>
$c->getColumnFromName('Book.Title');
=> array($bookTitleColumnMap, 'book.TITLE')
$c->join('Book.Author a')
->getColumnFromName('a.FirstName');
=> array($authorFirstNameColumnMap, 'a.FIRST_NAME')
</code>
@param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title'
@param boolean $failSilently
@return array List($columnMap, $realColumnName)
@throws PropelException | [
"Finds",
"a",
"column",
"and",
"a",
"SQL",
"translation",
"for",
"a",
"pseudo",
"SQL",
"column",
"name",
"Respects",
"table",
"aliases",
"previously",
"registered",
"in",
"a",
"join",
"()",
"or",
"addAlias",
"()",
"Examples",
":",
"<code",
">",
"$c",
"-",
">",
"getColumnFromName",
"(",
"Book",
".",
"Title",
")",
";",
"=",
">",
"array",
"(",
"$bookTitleColumnMap",
"book",
".",
"TITLE",
")",
"$c",
"-",
">",
"join",
"(",
"Book",
".",
"Author",
"a",
")",
"-",
">",
"getColumnFromName",
"(",
"a",
".",
"FirstName",
")",
";",
"=",
">",
"array",
"(",
"$authorFirstNameColumnMap",
"a",
".",
"FIRST_NAME",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L2047-L2098 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.addUsingAlias | public function addUsingAlias($column, $value = null, $operator = null)
{
return $this->addUsingOperator($this->getAliasedColName($column), $value, $operator);
} | php | public function addUsingAlias($column, $value = null, $operator = null)
{
return $this->addUsingOperator($this->getAliasedColName($column), $value, $operator);
} | [
"public",
"function",
"addUsingAlias",
"(",
"$",
"column",
",",
"$",
"value",
"=",
"null",
",",
"$",
"operator",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingOperator",
"(",
"$",
"this",
"->",
"getAliasedColName",
"(",
"$",
"column",
")",
",",
"$",
"value",
",",
"$",
"operator",
")",
";",
"}"
] | Overrides Criteria::add() to force the use of a true table alias if it exists
@see Criteria::add()
@param string $column The colName of column to run the condition on (e.g. BookPeer::ID)
@param mixed $value
@param string $operator A String, like Criteria::EQUAL.
@return ModelCriteria A modified Criteria object. | [
"Overrides",
"Criteria",
"::",
"add",
"()",
"to",
"force",
"the",
"use",
"of",
"a",
"true",
"table",
"alias",
"if",
"it",
"exists"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L2183-L2186 |
propelorm/Propel | runtime/lib/query/ModelCriteria.php | ModelCriteria.explain | public function explain($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName());
}
$this->basePreSelect($con);
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$this->configureSelectColumns();
$db = Propel::getDB($this->getDbName());
try {
$stmt = $db->doExplainPlan($con, $this);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException('Unable to execute query explain plan', $e);
}
} | php | public function explain($con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName());
}
$this->basePreSelect($con);
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
$this->addSelfSelectColumns();
}
$this->configureSelectColumns();
$db = Propel::getDB($this->getDbName());
try {
$stmt = $db->doExplainPlan($con, $this);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException('Unable to execute query explain plan', $e);
}
} | [
"public",
"function",
"explain",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"// check that the columns of the main class are already added (if this is the primary ModelCriteria)",
"if",
"(",
"!",
"$",
"this",
"->",
"hasSelectClause",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getPrimaryCriteria",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addSelfSelectColumns",
"(",
")",
";",
"}",
"$",
"this",
"->",
"configureSelectColumns",
"(",
")",
";",
"$",
"db",
"=",
"Propel",
"::",
"getDB",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"db",
"->",
"doExplainPlan",
"(",
"$",
"con",
",",
"$",
"this",
")",
";",
"return",
"$",
"stmt",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"'Unable to execute query explain plan'",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Make explain plan of the query
@param PropelPDO $con propel connection
@throws PropelException on error
@return array array of the explain plan | [
"Make",
"explain",
"plan",
"of",
"the",
"query"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/ModelCriteria.php#L2315-L2337 |
propelorm/Propel | generator/lib/model/Database.php | Database.setupObject | protected function setupObject()
{
parent::setupObject();
$this->name = $this->getAttribute("name");
$this->baseClass = $this->getAttribute("baseClass");
$this->basePeer = $this->getAttribute("basePeer");
$this->defaultIdMethod = $this->getAttribute("defaultIdMethod", IDMethod::NATIVE);
$this->defaultPhpNamingMethod = $this->getAttribute("defaultPhpNamingMethod", NameGenerator::CONV_METHOD_UNDERSCORE);
$this->defaultTranslateMethod = $this->getAttribute("defaultTranslateMethod", Validator::TRANSLATE_NONE);
$this->heavyIndexing = $this->booleanValue($this->getAttribute("heavyIndexing"));
$this->tablePrefix = $this->getAttribute('tablePrefix', $this->getBuildProperty('tablePrefix'));
$this->defaultStringFormat = $this->getAttribute('defaultStringFormat', 'YAML');
} | php | protected function setupObject()
{
parent::setupObject();
$this->name = $this->getAttribute("name");
$this->baseClass = $this->getAttribute("baseClass");
$this->basePeer = $this->getAttribute("basePeer");
$this->defaultIdMethod = $this->getAttribute("defaultIdMethod", IDMethod::NATIVE);
$this->defaultPhpNamingMethod = $this->getAttribute("defaultPhpNamingMethod", NameGenerator::CONV_METHOD_UNDERSCORE);
$this->defaultTranslateMethod = $this->getAttribute("defaultTranslateMethod", Validator::TRANSLATE_NONE);
$this->heavyIndexing = $this->booleanValue($this->getAttribute("heavyIndexing"));
$this->tablePrefix = $this->getAttribute('tablePrefix', $this->getBuildProperty('tablePrefix'));
$this->defaultStringFormat = $this->getAttribute('defaultStringFormat', 'YAML');
} | [
"protected",
"function",
"setupObject",
"(",
")",
"{",
"parent",
"::",
"setupObject",
"(",
")",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"name\"",
")",
";",
"$",
"this",
"->",
"baseClass",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"baseClass\"",
")",
";",
"$",
"this",
"->",
"basePeer",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"basePeer\"",
")",
";",
"$",
"this",
"->",
"defaultIdMethod",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultIdMethod\"",
",",
"IDMethod",
"::",
"NATIVE",
")",
";",
"$",
"this",
"->",
"defaultPhpNamingMethod",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultPhpNamingMethod\"",
",",
"NameGenerator",
"::",
"CONV_METHOD_UNDERSCORE",
")",
";",
"$",
"this",
"->",
"defaultTranslateMethod",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultTranslateMethod\"",
",",
"Validator",
"::",
"TRANSLATE_NONE",
")",
";",
"$",
"this",
"->",
"heavyIndexing",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"heavyIndexing\"",
")",
")",
";",
"$",
"this",
"->",
"tablePrefix",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'tablePrefix'",
",",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'tablePrefix'",
")",
")",
";",
"$",
"this",
"->",
"defaultStringFormat",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'defaultStringFormat'",
",",
"'YAML'",
")",
";",
"}"
] | Sets up the Database object based on the attributes that were passed to loadFromXML().
@see parent::loadFromXML() | [
"Sets",
"up",
"the",
"Database",
"object",
"based",
"on",
"the",
"attributes",
"that",
"were",
"passed",
"to",
"loadFromXML",
"()",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L102-L114 |
propelorm/Propel | generator/lib/model/Database.php | Database.countTables | public function countTables()
{
$count = 0;
foreach ($this->tableList as $table) {
if (!$table->isReadOnly()) {
$count++;
}
}
return $count;
} | php | public function countTables()
{
$count = 0;
foreach ($this->tableList as $table) {
if (!$table->isReadOnly()) {
$count++;
}
}
return $count;
} | [
"public",
"function",
"countTables",
"(",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"tableList",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"$",
"table",
"->",
"isReadOnly",
"(",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] | Return the number of tables in the database
@return integer | [
"Return",
"the",
"number",
"of",
"tables",
"in",
"the",
"database"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L322-L332 |
propelorm/Propel | generator/lib/model/Database.php | Database.getTable | public function getTable($name, $caseInsensitive = false)
{
if ($this->hasTable($name, $caseInsensitive)) {
if ($caseInsensitive) {
return $this->tablesByLowercaseName[strtolower($name)];
} else {
return $this->tablesByName[$name];
}
}
return null; // just to be explicit
} | php | public function getTable($name, $caseInsensitive = false)
{
if ($this->hasTable($name, $caseInsensitive)) {
if ($caseInsensitive) {
return $this->tablesByLowercaseName[strtolower($name)];
} else {
return $this->tablesByName[$name];
}
}
return null; // just to be explicit
} | [
"public",
"function",
"getTable",
"(",
"$",
"name",
",",
"$",
"caseInsensitive",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasTable",
"(",
"$",
"name",
",",
"$",
"caseInsensitive",
")",
")",
"{",
"if",
"(",
"$",
"caseInsensitive",
")",
"{",
"return",
"$",
"this",
"->",
"tablesByLowercaseName",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"tablesByName",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"null",
";",
"// just to be explicit",
"}"
] | Return the table with the specified name.
@param string $name The name of the table (e.g. 'my_table')
@param boolean $caseInsensitive Whether the check is case insensitive. False by default.
@return Table a Table object or null if it doesn't exist | [
"Return",
"the",
"table",
"with",
"the",
"specified",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L376-L387 |
propelorm/Propel | generator/lib/model/Database.php | Database.addDomain | public function addDomain($data)
{
if ($data instanceof Domain) {
$domain = $data; // alias
$domain->setDatabase($this);
$this->domainMap[$domain->getName()] = $domain;
return $domain;
} else {
$domain = new Domain();
$domain->setDatabase($this);
$domain->loadFromXML($data);
return $this->addDomain($domain); // call self w/ different param
}
} | php | public function addDomain($data)
{
if ($data instanceof Domain) {
$domain = $data; // alias
$domain->setDatabase($this);
$this->domainMap[$domain->getName()] = $domain;
return $domain;
} else {
$domain = new Domain();
$domain->setDatabase($this);
$domain->loadFromXML($data);
return $this->addDomain($domain); // call self w/ different param
}
} | [
"public",
"function",
"addDomain",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Domain",
")",
"{",
"$",
"domain",
"=",
"$",
"data",
";",
"// alias",
"$",
"domain",
"->",
"setDatabase",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"domainMap",
"[",
"$",
"domain",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"domain",
";",
"return",
"$",
"domain",
";",
"}",
"else",
"{",
"$",
"domain",
"=",
"new",
"Domain",
"(",
")",
";",
"$",
"domain",
"->",
"setDatabase",
"(",
"$",
"this",
")",
";",
"$",
"domain",
"->",
"loadFromXML",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"addDomain",
"(",
"$",
"domain",
")",
";",
"// call self w/ different param",
"}",
"}"
] | Adds Domain object from <domain> tag.
@param Domain|string $data XML attributes (array) or Domain object.
@return Domain | [
"Adds",
"Domain",
"object",
"from",
"<domain",
">",
"tag",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L484-L499 |
propelorm/Propel | generator/lib/model/Database.php | Database.getDomain | public function getDomain($domainName)
{
if (isset($this->domainMap[$domainName])) {
return $this->domainMap[$domainName];
}
return null; // just to be explicit
} | php | public function getDomain($domainName)
{
if (isset($this->domainMap[$domainName])) {
return $this->domainMap[$domainName];
}
return null; // just to be explicit
} | [
"public",
"function",
"getDomain",
"(",
"$",
"domainName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"domainMap",
"[",
"$",
"domainName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"domainMap",
"[",
"$",
"domainName",
"]",
";",
"}",
"return",
"null",
";",
"// just to be explicit",
"}"
] | Get already configured Domain object by name.
@return Domain | [
"Get",
"already",
"configured",
"Domain",
"object",
"by",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L506-L513 |
propelorm/Propel | generator/lib/model/Database.php | Database.addBehavior | public function addBehavior($bdata)
{
if ($bdata instanceof Behavior) {
$behavior = $bdata;
$behavior->setDatabase($this);
$this->behaviors[$behavior->getName()] = $behavior;
return $behavior;
} else {
$class = $this->getConfiguredBehavior($bdata['name']);
$behavior = new $class();
$behavior->loadFromXML($bdata);
return $this->addBehavior($behavior);
}
} | php | public function addBehavior($bdata)
{
if ($bdata instanceof Behavior) {
$behavior = $bdata;
$behavior->setDatabase($this);
$this->behaviors[$behavior->getName()] = $behavior;
return $behavior;
} else {
$class = $this->getConfiguredBehavior($bdata['name']);
$behavior = new $class();
$behavior->loadFromXML($bdata);
return $this->addBehavior($behavior);
}
} | [
"public",
"function",
"addBehavior",
"(",
"$",
"bdata",
")",
"{",
"if",
"(",
"$",
"bdata",
"instanceof",
"Behavior",
")",
"{",
"$",
"behavior",
"=",
"$",
"bdata",
";",
"$",
"behavior",
"->",
"setDatabase",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"behaviors",
"[",
"$",
"behavior",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"behavior",
";",
"return",
"$",
"behavior",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getConfiguredBehavior",
"(",
"$",
"bdata",
"[",
"'name'",
"]",
")",
";",
"$",
"behavior",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"behavior",
"->",
"loadFromXML",
"(",
"$",
"bdata",
")",
";",
"return",
"$",
"this",
"->",
"addBehavior",
"(",
"$",
"behavior",
")",
";",
"}",
"}"
] | Adds a new Behavior to the database
@return Behavior A behavior instance | [
"Adds",
"a",
"new",
"Behavior",
"to",
"the",
"database"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L538-L553 |
propelorm/Propel | generator/lib/model/Database.php | Database.getNextTableBehavior | public function getNextTableBehavior()
{
// order the behaviors according to Behavior::$tableModificationOrder
$behaviors = array();
foreach ($this->getTables() as $table) {
foreach ($table->getBehaviors() as $behavior) {
if (!$behavior->isTableModified()) {
$behaviors[$behavior->getTableModificationOrder()][] = $behavior;
}
}
}
ksort($behaviors);
foreach ($behaviors as $behaviorList) {
foreach ($behaviorList as $behavior) {
return $behavior;
}
}
} | php | public function getNextTableBehavior()
{
// order the behaviors according to Behavior::$tableModificationOrder
$behaviors = array();
foreach ($this->getTables() as $table) {
foreach ($table->getBehaviors() as $behavior) {
if (!$behavior->isTableModified()) {
$behaviors[$behavior->getTableModificationOrder()][] = $behavior;
}
}
}
ksort($behaviors);
foreach ($behaviors as $behaviorList) {
foreach ($behaviorList as $behavior) {
return $behavior;
}
}
} | [
"public",
"function",
"getNextTableBehavior",
"(",
")",
"{",
"// order the behaviors according to Behavior::$tableModificationOrder",
"$",
"behaviors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"getBehaviors",
"(",
")",
"as",
"$",
"behavior",
")",
"{",
"if",
"(",
"!",
"$",
"behavior",
"->",
"isTableModified",
"(",
")",
")",
"{",
"$",
"behaviors",
"[",
"$",
"behavior",
"->",
"getTableModificationOrder",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"behavior",
";",
"}",
"}",
"}",
"ksort",
"(",
"$",
"behaviors",
")",
";",
"foreach",
"(",
"$",
"behaviors",
"as",
"$",
"behaviorList",
")",
"{",
"foreach",
"(",
"$",
"behaviorList",
"as",
"$",
"behavior",
")",
"{",
"return",
"$",
"behavior",
";",
"}",
"}",
"}"
] | Get the next behavior on all tables, ordered by behavior priority,
and skipping the ones that were already executed,
@return Behavior | [
"Get",
"the",
"next",
"behavior",
"on",
"all",
"tables",
"ordered",
"by",
"behavior",
"priority",
"and",
"skipping",
"the",
"ones",
"that",
"were",
"already",
"executed"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Database.php#L605-L622 |
propelorm/Propel | generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php | SortableBehaviorObjectBuilderModifier.addScopeAccessors | protected function addScopeAccessors(&$script)
{
$script .= "
/**
* Wrap the getter for scope value
*
* @param boolean \$returnNulls If true and all scope values are null, this will return null instead of a array full with nulls
*
* @return mixed A array or a native type
*/
public function getScopeValue(\$returnNulls = true)
{
";
if ($this->behavior->hasMultipleScopes()) {
$script .= "
\$result = array();
\$onlyNulls = true;
";
foreach ($this->behavior->getScopes() as $scopeField) {
$script .= "
\$onlyNulls &= null === (\$result[] = \$this->{$this->behavior->getColumnGetter($scopeField)}());
";
}
$script .= "
return \$onlyNulls && \$returnNulls ? null : \$result;
";
} else {
$script .= "
return \$this->{$this->getColumnGetter('scope_column')}();
";
}
$script .= "
}
/**
* Wrap the setter for scope value
*
* @param mixed A array or a native type
* @return {$this->objectClassname}
*/
public function setScopeValue(\$v)
{
";
if ($this->behavior->hasMultipleScopes()) {
foreach ($this->behavior->getScopes() as $idx => $scopeField) {
$script .= "
\$this->{$this->behavior->getColumnSetter($scopeField)}(\$v === null ? null : \$v[$idx]);
";
}
} else {
$script .= "
return \$this->{$this->getColumnSetter('scope_column')}(\$v);
";
}
$script .= "
}
";
} | php | protected function addScopeAccessors(&$script)
{
$script .= "
/**
* Wrap the getter for scope value
*
* @param boolean \$returnNulls If true and all scope values are null, this will return null instead of a array full with nulls
*
* @return mixed A array or a native type
*/
public function getScopeValue(\$returnNulls = true)
{
";
if ($this->behavior->hasMultipleScopes()) {
$script .= "
\$result = array();
\$onlyNulls = true;
";
foreach ($this->behavior->getScopes() as $scopeField) {
$script .= "
\$onlyNulls &= null === (\$result[] = \$this->{$this->behavior->getColumnGetter($scopeField)}());
";
}
$script .= "
return \$onlyNulls && \$returnNulls ? null : \$result;
";
} else {
$script .= "
return \$this->{$this->getColumnGetter('scope_column')}();
";
}
$script .= "
}
/**
* Wrap the setter for scope value
*
* @param mixed A array or a native type
* @return {$this->objectClassname}
*/
public function setScopeValue(\$v)
{
";
if ($this->behavior->hasMultipleScopes()) {
foreach ($this->behavior->getScopes() as $idx => $scopeField) {
$script .= "
\$this->{$this->behavior->getColumnSetter($scopeField)}(\$v === null ? null : \$v[$idx]);
";
}
} else {
$script .= "
return \$this->{$this->getColumnSetter('scope_column')}(\$v);
";
}
$script .= "
}
";
} | [
"protected",
"function",
"addScopeAccessors",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"script",
".=",
"\"\n\n/**\n * Wrap the getter for scope value\n *\n * @param boolean \\$returnNulls If true and all scope values are null, this will return null instead of a array full with nulls\n *\n * @return mixed A array or a native type\n */\npublic function getScopeValue(\\$returnNulls = true)\n{\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"behavior",
"->",
"hasMultipleScopes",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\"\n \\$result = array();\n \\$onlyNulls = true;\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"behavior",
"->",
"getScopes",
"(",
")",
"as",
"$",
"scopeField",
")",
"{",
"$",
"script",
".=",
"\"\n \\$onlyNulls &= null === (\\$result[] = \\$this->{$this->behavior->getColumnGetter($scopeField)}());\n\"",
";",
"}",
"$",
"script",
".=",
"\"\n\n return \\$onlyNulls && \\$returnNulls ? null : \\$result;\n\"",
";",
"}",
"else",
"{",
"$",
"script",
".=",
"\"\n\n return \\$this->{$this->getColumnGetter('scope_column')}();\n\"",
";",
"}",
"$",
"script",
".=",
"\"\n}\n\n/**\n * Wrap the setter for scope value\n *\n * @param mixed A array or a native type\n * @return {$this->objectClassname}\n */\npublic function setScopeValue(\\$v)\n{\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"behavior",
"->",
"hasMultipleScopes",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"behavior",
"->",
"getScopes",
"(",
")",
"as",
"$",
"idx",
"=>",
"$",
"scopeField",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->{$this->behavior->getColumnSetter($scopeField)}(\\$v === null ? null : \\$v[$idx]);\n\"",
";",
"}",
"}",
"else",
"{",
"$",
"script",
".=",
"\"\n\n return \\$this->{$this->getColumnSetter('scope_column')}(\\$v);\n\"",
";",
"}",
"$",
"script",
".=",
"\"\n}\n\"",
";",
"}"
] | Get the wraps for getter/setter, if the scope column has not the default name
@return string | [
"Get",
"the",
"wraps",
"for",
"getter",
"/",
"setter",
"if",
"the",
"scope",
"column",
"has",
"not",
"the",
"default",
"name"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/sortable/SortableBehaviorObjectBuilderModifier.php#L264-L334 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.getConfiguration | public function getConfiguration()
{
if (null === $this->configuration) {
$this->configuration = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
}
return $this->configuration;
} | php | public function getConfiguration()
{
if (null === $this->configuration) {
$this->configuration = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
}
return $this->configuration;
} | [
"public",
"function",
"getConfiguration",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"configuration",
")",
"{",
"$",
"this",
"->",
"configuration",
"=",
"Propel",
"::",
"getConfiguration",
"(",
"PropelConfiguration",
"::",
"TYPE_OBJECT",
")",
";",
"}",
"return",
"$",
"this",
"->",
"configuration",
";",
"}"
] | Get the runtime configuration
@return PropelConfiguration | [
"Get",
"the",
"runtime",
"configuration"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L176-L183 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.beginTransaction | public function beginTransaction()
{
$return = true;
if (!$this->nestedTransactionCount) {
$return = parent::beginTransaction();
if ($this->useDebug) {
$this->log('Begin transaction', null, __METHOD__);
}
$this->isUncommitable = false;
}
$this->nestedTransactionCount++;
return $return;
} | php | public function beginTransaction()
{
$return = true;
if (!$this->nestedTransactionCount) {
$return = parent::beginTransaction();
if ($this->useDebug) {
$this->log('Begin transaction', null, __METHOD__);
}
$this->isUncommitable = false;
}
$this->nestedTransactionCount++;
return $return;
} | [
"public",
"function",
"beginTransaction",
"(",
")",
"{",
"$",
"return",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"nestedTransactionCount",
")",
"{",
"$",
"return",
"=",
"parent",
"::",
"beginTransaction",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Begin transaction'",
",",
"null",
",",
"__METHOD__",
")",
";",
"}",
"$",
"this",
"->",
"isUncommitable",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"nestedTransactionCount",
"++",
";",
"return",
"$",
"return",
";",
"}"
] | Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction.
@return boolean | [
"Overrides",
"PDO",
"::",
"beginTransaction",
"()",
"to",
"prevent",
"errors",
"due",
"to",
"already",
"-",
"in",
"-",
"progress",
"transaction",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L232-L245 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.commit | public function commit()
{
$return = true;
$opcount = $this->nestedTransactionCount;
if ($opcount > 0) {
if ($opcount === 1) {
if ($this->isUncommitable) {
throw new PropelException('Cannot commit because a nested transaction was rolled back');
} else {
$return = parent::commit();
if ($this->useDebug) {
$this->log('Commit transaction', null, __METHOD__);
}
}
}
$this->nestedTransactionCount--;
}
return $return;
} | php | public function commit()
{
$return = true;
$opcount = $this->nestedTransactionCount;
if ($opcount > 0) {
if ($opcount === 1) {
if ($this->isUncommitable) {
throw new PropelException('Cannot commit because a nested transaction was rolled back');
} else {
$return = parent::commit();
if ($this->useDebug) {
$this->log('Commit transaction', null, __METHOD__);
}
}
}
$this->nestedTransactionCount--;
}
return $return;
} | [
"public",
"function",
"commit",
"(",
")",
"{",
"$",
"return",
"=",
"true",
";",
"$",
"opcount",
"=",
"$",
"this",
"->",
"nestedTransactionCount",
";",
"if",
"(",
"$",
"opcount",
">",
"0",
")",
"{",
"if",
"(",
"$",
"opcount",
"===",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isUncommitable",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot commit because a nested transaction was rolled back'",
")",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"parent",
"::",
"commit",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Commit transaction'",
",",
"null",
",",
"__METHOD__",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"nestedTransactionCount",
"--",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Overrides PDO::commit() to only commit the transaction if we are in the outermost
transaction nesting level.
@return boolean
@throws PropelException | [
"Overrides",
"PDO",
"::",
"commit",
"()",
"to",
"only",
"commit",
"the",
"transaction",
"if",
"we",
"are",
"in",
"the",
"outermost",
"transaction",
"nesting",
"level",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L255-L276 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.rollBack | public function rollBack()
{
$return = true;
$opcount = $this->nestedTransactionCount;
if ($opcount > 0) {
if ($opcount === 1) {
$return = parent::rollBack();
if ($this->useDebug) {
$this->log('Rollback transaction', null, __METHOD__);
}
} else {
$this->isUncommitable = true;
}
$this->nestedTransactionCount--;
}
return $return;
} | php | public function rollBack()
{
$return = true;
$opcount = $this->nestedTransactionCount;
if ($opcount > 0) {
if ($opcount === 1) {
$return = parent::rollBack();
if ($this->useDebug) {
$this->log('Rollback transaction', null, __METHOD__);
}
} else {
$this->isUncommitable = true;
}
$this->nestedTransactionCount--;
}
return $return;
} | [
"public",
"function",
"rollBack",
"(",
")",
"{",
"$",
"return",
"=",
"true",
";",
"$",
"opcount",
"=",
"$",
"this",
"->",
"nestedTransactionCount",
";",
"if",
"(",
"$",
"opcount",
">",
"0",
")",
"{",
"if",
"(",
"$",
"opcount",
"===",
"1",
")",
"{",
"$",
"return",
"=",
"parent",
"::",
"rollBack",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Rollback transaction'",
",",
"null",
",",
"__METHOD__",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"isUncommitable",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"nestedTransactionCount",
"--",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost
transaction nesting level
@return boolean Whether operation was successful. | [
"Overrides",
"PDO",
"::",
"rollBack",
"()",
"to",
"only",
"rollback",
"the",
"transaction",
"if",
"we",
"are",
"in",
"the",
"outermost",
"transaction",
"nesting",
"level"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L284-L303 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.forceRollBack | public function forceRollBack()
{
$return = true;
if ($this->nestedTransactionCount) {
// If we're in a transaction, always roll it back
// regardless of nesting level.
$return = parent::rollBack();
// reset nested transaction count to 0 so that we don't
// try to commit (or rollback) the transaction outside this scope.
$this->nestedTransactionCount = 0;
if ($this->useDebug) {
$this->log('Rollback transaction', null, __METHOD__);
}
}
return $return;
} | php | public function forceRollBack()
{
$return = true;
if ($this->nestedTransactionCount) {
// If we're in a transaction, always roll it back
// regardless of nesting level.
$return = parent::rollBack();
// reset nested transaction count to 0 so that we don't
// try to commit (or rollback) the transaction outside this scope.
$this->nestedTransactionCount = 0;
if ($this->useDebug) {
$this->log('Rollback transaction', null, __METHOD__);
}
}
return $return;
} | [
"public",
"function",
"forceRollBack",
"(",
")",
"{",
"$",
"return",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"nestedTransactionCount",
")",
"{",
"// If we're in a transaction, always roll it back",
"// regardless of nesting level.",
"$",
"return",
"=",
"parent",
"::",
"rollBack",
"(",
")",
";",
"// reset nested transaction count to 0 so that we don't",
"// try to commit (or rollback) the transaction outside this scope.",
"$",
"this",
"->",
"nestedTransactionCount",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'Rollback transaction'",
",",
"null",
",",
"__METHOD__",
")",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Rollback the whole transaction, even if this is a nested rollback
and reset the nested transaction count to 0.
@return boolean Whether operation was successful. | [
"Rollback",
"the",
"whole",
"transaction",
"even",
"if",
"this",
"is",
"a",
"nested",
"rollback",
"and",
"reset",
"the",
"nested",
"transaction",
"count",
"to",
"0",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L311-L330 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.setAttribute | public function setAttribute($attribute, $value)
{
switch ($attribute) {
case self::PROPEL_ATTR_CACHE_PREPARES:
$this->cachePreparedStatements = $value;
break;
case self::PROPEL_ATTR_CONNECTION_NAME:
$this->connectionName = $value;
break;
default:
parent::setAttribute($attribute, $value);
}
} | php | public function setAttribute($attribute, $value)
{
switch ($attribute) {
case self::PROPEL_ATTR_CACHE_PREPARES:
$this->cachePreparedStatements = $value;
break;
case self::PROPEL_ATTR_CONNECTION_NAME:
$this->connectionName = $value;
break;
default:
parent::setAttribute($attribute, $value);
}
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"attribute",
")",
"{",
"case",
"self",
"::",
"PROPEL_ATTR_CACHE_PREPARES",
":",
"$",
"this",
"->",
"cachePreparedStatements",
"=",
"$",
"value",
";",
"break",
";",
"case",
"self",
"::",
"PROPEL_ATTR_CONNECTION_NAME",
":",
"$",
"this",
"->",
"connectionName",
"=",
"$",
"value",
";",
"break",
";",
"default",
":",
"parent",
"::",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Sets a connection attribute.
This is overridden here to provide support for setting Propel-specific attributes too.
@param integer $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
@param mixed $value The attribute value.
@return void | [
"Sets",
"a",
"connection",
"attribute",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L342-L354 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.getAttribute | public function getAttribute($attribute)
{
switch ($attribute) {
case self::PROPEL_ATTR_CACHE_PREPARES:
return $this->cachePreparedStatements;
break;
case self::PROPEL_ATTR_CONNECTION_NAME:
return $this->connectionName;
break;
default:
return parent::getAttribute($attribute);
}
} | php | public function getAttribute($attribute)
{
switch ($attribute) {
case self::PROPEL_ATTR_CACHE_PREPARES:
return $this->cachePreparedStatements;
break;
case self::PROPEL_ATTR_CONNECTION_NAME:
return $this->connectionName;
break;
default:
return parent::getAttribute($attribute);
}
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"attribute",
")",
"{",
"switch",
"(",
"$",
"attribute",
")",
"{",
"case",
"self",
"::",
"PROPEL_ATTR_CACHE_PREPARES",
":",
"return",
"$",
"this",
"->",
"cachePreparedStatements",
";",
"break",
";",
"case",
"self",
"::",
"PROPEL_ATTR_CONNECTION_NAME",
":",
"return",
"$",
"this",
"->",
"connectionName",
";",
"break",
";",
"default",
":",
"return",
"parent",
"::",
"getAttribute",
"(",
"$",
"attribute",
")",
";",
"}",
"}"
] | Gets a connection attribute.
This is overridden here to provide support for setting Propel-specific attributes too.
@param integer $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
@return mixed | [
"Gets",
"a",
"connection",
"attribute",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L365-L377 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.prepare | public function prepare($sql, $driver_options = array())
{
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
if ($this->cachePreparedStatements) {
if (!isset($this->preparedStatements[$sql])) {
$return = parent::prepare($sql, $driver_options);
$this->preparedStatements[$sql] = $return;
} else {
$return = $this->preparedStatements[$sql];
}
} else {
$return = parent::prepare($sql, $driver_options);
}
if ($this->useDebug) {
$this->log($sql, null, __METHOD__, $debug);
}
return $return;
} | php | public function prepare($sql, $driver_options = array())
{
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
if ($this->cachePreparedStatements) {
if (!isset($this->preparedStatements[$sql])) {
$return = parent::prepare($sql, $driver_options);
$this->preparedStatements[$sql] = $return;
} else {
$return = $this->preparedStatements[$sql];
}
} else {
$return = parent::prepare($sql, $driver_options);
}
if ($this->useDebug) {
$this->log($sql, null, __METHOD__, $debug);
}
return $return;
} | [
"public",
"function",
"prepare",
"(",
"$",
"sql",
",",
"$",
"driver_options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"debug",
"=",
"$",
"this",
"->",
"getDebugSnapshot",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cachePreparedStatements",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"preparedStatements",
"[",
"$",
"sql",
"]",
")",
")",
"{",
"$",
"return",
"=",
"parent",
"::",
"prepare",
"(",
"$",
"sql",
",",
"$",
"driver_options",
")",
";",
"$",
"this",
"->",
"preparedStatements",
"[",
"$",
"sql",
"]",
"=",
"$",
"return",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"preparedStatements",
"[",
"$",
"sql",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"parent",
"::",
"prepare",
"(",
"$",
"sql",
",",
"$",
"driver_options",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"sql",
",",
"null",
",",
"__METHOD__",
",",
"$",
"debug",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Prepares a statement for execution and returns a statement object.
Overrides PDO::prepare() in order to:
- Add logging and query counting if logging is true.
- Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true.
@param string $sql This must be a valid SQL statement for the target database server.
@param array $driver_options One $array or more key => value pairs to set attribute values
for the PDOStatement object that this method returns.
@return PDOStatement | [
"Prepares",
"a",
"statement",
"for",
"execution",
"and",
"returns",
"a",
"statement",
"object",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L392-L414 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.exec | public function exec($sql)
{
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
$return = parent::exec($sql);
if ($this->useDebug) {
$this->log($sql, null, __METHOD__, $debug);
$this->setLastExecutedQuery($sql);
$this->incrementQueryCount();
}
return $return;
} | php | public function exec($sql)
{
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
$return = parent::exec($sql);
if ($this->useDebug) {
$this->log($sql, null, __METHOD__, $debug);
$this->setLastExecutedQuery($sql);
$this->incrementQueryCount();
}
return $return;
} | [
"public",
"function",
"exec",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"debug",
"=",
"$",
"this",
"->",
"getDebugSnapshot",
"(",
")",
";",
"}",
"$",
"return",
"=",
"parent",
"::",
"exec",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"sql",
",",
"null",
",",
"__METHOD__",
",",
"$",
"debug",
")",
";",
"$",
"this",
"->",
"setLastExecutedQuery",
"(",
"$",
"sql",
")",
";",
"$",
"this",
"->",
"incrementQueryCount",
"(",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Execute an SQL statement and return the number of affected rows.
Overrides PDO::exec() to log queries when required
@param string $sql
@return integer | [
"Execute",
"an",
"SQL",
"statement",
"and",
"return",
"the",
"number",
"of",
"affected",
"rows",
".",
"Overrides",
"PDO",
"::",
"exec",
"()",
"to",
"log",
"queries",
"when",
"required"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L424-L439 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.query | public function query()
{
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
$args = func_get_args();
if (version_compare(PHP_VERSION, '5.3', '<')) {
$return = call_user_func_array(array($this, 'parent::query'), $args);
} else {
$return = call_user_func_array('parent::query', $args);
}
if ($this->useDebug) {
$sql = $args[0];
$this->log($sql, null, __METHOD__, $debug);
$this->setLastExecutedQuery($sql);
$this->incrementQueryCount();
}
return $return;
} | php | public function query()
{
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
$args = func_get_args();
if (version_compare(PHP_VERSION, '5.3', '<')) {
$return = call_user_func_array(array($this, 'parent::query'), $args);
} else {
$return = call_user_func_array('parent::query', $args);
}
if ($this->useDebug) {
$sql = $args[0];
$this->log($sql, null, __METHOD__, $debug);
$this->setLastExecutedQuery($sql);
$this->incrementQueryCount();
}
return $return;
} | [
"public",
"function",
"query",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"debug",
"=",
"$",
"this",
"->",
"getDebugSnapshot",
"(",
")",
";",
"}",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.3'",
",",
"'<'",
")",
")",
"{",
"$",
"return",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"'parent::query'",
")",
",",
"$",
"args",
")",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"call_user_func_array",
"(",
"'parent::query'",
",",
"$",
"args",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"$",
"sql",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"sql",
",",
"null",
",",
"__METHOD__",
",",
"$",
"debug",
")",
";",
"$",
"this",
"->",
"setLastExecutedQuery",
"(",
"$",
"sql",
")",
";",
"$",
"this",
"->",
"incrementQueryCount",
"(",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Executes an SQL statement, returning a result set as a PDOStatement object.
Despite its signature here, this method takes a variety of parameters.
Overrides PDO::query() to log queries when required
@see http://php.net/manual/en/pdo.query.php for a description of the possible parameters.
@return PDOStatement | [
"Executes",
"an",
"SQL",
"statement",
"returning",
"a",
"result",
"set",
"as",
"a",
"PDOStatement",
"object",
".",
"Despite",
"its",
"signature",
"here",
"this",
"method",
"takes",
"a",
"variety",
"of",
"parameters",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L451-L472 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.configureStatementClass | protected function configureStatementClass($class = 'PDOStatement', $suppressError = true)
{
// extending PDOStatement is only supported with non-persistent connections
if (!$this->getAttribute(PDO::ATTR_PERSISTENT)) {
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($class, array($this)));
} elseif (!$suppressError) {
throw new PropelException('Extending PDOStatement is not supported with persistent connections.');
}
} | php | protected function configureStatementClass($class = 'PDOStatement', $suppressError = true)
{
// extending PDOStatement is only supported with non-persistent connections
if (!$this->getAttribute(PDO::ATTR_PERSISTENT)) {
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($class, array($this)));
} elseif (!$suppressError) {
throw new PropelException('Extending PDOStatement is not supported with persistent connections.');
}
} | [
"protected",
"function",
"configureStatementClass",
"(",
"$",
"class",
"=",
"'PDOStatement'",
",",
"$",
"suppressError",
"=",
"true",
")",
"{",
"// extending PDOStatement is only supported with non-persistent connections",
"if",
"(",
"!",
"$",
"this",
"->",
"getAttribute",
"(",
"PDO",
"::",
"ATTR_PERSISTENT",
")",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"PDO",
"::",
"ATTR_STATEMENT_CLASS",
",",
"array",
"(",
"$",
"class",
",",
"array",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"suppressError",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Extending PDOStatement is not supported with persistent connections.'",
")",
";",
"}",
"}"
] | Configures the PDOStatement class for this connection.
@param string $class
@param boolean $suppressError Whether to suppress an exception if the statement class cannot be set.
@throws PropelException if the statement class cannot be set (and $suppressError is false). | [
"Configures",
"the",
"PDOStatement",
"class",
"for",
"this",
"connection",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L490-L498 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.useDebug | public function useDebug($value = true)
{
if ($value) {
$this->configureStatementClass('DebugPDOStatement', true);
} else {
// reset query logging
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'));
$this->setLastExecutedQuery('');
$this->queryCount = 0;
}
$this->clearStatementCache();
$this->useDebug = $value;
} | php | public function useDebug($value = true)
{
if ($value) {
$this->configureStatementClass('DebugPDOStatement', true);
} else {
// reset query logging
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'));
$this->setLastExecutedQuery('');
$this->queryCount = 0;
}
$this->clearStatementCache();
$this->useDebug = $value;
} | [
"public",
"function",
"useDebug",
"(",
"$",
"value",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"configureStatementClass",
"(",
"'DebugPDOStatement'",
",",
"true",
")",
";",
"}",
"else",
"{",
"// reset query logging",
"$",
"this",
"->",
"setAttribute",
"(",
"PDO",
"::",
"ATTR_STATEMENT_CLASS",
",",
"array",
"(",
"'PDOStatement'",
")",
")",
";",
"$",
"this",
"->",
"setLastExecutedQuery",
"(",
"''",
")",
";",
"$",
"this",
"->",
"queryCount",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"clearStatementCache",
"(",
")",
";",
"$",
"this",
"->",
"useDebug",
"=",
"$",
"value",
";",
"}"
] | Enable or disable the query debug features
@param boolean $value True to enable debug (default), false to disable it | [
"Enable",
"or",
"disable",
"the",
"query",
"debug",
"features"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L556-L568 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.log | public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null)
{
// If logging has been specifically disabled, this method won't do anything
if (!$this->getLoggingConfig('enabled', true)) {
return;
}
// If the method being logged isn't one of the ones to be logged, bail
if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) {
return;
}
// If a logging level wasn't provided, use the default one
if ($level === null) {
$level = $this->logLevel;
}
// Determine if this query is slow enough to warrant logging
if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) {
$now = $this->getDebugSnapshot();
if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) {
return;
}
}
// If the necessary additional parameters were given, get the debug log prefix for the log line
if ($methodName && $debugSnapshot) {
$msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg;
}
// We won't log empty messages
if (!$msg) {
return;
}
// Delegate the actual logging forward
if ($this->logger) {
$this->logger->log($msg, $level);
} else {
Propel::log($msg, $level);
}
} | php | public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null)
{
// If logging has been specifically disabled, this method won't do anything
if (!$this->getLoggingConfig('enabled', true)) {
return;
}
// If the method being logged isn't one of the ones to be logged, bail
if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) {
return;
}
// If a logging level wasn't provided, use the default one
if ($level === null) {
$level = $this->logLevel;
}
// Determine if this query is slow enough to warrant logging
if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) {
$now = $this->getDebugSnapshot();
if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) {
return;
}
}
// If the necessary additional parameters were given, get the debug log prefix for the log line
if ($methodName && $debugSnapshot) {
$msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg;
}
// We won't log empty messages
if (!$msg) {
return;
}
// Delegate the actual logging forward
if ($this->logger) {
$this->logger->log($msg, $level);
} else {
Propel::log($msg, $level);
}
} | [
"public",
"function",
"log",
"(",
"$",
"msg",
",",
"$",
"level",
"=",
"null",
",",
"$",
"methodName",
"=",
"null",
",",
"array",
"$",
"debugSnapshot",
"=",
"null",
")",
"{",
"// If logging has been specifically disabled, this method won't do anything",
"if",
"(",
"!",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'enabled'",
",",
"true",
")",
")",
"{",
"return",
";",
"}",
"// If the method being logged isn't one of the ones to be logged, bail",
"if",
"(",
"!",
"in_array",
"(",
"$",
"methodName",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'methods'",
",",
"self",
"::",
"$",
"defaultLogMethods",
")",
")",
")",
"{",
"return",
";",
"}",
"// If a logging level wasn't provided, use the default one",
"if",
"(",
"$",
"level",
"===",
"null",
")",
"{",
"$",
"level",
"=",
"$",
"this",
"->",
"logLevel",
";",
"}",
"// Determine if this query is slow enough to warrant logging",
"if",
"(",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"\"onlyslow\"",
",",
"self",
"::",
"DEFAULT_ONLYSLOW_ENABLED",
")",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"getDebugSnapshot",
"(",
")",
";",
"if",
"(",
"$",
"now",
"[",
"'microtime'",
"]",
"-",
"$",
"debugSnapshot",
"[",
"'microtime'",
"]",
"<",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"\"details.slow.threshold\"",
",",
"self",
"::",
"DEFAULT_SLOW_THRESHOLD",
")",
")",
"{",
"return",
";",
"}",
"}",
"// If the necessary additional parameters were given, get the debug log prefix for the log line",
"if",
"(",
"$",
"methodName",
"&&",
"$",
"debugSnapshot",
")",
"{",
"$",
"msg",
"=",
"$",
"this",
"->",
"getLogPrefix",
"(",
"$",
"methodName",
",",
"$",
"debugSnapshot",
")",
".",
"$",
"msg",
";",
"}",
"// We won't log empty messages",
"if",
"(",
"!",
"$",
"msg",
")",
"{",
"return",
";",
"}",
"// Delegate the actual logging forward",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"log",
"(",
"$",
"msg",
",",
"$",
"level",
")",
";",
"}",
"else",
"{",
"Propel",
"::",
"log",
"(",
"$",
"msg",
",",
"$",
"level",
")",
";",
"}",
"}"
] | Logs the method call or SQL using the Propel::log() method or a registered logger class.
@uses self::getLogPrefix()
@see self::setLogger()
@param string $msg Message to log.
@param integer $level Log level to use; will use self::setLogLevel() specified level by default.
@param string $methodName Name of the method whose execution is being logged.
@param array $debugSnapshot Previous return value from self::getDebugSnapshot(). | [
"Logs",
"the",
"method",
"call",
"or",
"SQL",
"using",
"the",
"Propel",
"::",
"log",
"()",
"method",
"or",
"a",
"registered",
"logger",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L613-L654 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.getDebugSnapshot | public function getDebugSnapshot()
{
if ($this->useDebug) {
return array(
'microtime' => microtime(true),
'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)),
'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)),
);
} else {
throw new PropelException('Should not get debug snapshot when not debugging');
}
} | php | public function getDebugSnapshot()
{
if ($this->useDebug) {
return array(
'microtime' => microtime(true),
'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)),
'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)),
);
} else {
throw new PropelException('Should not get debug snapshot when not debugging');
}
} | [
"public",
"function",
"getDebugSnapshot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useDebug",
")",
"{",
"return",
"array",
"(",
"'microtime'",
"=>",
"microtime",
"(",
"true",
")",
",",
"'memory_get_usage'",
"=>",
"memory_get_usage",
"(",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'realmemoryusage'",
",",
"false",
")",
")",
",",
"'memory_get_peak_usage'",
"=>",
"memory_get_peak_usage",
"(",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'realmemoryusage'",
",",
"false",
")",
")",
",",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'Should not get debug snapshot when not debugging'",
")",
";",
"}",
"}"
] | Returns a snapshot of the current values of some functions useful in debugging.
@return array
@throws PropelException | [
"Returns",
"a",
"snapshot",
"of",
"the",
"current",
"values",
"of",
"some",
"functions",
"useful",
"in",
"debugging",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L663-L674 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.getLogPrefix | protected function getLogPrefix($methodName, $debugSnapshot)
{
$config = $this->getConfiguration()->getParameters();
if (!isset($config['debugpdo']['logging']['details'])) {
return '';
}
$prefix = '';
$logDetails = $config['debugpdo']['logging']['details'];
$now = $this->getDebugSnapshot();
$innerGlue = $this->getLoggingConfig('innerglue', ': ');
$outerGlue = $this->getLoggingConfig('outerglue', ' | ');
// Iterate through each detail that has been configured to be enabled
foreach ($logDetails as $detailName => $details) {
if (!$this->getLoggingConfig("details.$detailName.enabled", false)) {
continue;
}
switch ($detailName) {
case 'slow';
$value = $now['microtime'] - $debugSnapshot['microtime'] >= $this->getLoggingConfig('details.slow.threshold', self::DEFAULT_SLOW_THRESHOLD) ? 'YES' : ' NO';
break;
case 'time':
$value = number_format($now['microtime'] - $debugSnapshot['microtime'], $this->getLoggingConfig('details.time.precision', 3)) . ' sec';
$value = str_pad($value, $this->getLoggingConfig('details.time.pad', 10), ' ', STR_PAD_LEFT);
break;
case 'mem':
$value = self::getReadableBytes($now['memory_get_usage'], $this->getLoggingConfig('details.mem.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.mem.pad', 9), ' ', STR_PAD_LEFT);
break;
case 'memdelta':
$value = $now['memory_get_usage'] - $debugSnapshot['memory_get_usage'];
$value = ($value > 0 ? '+' : '') . self::getReadableBytes($value, $this->getLoggingConfig('details.memdelta.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.memdelta.pad', 10), ' ', STR_PAD_LEFT);
break;
case 'mempeak':
$value = self::getReadableBytes($now['memory_get_peak_usage'], $this->getLoggingConfig('details.mempeak.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.mempeak.pad', 9), ' ', STR_PAD_LEFT);
break;
case 'querycount':
$value = str_pad($this->getQueryCount(), $this->getLoggingConfig('details.querycount.pad', 2), ' ', STR_PAD_LEFT);
break;
case 'method':
$value = str_pad($methodName, $this->getLoggingConfig('details.method.pad', 28), ' ', STR_PAD_RIGHT);
break;
case 'connection':
$value = $this->connectionName;
break;
default:
$value = 'n/a';
break;
}
$prefix .= $detailName . $innerGlue . $value . $outerGlue;
}
return $prefix;
} | php | protected function getLogPrefix($methodName, $debugSnapshot)
{
$config = $this->getConfiguration()->getParameters();
if (!isset($config['debugpdo']['logging']['details'])) {
return '';
}
$prefix = '';
$logDetails = $config['debugpdo']['logging']['details'];
$now = $this->getDebugSnapshot();
$innerGlue = $this->getLoggingConfig('innerglue', ': ');
$outerGlue = $this->getLoggingConfig('outerglue', ' | ');
// Iterate through each detail that has been configured to be enabled
foreach ($logDetails as $detailName => $details) {
if (!$this->getLoggingConfig("details.$detailName.enabled", false)) {
continue;
}
switch ($detailName) {
case 'slow';
$value = $now['microtime'] - $debugSnapshot['microtime'] >= $this->getLoggingConfig('details.slow.threshold', self::DEFAULT_SLOW_THRESHOLD) ? 'YES' : ' NO';
break;
case 'time':
$value = number_format($now['microtime'] - $debugSnapshot['microtime'], $this->getLoggingConfig('details.time.precision', 3)) . ' sec';
$value = str_pad($value, $this->getLoggingConfig('details.time.pad', 10), ' ', STR_PAD_LEFT);
break;
case 'mem':
$value = self::getReadableBytes($now['memory_get_usage'], $this->getLoggingConfig('details.mem.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.mem.pad', 9), ' ', STR_PAD_LEFT);
break;
case 'memdelta':
$value = $now['memory_get_usage'] - $debugSnapshot['memory_get_usage'];
$value = ($value > 0 ? '+' : '') . self::getReadableBytes($value, $this->getLoggingConfig('details.memdelta.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.memdelta.pad', 10), ' ', STR_PAD_LEFT);
break;
case 'mempeak':
$value = self::getReadableBytes($now['memory_get_peak_usage'], $this->getLoggingConfig('details.mempeak.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.mempeak.pad', 9), ' ', STR_PAD_LEFT);
break;
case 'querycount':
$value = str_pad($this->getQueryCount(), $this->getLoggingConfig('details.querycount.pad', 2), ' ', STR_PAD_LEFT);
break;
case 'method':
$value = str_pad($methodName, $this->getLoggingConfig('details.method.pad', 28), ' ', STR_PAD_RIGHT);
break;
case 'connection':
$value = $this->connectionName;
break;
default:
$value = 'n/a';
break;
}
$prefix .= $detailName . $innerGlue . $value . $outerGlue;
}
return $prefix;
} | [
"protected",
"function",
"getLogPrefix",
"(",
"$",
"methodName",
",",
"$",
"debugSnapshot",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
")",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'debugpdo'",
"]",
"[",
"'logging'",
"]",
"[",
"'details'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"prefix",
"=",
"''",
";",
"$",
"logDetails",
"=",
"$",
"config",
"[",
"'debugpdo'",
"]",
"[",
"'logging'",
"]",
"[",
"'details'",
"]",
";",
"$",
"now",
"=",
"$",
"this",
"->",
"getDebugSnapshot",
"(",
")",
";",
"$",
"innerGlue",
"=",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'innerglue'",
",",
"': '",
")",
";",
"$",
"outerGlue",
"=",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'outerglue'",
",",
"' | '",
")",
";",
"// Iterate through each detail that has been configured to be enabled",
"foreach",
"(",
"$",
"logDetails",
"as",
"$",
"detailName",
"=>",
"$",
"details",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"\"details.$detailName.enabled\"",
",",
"false",
")",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"$",
"detailName",
")",
"{",
"case",
"'slow'",
";",
"$",
"value",
"=",
"$",
"now",
"[",
"'microtime'",
"]",
"-",
"$",
"debugSnapshot",
"[",
"'microtime'",
"]",
">=",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.slow.threshold'",
",",
"self",
"::",
"DEFAULT_SLOW_THRESHOLD",
")",
"?",
"'YES'",
":",
"' NO'",
";",
"break",
";",
"case",
"'time'",
":",
"$",
"value",
"=",
"number_format",
"(",
"$",
"now",
"[",
"'microtime'",
"]",
"-",
"$",
"debugSnapshot",
"[",
"'microtime'",
"]",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.time.precision'",
",",
"3",
")",
")",
".",
"' sec'",
";",
"$",
"value",
"=",
"str_pad",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.time.pad'",
",",
"10",
")",
",",
"' '",
",",
"STR_PAD_LEFT",
")",
";",
"break",
";",
"case",
"'mem'",
":",
"$",
"value",
"=",
"self",
"::",
"getReadableBytes",
"(",
"$",
"now",
"[",
"'memory_get_usage'",
"]",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.mem.precision'",
",",
"1",
")",
")",
";",
"$",
"value",
"=",
"str_pad",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.mem.pad'",
",",
"9",
")",
",",
"' '",
",",
"STR_PAD_LEFT",
")",
";",
"break",
";",
"case",
"'memdelta'",
":",
"$",
"value",
"=",
"$",
"now",
"[",
"'memory_get_usage'",
"]",
"-",
"$",
"debugSnapshot",
"[",
"'memory_get_usage'",
"]",
";",
"$",
"value",
"=",
"(",
"$",
"value",
">",
"0",
"?",
"'+'",
":",
"''",
")",
".",
"self",
"::",
"getReadableBytes",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.memdelta.precision'",
",",
"1",
")",
")",
";",
"$",
"value",
"=",
"str_pad",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.memdelta.pad'",
",",
"10",
")",
",",
"' '",
",",
"STR_PAD_LEFT",
")",
";",
"break",
";",
"case",
"'mempeak'",
":",
"$",
"value",
"=",
"self",
"::",
"getReadableBytes",
"(",
"$",
"now",
"[",
"'memory_get_peak_usage'",
"]",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.mempeak.precision'",
",",
"1",
")",
")",
";",
"$",
"value",
"=",
"str_pad",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.mempeak.pad'",
",",
"9",
")",
",",
"' '",
",",
"STR_PAD_LEFT",
")",
";",
"break",
";",
"case",
"'querycount'",
":",
"$",
"value",
"=",
"str_pad",
"(",
"$",
"this",
"->",
"getQueryCount",
"(",
")",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.querycount.pad'",
",",
"2",
")",
",",
"' '",
",",
"STR_PAD_LEFT",
")",
";",
"break",
";",
"case",
"'method'",
":",
"$",
"value",
"=",
"str_pad",
"(",
"$",
"methodName",
",",
"$",
"this",
"->",
"getLoggingConfig",
"(",
"'details.method.pad'",
",",
"28",
")",
",",
"' '",
",",
"STR_PAD_RIGHT",
")",
";",
"break",
";",
"case",
"'connection'",
":",
"$",
"value",
"=",
"$",
"this",
"->",
"connectionName",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"'n/a'",
";",
"break",
";",
"}",
"$",
"prefix",
".=",
"$",
"detailName",
".",
"$",
"innerGlue",
".",
"$",
"value",
".",
"$",
"outerGlue",
";",
"}",
"return",
"$",
"prefix",
";",
"}"
] | Returns a prefix that may be prepended to a log line, containing debug information according
to the current configuration.
Uses a given $debugSnapshot to calculate how much time has passed since the call to self::getDebugSnapshot(),
how much the memory consumption by PHP has changed etc.
@see self::getDebugSnapshot()
@param string $methodName Name of the method whose execution is being logged.
@param array $debugSnapshot A previous return value from self::getDebugSnapshot().
@return string | [
"Returns",
"a",
"prefix",
"that",
"may",
"be",
"prepended",
"to",
"a",
"log",
"line",
"containing",
"debug",
"information",
"according",
"to",
"the",
"current",
"configuration",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L705-L772 |
propelorm/Propel | runtime/lib/connection/PropelPDO.php | PropelPDO.getReadableBytes | protected function getReadableBytes($bytes, $precision)
{
$suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$total = count($suffix);
for ($i = 0; $bytes > 1024 && $i < $total; $i++) {
$bytes /= 1024;
}
return number_format($bytes, $precision) . ' ' . $suffix[$i];
} | php | protected function getReadableBytes($bytes, $precision)
{
$suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$total = count($suffix);
for ($i = 0; $bytes > 1024 && $i < $total; $i++) {
$bytes /= 1024;
}
return number_format($bytes, $precision) . ' ' . $suffix[$i];
} | [
"protected",
"function",
"getReadableBytes",
"(",
"$",
"bytes",
",",
"$",
"precision",
")",
"{",
"$",
"suffix",
"=",
"array",
"(",
"'B'",
",",
"'kB'",
",",
"'MB'",
",",
"'GB'",
",",
"'TB'",
",",
"'PB'",
",",
"'EB'",
",",
"'ZB'",
",",
"'YB'",
")",
";",
"$",
"total",
"=",
"count",
"(",
"$",
"suffix",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"bytes",
">",
"1024",
"&&",
"$",
"i",
"<",
"$",
"total",
";",
"$",
"i",
"++",
")",
"{",
"$",
"bytes",
"/=",
"1024",
";",
"}",
"return",
"number_format",
"(",
"$",
"bytes",
",",
"$",
"precision",
")",
".",
"' '",
".",
"$",
"suffix",
"[",
"$",
"i",
"]",
";",
"}"
] | Returns a human-readable representation of the given byte count.
@param integer $bytes Byte count to convert.
@param integer $precision How many decimals to include.
@return string | [
"Returns",
"a",
"human",
"-",
"readable",
"representation",
"of",
"the",
"given",
"byte",
"count",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/connection/PropelPDO.php#L782-L792 |
propelorm/Propel | generator/lib/task/PropelMigrationDownTask.php | PropelMigrationDownTask.main | public function main()
{
$manager = new PropelMigrationManager();
$manager->setConnections($this->getGeneratorConfig()->getBuildConnections());
$manager->setMigrationTable($this->getMigrationTable());
$manager->setMigrationDir($this->getOutputDirectory());
$previousTimestamps = $manager->getAlreadyExecutedMigrationTimestamps();
if (!$nextMigrationTimestamp = array_pop($previousTimestamps)) {
$this->log('No migration were ever executed on this database - nothing to reverse.');
return false;
}
$this->log(sprintf('Executing migration %s down', $manager->getMigrationClassName($nextMigrationTimestamp)));
if ($nbPreviousTimestamps = count($previousTimestamps)) {
$previousTimestamp = array_pop($previousTimestamps);
} else {
$previousTimestamp = 0;
}
$migration = $manager->getMigrationObject($nextMigrationTimestamp);
if (false === $migration->preDown($manager)) {
$this->log('preDown() returned false. Aborting migration.', Project::MSG_ERR);
return false;
}
foreach ($migration->getDownSQL() as $datasource => $sql) {
$connection = $manager->getConnection($datasource);
$this->log(sprintf(
'Connecting to database "%s" using DSN "%s"',
$datasource,
$connection['dsn']
), Project::MSG_VERBOSE);
$pdo = $manager->getPdoConnection($datasource);
$res = 0;
$statements = PropelSQLParser::parseString($sql);
foreach ($statements as $statement) {
try {
$this->log(sprintf('Executing statement "%s"', $statement), Project::MSG_VERBOSE);
$stmt = $pdo->prepare($statement);
$stmt->execute();
$res++;
} catch (PDOException $e) {
$this->log(sprintf('Failed to execute SQL "%s"', $statement), Project::MSG_ERR);
// continue
}
}
if (!$res) {
$this->log('No statement was executed. The version was not updated.');
$this->log(sprintf(
'Please review the code in "%s"',
$manager->getMigrationDir() . DIRECTORY_SEPARATOR . $manager->getMigrationClassName($nextMigrationTimestamp)
));
$this->log('Migration aborted', Project::MSG_ERR);
return false;
}
$this->log(sprintf(
'%d of %d SQL statements executed successfully on datasource "%s"',
$res,
count($statements),
$datasource
));
$manager->updateLatestMigrationTimestamp($datasource, $previousTimestamp);
$this->log(sprintf(
'Downgraded migration date to %d for datasource "%s"',
$previousTimestamp,
$datasource
), Project::MSG_VERBOSE);
}
$migration->postDown($manager);
if ($nbPreviousTimestamps) {
$this->log(sprintf('Reverse migration complete. %d more migrations available for reverse.', $nbPreviousTimestamps));
} else {
$this->log('Reverse migration complete. No more migration available for reverse');
}
} | php | public function main()
{
$manager = new PropelMigrationManager();
$manager->setConnections($this->getGeneratorConfig()->getBuildConnections());
$manager->setMigrationTable($this->getMigrationTable());
$manager->setMigrationDir($this->getOutputDirectory());
$previousTimestamps = $manager->getAlreadyExecutedMigrationTimestamps();
if (!$nextMigrationTimestamp = array_pop($previousTimestamps)) {
$this->log('No migration were ever executed on this database - nothing to reverse.');
return false;
}
$this->log(sprintf('Executing migration %s down', $manager->getMigrationClassName($nextMigrationTimestamp)));
if ($nbPreviousTimestamps = count($previousTimestamps)) {
$previousTimestamp = array_pop($previousTimestamps);
} else {
$previousTimestamp = 0;
}
$migration = $manager->getMigrationObject($nextMigrationTimestamp);
if (false === $migration->preDown($manager)) {
$this->log('preDown() returned false. Aborting migration.', Project::MSG_ERR);
return false;
}
foreach ($migration->getDownSQL() as $datasource => $sql) {
$connection = $manager->getConnection($datasource);
$this->log(sprintf(
'Connecting to database "%s" using DSN "%s"',
$datasource,
$connection['dsn']
), Project::MSG_VERBOSE);
$pdo = $manager->getPdoConnection($datasource);
$res = 0;
$statements = PropelSQLParser::parseString($sql);
foreach ($statements as $statement) {
try {
$this->log(sprintf('Executing statement "%s"', $statement), Project::MSG_VERBOSE);
$stmt = $pdo->prepare($statement);
$stmt->execute();
$res++;
} catch (PDOException $e) {
$this->log(sprintf('Failed to execute SQL "%s"', $statement), Project::MSG_ERR);
// continue
}
}
if (!$res) {
$this->log('No statement was executed. The version was not updated.');
$this->log(sprintf(
'Please review the code in "%s"',
$manager->getMigrationDir() . DIRECTORY_SEPARATOR . $manager->getMigrationClassName($nextMigrationTimestamp)
));
$this->log('Migration aborted', Project::MSG_ERR);
return false;
}
$this->log(sprintf(
'%d of %d SQL statements executed successfully on datasource "%s"',
$res,
count($statements),
$datasource
));
$manager->updateLatestMigrationTimestamp($datasource, $previousTimestamp);
$this->log(sprintf(
'Downgraded migration date to %d for datasource "%s"',
$previousTimestamp,
$datasource
), Project::MSG_VERBOSE);
}
$migration->postDown($manager);
if ($nbPreviousTimestamps) {
$this->log(sprintf('Reverse migration complete. %d more migrations available for reverse.', $nbPreviousTimestamps));
} else {
$this->log('Reverse migration complete. No more migration available for reverse');
}
} | [
"public",
"function",
"main",
"(",
")",
"{",
"$",
"manager",
"=",
"new",
"PropelMigrationManager",
"(",
")",
";",
"$",
"manager",
"->",
"setConnections",
"(",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getBuildConnections",
"(",
")",
")",
";",
"$",
"manager",
"->",
"setMigrationTable",
"(",
"$",
"this",
"->",
"getMigrationTable",
"(",
")",
")",
";",
"$",
"manager",
"->",
"setMigrationDir",
"(",
"$",
"this",
"->",
"getOutputDirectory",
"(",
")",
")",
";",
"$",
"previousTimestamps",
"=",
"$",
"manager",
"->",
"getAlreadyExecutedMigrationTimestamps",
"(",
")",
";",
"if",
"(",
"!",
"$",
"nextMigrationTimestamp",
"=",
"array_pop",
"(",
"$",
"previousTimestamps",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'No migration were ever executed on this database - nothing to reverse.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Executing migration %s down'",
",",
"$",
"manager",
"->",
"getMigrationClassName",
"(",
"$",
"nextMigrationTimestamp",
")",
")",
")",
";",
"if",
"(",
"$",
"nbPreviousTimestamps",
"=",
"count",
"(",
"$",
"previousTimestamps",
")",
")",
"{",
"$",
"previousTimestamp",
"=",
"array_pop",
"(",
"$",
"previousTimestamps",
")",
";",
"}",
"else",
"{",
"$",
"previousTimestamp",
"=",
"0",
";",
"}",
"$",
"migration",
"=",
"$",
"manager",
"->",
"getMigrationObject",
"(",
"$",
"nextMigrationTimestamp",
")",
";",
"if",
"(",
"false",
"===",
"$",
"migration",
"->",
"preDown",
"(",
"$",
"manager",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'preDown() returned false. Aborting migration.'",
",",
"Project",
"::",
"MSG_ERR",
")",
";",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"migration",
"->",
"getDownSQL",
"(",
")",
"as",
"$",
"datasource",
"=>",
"$",
"sql",
")",
"{",
"$",
"connection",
"=",
"$",
"manager",
"->",
"getConnection",
"(",
"$",
"datasource",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Connecting to database \"%s\" using DSN \"%s\"'",
",",
"$",
"datasource",
",",
"$",
"connection",
"[",
"'dsn'",
"]",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"pdo",
"=",
"$",
"manager",
"->",
"getPdoConnection",
"(",
"$",
"datasource",
")",
";",
"$",
"res",
"=",
"0",
";",
"$",
"statements",
"=",
"PropelSQLParser",
"::",
"parseString",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"statements",
"as",
"$",
"statement",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Executing statement \"%s\"'",
",",
"$",
"statement",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"$",
"stmt",
"=",
"$",
"pdo",
"->",
"prepare",
"(",
"$",
"statement",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"$",
"res",
"++",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Failed to execute SQL \"%s\"'",
",",
"$",
"statement",
")",
",",
"Project",
"::",
"MSG_ERR",
")",
";",
"// continue",
"}",
"}",
"if",
"(",
"!",
"$",
"res",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'No statement was executed. The version was not updated.'",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Please review the code in \"%s\"'",
",",
"$",
"manager",
"->",
"getMigrationDir",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"manager",
"->",
"getMigrationClassName",
"(",
"$",
"nextMigrationTimestamp",
")",
")",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Migration aborted'",
",",
"Project",
"::",
"MSG_ERR",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'%d of %d SQL statements executed successfully on datasource \"%s\"'",
",",
"$",
"res",
",",
"count",
"(",
"$",
"statements",
")",
",",
"$",
"datasource",
")",
")",
";",
"$",
"manager",
"->",
"updateLatestMigrationTimestamp",
"(",
"$",
"datasource",
",",
"$",
"previousTimestamp",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Downgraded migration date to %d for datasource \"%s\"'",
",",
"$",
"previousTimestamp",
",",
"$",
"datasource",
")",
",",
"Project",
"::",
"MSG_VERBOSE",
")",
";",
"}",
"$",
"migration",
"->",
"postDown",
"(",
"$",
"manager",
")",
";",
"if",
"(",
"$",
"nbPreviousTimestamps",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Reverse migration complete. %d more migrations available for reverse.'",
",",
"$",
"nbPreviousTimestamps",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"'Reverse migration complete. No more migration available for reverse'",
")",
";",
"}",
"}"
] | 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/PropelMigrationDownTask.php#L26-L107 |
propelorm/Propel | generator/lib/builder/util/XmlToAppData.php | XmlToAppData.startElement | public function startElement($parser, $name, $attributes)
{
$parentTag = $this->peekCurrentSchemaTag();
if ($parentTag === false) {
switch ($name) {
case "database":
if ($this->isExternalSchema()) {
$this->currentPackage = @$attributes["package"];
if ($this->currentPackage === null) {
$this->currentPackage = $this->defaultPackage;
}
} else {
$this->currDB = $this->app->addDatabase($attributes);
}
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "database") {
switch ($name) {
case "external-schema":
$xmlFile = @$attributes["filename"];
// "referenceOnly" attribute is valid in the main schema XML file only,
// and it's ignored in the nested external-schemas
if (!$this->isExternalSchema()) {
$isForRefOnly = @$attributes["referenceOnly"];
$this->isForReferenceOnly = ($isForRefOnly !== null ? (strtolower($isForRefOnly) === "true") : true); // defaults to TRUE
}
if (!$this->isAbsolutePath($xmlFile)) {
$xmlFile = realpath(dirname($this->currentXmlFile) . DIRECTORY_SEPARATOR . $xmlFile);
if (!file_exists($xmlFile)) {
throw new SchemaException(sprintf('Unknown include external "%s"', $xmlFile));
}
}
$this->parseFile($xmlFile);
break;
case "domain":
$this->currDB->addDomain($attributes);
break;
case "table":
$this->currTable = $this->currDB->addTable($attributes);
if ($this->isExternalSchema()) {
$this->currTable->setForReferenceOnly($this->isForReferenceOnly);
$this->currTable->setPackage($this->currentPackage);
}
break;
case "vendor":
$this->currVendorObject = $this->currDB->addVendorInfo($attributes);
break;
case "behavior":
$this->currBehavior = $this->currDB->addBehavior($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "table") {
switch ($name) {
case "column":
$this->currColumn = $this->currTable->addColumn($attributes);
break;
case "foreign-key":
$this->currFK = $this->currTable->addForeignKey($attributes);
break;
case "index":
$this->currIndex = $this->currTable->addIndex($attributes);
break;
case "unique":
$this->currUnique = $this->currTable->addUnique($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currTable->addVendorInfo($attributes);
break;
case "validator":
$this->currValidator = $this->currTable->addValidator($attributes);
break;
case "id-method-parameter":
$this->currTable->addIdMethodParameter($attributes);
break;
case "behavior":
$this->currBehavior = $this->currTable->addBehavior($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "column") {
switch ($name) {
case "inheritance":
$this->currColumn->addInheritance($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currColumn->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "foreign-key") {
switch ($name) {
case "reference":
$this->currFK->addReference($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currUnique->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "index") {
switch ($name) {
case "index-column":
$this->currIndex->addColumn($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currIndex->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "unique") {
switch ($name) {
case "unique-column":
$this->currUnique->addColumn($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currUnique->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "behavior") {
switch ($name) {
case "parameter":
$this->currBehavior->addParameter($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "validator") {
switch ($name) {
case "rule":
$this->currValidator->addRule($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "vendor") {
switch ($name) {
case "parameter":
$this->currVendorObject->addParameter($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} else {
// it must be an invalid tag
$this->_throwInvalidTagException($parser, $name);
}
$this->pushCurrentSchemaTag($name);
} | php | public function startElement($parser, $name, $attributes)
{
$parentTag = $this->peekCurrentSchemaTag();
if ($parentTag === false) {
switch ($name) {
case "database":
if ($this->isExternalSchema()) {
$this->currentPackage = @$attributes["package"];
if ($this->currentPackage === null) {
$this->currentPackage = $this->defaultPackage;
}
} else {
$this->currDB = $this->app->addDatabase($attributes);
}
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "database") {
switch ($name) {
case "external-schema":
$xmlFile = @$attributes["filename"];
// "referenceOnly" attribute is valid in the main schema XML file only,
// and it's ignored in the nested external-schemas
if (!$this->isExternalSchema()) {
$isForRefOnly = @$attributes["referenceOnly"];
$this->isForReferenceOnly = ($isForRefOnly !== null ? (strtolower($isForRefOnly) === "true") : true); // defaults to TRUE
}
if (!$this->isAbsolutePath($xmlFile)) {
$xmlFile = realpath(dirname($this->currentXmlFile) . DIRECTORY_SEPARATOR . $xmlFile);
if (!file_exists($xmlFile)) {
throw new SchemaException(sprintf('Unknown include external "%s"', $xmlFile));
}
}
$this->parseFile($xmlFile);
break;
case "domain":
$this->currDB->addDomain($attributes);
break;
case "table":
$this->currTable = $this->currDB->addTable($attributes);
if ($this->isExternalSchema()) {
$this->currTable->setForReferenceOnly($this->isForReferenceOnly);
$this->currTable->setPackage($this->currentPackage);
}
break;
case "vendor":
$this->currVendorObject = $this->currDB->addVendorInfo($attributes);
break;
case "behavior":
$this->currBehavior = $this->currDB->addBehavior($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "table") {
switch ($name) {
case "column":
$this->currColumn = $this->currTable->addColumn($attributes);
break;
case "foreign-key":
$this->currFK = $this->currTable->addForeignKey($attributes);
break;
case "index":
$this->currIndex = $this->currTable->addIndex($attributes);
break;
case "unique":
$this->currUnique = $this->currTable->addUnique($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currTable->addVendorInfo($attributes);
break;
case "validator":
$this->currValidator = $this->currTable->addValidator($attributes);
break;
case "id-method-parameter":
$this->currTable->addIdMethodParameter($attributes);
break;
case "behavior":
$this->currBehavior = $this->currTable->addBehavior($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "column") {
switch ($name) {
case "inheritance":
$this->currColumn->addInheritance($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currColumn->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "foreign-key") {
switch ($name) {
case "reference":
$this->currFK->addReference($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currUnique->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "index") {
switch ($name) {
case "index-column":
$this->currIndex->addColumn($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currIndex->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "unique") {
switch ($name) {
case "unique-column":
$this->currUnique->addColumn($attributes);
break;
case "vendor":
$this->currVendorObject = $this->currUnique->addVendorInfo($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "behavior") {
switch ($name) {
case "parameter":
$this->currBehavior->addParameter($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "validator") {
switch ($name) {
case "rule":
$this->currValidator->addRule($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} elseif ($parentTag == "vendor") {
switch ($name) {
case "parameter":
$this->currVendorObject->addParameter($attributes);
break;
default:
$this->_throwInvalidTagException($parser, $name);
}
} else {
// it must be an invalid tag
$this->_throwInvalidTagException($parser, $name);
}
$this->pushCurrentSchemaTag($name);
} | [
"public",
"function",
"startElement",
"(",
"$",
"parser",
",",
"$",
"name",
",",
"$",
"attributes",
")",
"{",
"$",
"parentTag",
"=",
"$",
"this",
"->",
"peekCurrentSchemaTag",
"(",
")",
";",
"if",
"(",
"$",
"parentTag",
"===",
"false",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"database\"",
":",
"if",
"(",
"$",
"this",
"->",
"isExternalSchema",
"(",
")",
")",
"{",
"$",
"this",
"->",
"currentPackage",
"=",
"@",
"$",
"attributes",
"[",
"\"package\"",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"currentPackage",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"currentPackage",
"=",
"$",
"this",
"->",
"defaultPackage",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"currDB",
"=",
"$",
"this",
"->",
"app",
"->",
"addDatabase",
"(",
"$",
"attributes",
")",
";",
"}",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"database\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"external-schema\"",
":",
"$",
"xmlFile",
"=",
"@",
"$",
"attributes",
"[",
"\"filename\"",
"]",
";",
"// \"referenceOnly\" attribute is valid in the main schema XML file only,",
"// and it's ignored in the nested external-schemas",
"if",
"(",
"!",
"$",
"this",
"->",
"isExternalSchema",
"(",
")",
")",
"{",
"$",
"isForRefOnly",
"=",
"@",
"$",
"attributes",
"[",
"\"referenceOnly\"",
"]",
";",
"$",
"this",
"->",
"isForReferenceOnly",
"=",
"(",
"$",
"isForRefOnly",
"!==",
"null",
"?",
"(",
"strtolower",
"(",
"$",
"isForRefOnly",
")",
"===",
"\"true\"",
")",
":",
"true",
")",
";",
"// defaults to TRUE",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isAbsolutePath",
"(",
"$",
"xmlFile",
")",
")",
"{",
"$",
"xmlFile",
"=",
"realpath",
"(",
"dirname",
"(",
"$",
"this",
"->",
"currentXmlFile",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"xmlFile",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"xmlFile",
")",
")",
"{",
"throw",
"new",
"SchemaException",
"(",
"sprintf",
"(",
"'Unknown include external \"%s\"'",
",",
"$",
"xmlFile",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"parseFile",
"(",
"$",
"xmlFile",
")",
";",
"break",
";",
"case",
"\"domain\"",
":",
"$",
"this",
"->",
"currDB",
"->",
"addDomain",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"table\"",
":",
"$",
"this",
"->",
"currTable",
"=",
"$",
"this",
"->",
"currDB",
"->",
"addTable",
"(",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isExternalSchema",
"(",
")",
")",
"{",
"$",
"this",
"->",
"currTable",
"->",
"setForReferenceOnly",
"(",
"$",
"this",
"->",
"isForReferenceOnly",
")",
";",
"$",
"this",
"->",
"currTable",
"->",
"setPackage",
"(",
"$",
"this",
"->",
"currentPackage",
")",
";",
"}",
"break",
";",
"case",
"\"vendor\"",
":",
"$",
"this",
"->",
"currVendorObject",
"=",
"$",
"this",
"->",
"currDB",
"->",
"addVendorInfo",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"behavior\"",
":",
"$",
"this",
"->",
"currBehavior",
"=",
"$",
"this",
"->",
"currDB",
"->",
"addBehavior",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"table\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"column\"",
":",
"$",
"this",
"->",
"currColumn",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addColumn",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"foreign-key\"",
":",
"$",
"this",
"->",
"currFK",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addForeignKey",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"index\"",
":",
"$",
"this",
"->",
"currIndex",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addIndex",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"unique\"",
":",
"$",
"this",
"->",
"currUnique",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addUnique",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"vendor\"",
":",
"$",
"this",
"->",
"currVendorObject",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addVendorInfo",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"validator\"",
":",
"$",
"this",
"->",
"currValidator",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addValidator",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"id-method-parameter\"",
":",
"$",
"this",
"->",
"currTable",
"->",
"addIdMethodParameter",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"behavior\"",
":",
"$",
"this",
"->",
"currBehavior",
"=",
"$",
"this",
"->",
"currTable",
"->",
"addBehavior",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"column\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"inheritance\"",
":",
"$",
"this",
"->",
"currColumn",
"->",
"addInheritance",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"vendor\"",
":",
"$",
"this",
"->",
"currVendorObject",
"=",
"$",
"this",
"->",
"currColumn",
"->",
"addVendorInfo",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"foreign-key\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"reference\"",
":",
"$",
"this",
"->",
"currFK",
"->",
"addReference",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"vendor\"",
":",
"$",
"this",
"->",
"currVendorObject",
"=",
"$",
"this",
"->",
"currUnique",
"->",
"addVendorInfo",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"index\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"index-column\"",
":",
"$",
"this",
"->",
"currIndex",
"->",
"addColumn",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"vendor\"",
":",
"$",
"this",
"->",
"currVendorObject",
"=",
"$",
"this",
"->",
"currIndex",
"->",
"addVendorInfo",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"unique\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"unique-column\"",
":",
"$",
"this",
"->",
"currUnique",
"->",
"addColumn",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"case",
"\"vendor\"",
":",
"$",
"this",
"->",
"currVendorObject",
"=",
"$",
"this",
"->",
"currUnique",
"->",
"addVendorInfo",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"behavior\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"parameter\"",
":",
"$",
"this",
"->",
"currBehavior",
"->",
"addParameter",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"validator\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"rule\"",
":",
"$",
"this",
"->",
"currValidator",
"->",
"addRule",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"parentTag",
"==",
"\"vendor\"",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"\"parameter\"",
":",
"$",
"this",
"->",
"currVendorObject",
"->",
"addParameter",
"(",
"$",
"attributes",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"}",
"else",
"{",
"// it must be an invalid tag",
"$",
"this",
"->",
"_throwInvalidTagException",
"(",
"$",
"parser",
",",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"pushCurrentSchemaTag",
"(",
"$",
"name",
")",
";",
"}"
] | Handles opening elements of the xml file.
@param string $uri
@param string $localName The local name (without prefix), or the empty string if
Namespace processing is not being performed.
@param string $rawName The qualified name (with prefix), or the empty string if
qualified names are not available.
@param string $attributes The specified or defaulted attributes
@throws SchemaException | [
"Handles",
"opening",
"elements",
"of",
"the",
"xml",
"file",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/util/XmlToAppData.php#L150-L345 |
propelorm/Propel | runtime/lib/config/PropelConfiguration.php | PropelConfiguration.offsetSet | public function offsetSet($offset, $value)
{
$this->parameters[$offset] = $value;
$this->isFlattened = false;
} | php | public function offsetSet($offset, $value)
{
$this->parameters[$offset] = $value;
$this->isFlattened = false;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"parameters",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"isFlattened",
"=",
"false",
";",
"}"
] | @see http://www.php.net/ArrayAccess
@param integer $offset
@param mixed $value | [
"@see",
"http",
":",
"//",
"www",
".",
"php",
".",
"net",
"/",
"ArrayAccess"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/config/PropelConfiguration.php#L61-L65 |
propelorm/Propel | runtime/lib/config/PropelConfiguration.php | PropelConfiguration.getParameter | public function getParameter($name, $default = null)
{
$flattenedParameters = $this->getFlattenedParameters();
if (isset($flattenedParameters[$name])) {
return $flattenedParameters[$name];
}
return $default;
} | php | public function getParameter($name, $default = null)
{
$flattenedParameters = $this->getFlattenedParameters();
if (isset($flattenedParameters[$name])) {
return $flattenedParameters[$name];
}
return $default;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"flattenedParameters",
"=",
"$",
"this",
"->",
"getFlattenedParameters",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"flattenedParameters",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"flattenedParameters",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Get a value from the container, using a namespaced key.
If the specified value is supposed to be an array, the actual return value will be null.
Examples:
<code>
$c['foo'] = 'bar';
echo $c->getParameter('foo'); => 'bar'
$c['foo1'] = array('foo2' => 'bar');
echo $c->getParameter('foo1'); => null
echo $c->getParameter('foo1.foo2'); => 'bar'
</code>
@param string $name Parameter name
@param mixed $default Default value to be used if the requested value is not found
@return mixed Parameter value or the default | [
"Get",
"a",
"value",
"from",
"the",
"container",
"using",
"a",
"namespaced",
"key",
".",
"If",
"the",
"specified",
"value",
"is",
"supposed",
"to",
"be",
"an",
"array",
"the",
"actual",
"return",
"value",
"will",
"be",
"null",
".",
"Examples",
":",
"<code",
">",
"$c",
"[",
"foo",
"]",
"=",
"bar",
";",
"echo",
"$c",
"-",
">",
"getParameter",
"(",
"foo",
")",
";",
"=",
">",
"bar",
"$c",
"[",
"foo1",
"]",
"=",
"array",
"(",
"foo2",
"=",
">",
"bar",
")",
";",
"echo",
"$c",
"-",
">",
"getParameter",
"(",
"foo1",
")",
";",
"=",
">",
"null",
"echo",
"$c",
"-",
">",
"getParameter",
"(",
"foo1",
".",
"foo2",
")",
";",
"=",
">",
"bar",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/config/PropelConfiguration.php#L107-L115 |
propelorm/Propel | runtime/lib/config/PropelConfiguration.php | PropelConfiguration.setParameter | public function setParameter($name, $value, $autoFlattenArrays = true)
{
$param = &$this->parameters;
$parts = explode('.', $name); //name.space.name
foreach ($parts as $part) {
$param = &$param[$part];
}
$param = $value;
if (is_array($value) && $autoFlattenArrays) {
// The list will need to be re-flattened.
$this->isFlattened = false;
} else {
$this->flattenedParameters[$name] = $value;
}
} | php | public function setParameter($name, $value, $autoFlattenArrays = true)
{
$param = &$this->parameters;
$parts = explode('.', $name); //name.space.name
foreach ($parts as $part) {
$param = &$param[$part];
}
$param = $value;
if (is_array($value) && $autoFlattenArrays) {
// The list will need to be re-flattened.
$this->isFlattened = false;
} else {
$this->flattenedParameters[$name] = $value;
}
} | [
"public",
"function",
"setParameter",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"autoFlattenArrays",
"=",
"true",
")",
"{",
"$",
"param",
"=",
"&",
"$",
"this",
"->",
"parameters",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
")",
";",
"//name.space.name",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"$",
"param",
"=",
"&",
"$",
"param",
"[",
"$",
"part",
"]",
";",
"}",
"$",
"param",
"=",
"$",
"value",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"$",
"autoFlattenArrays",
")",
"{",
"// The list will need to be re-flattened.",
"$",
"this",
"->",
"isFlattened",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"flattenedParameters",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Store a value to the container. Accept scalar and array values.
Examples:
<code>
$c->setParameter('foo', 'bar');
echo $c['foo']; => 'bar'
$c->setParameter('foo1.foo2', 'bar');
print_r($c['foo1']); => array('foo2' => 'bar')
</code>
@param string $name Configuration item name (name.space.name)
@param mixed $value Value to be stored
@param Boolean $autoFlattenArrays | [
"Store",
"a",
"value",
"to",
"the",
"container",
".",
"Accept",
"scalar",
"and",
"array",
"values",
".",
"Examples",
":",
"<code",
">",
"$c",
"-",
">",
"setParameter",
"(",
"foo",
"bar",
")",
";",
"echo",
"$c",
"[",
"foo",
"]",
";",
"=",
">",
"bar",
"$c",
"-",
">",
"setParameter",
"(",
"foo1",
".",
"foo2",
"bar",
")",
";",
"print_r",
"(",
"$c",
"[",
"foo1",
"]",
")",
";",
"=",
">",
"array",
"(",
"foo2",
"=",
">",
"bar",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/config/PropelConfiguration.php#L131-L145 |
propelorm/Propel | runtime/lib/config/PropelConfiguration.php | PropelConfiguration.getParameters | public function getParameters($type = PropelConfiguration::TYPE_ARRAY)
{
switch ($type) {
case PropelConfiguration::TYPE_ARRAY:
return $this->parameters;
case PropelConfiguration::TYPE_ARRAY_FLAT:
return $this->getFlattenedParameters();
case PropelConfiguration::TYPE_OBJECT:
return $this;
default:
throw new PropelException('Unknown configuration type: ' . var_export($type, true));
}
} | php | public function getParameters($type = PropelConfiguration::TYPE_ARRAY)
{
switch ($type) {
case PropelConfiguration::TYPE_ARRAY:
return $this->parameters;
case PropelConfiguration::TYPE_ARRAY_FLAT:
return $this->getFlattenedParameters();
case PropelConfiguration::TYPE_OBJECT:
return $this;
default:
throw new PropelException('Unknown configuration type: ' . var_export($type, true));
}
} | [
"public",
"function",
"getParameters",
"(",
"$",
"type",
"=",
"PropelConfiguration",
"::",
"TYPE_ARRAY",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"PropelConfiguration",
"::",
"TYPE_ARRAY",
":",
"return",
"$",
"this",
"->",
"parameters",
";",
"case",
"PropelConfiguration",
"::",
"TYPE_ARRAY_FLAT",
":",
"return",
"$",
"this",
"->",
"getFlattenedParameters",
"(",
")",
";",
"case",
"PropelConfiguration",
"::",
"TYPE_OBJECT",
":",
"return",
"$",
"this",
";",
"default",
":",
"throw",
"new",
"PropelException",
"(",
"'Unknown configuration type: '",
".",
"var_export",
"(",
"$",
"type",
",",
"true",
")",
")",
";",
"}",
"}"
] | @throws PropelException
@param integer $type
@return mixed | [
"@throws",
"PropelException"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/config/PropelConfiguration.php#L154-L166 |
propelorm/Propel | generator/lib/task/PropelSchemaReverseTask.php | PropelSchemaReverseTask.setAddValidators | public function setAddValidators($v)
{
$validKeys = array_keys(self::$validatorBitMap);
// lowercase input
$v = strtolower($v);
$bits = self::VALIDATORS_NONE;
$exprs = explode(',', $v);
foreach ($exprs as $expr) {
$expr = trim($expr);
if (!empty($expr)) {
if (!isset(self::$validatorBitMap[$expr])) {
throw new BuildException("Unable to interpret validator in expression ('$v'): " . $expr);
}
$bits |= self::$validatorBitMap[$expr];
}
}
$this->validatorBits = $bits;
} | php | public function setAddValidators($v)
{
$validKeys = array_keys(self::$validatorBitMap);
// lowercase input
$v = strtolower($v);
$bits = self::VALIDATORS_NONE;
$exprs = explode(',', $v);
foreach ($exprs as $expr) {
$expr = trim($expr);
if (!empty($expr)) {
if (!isset(self::$validatorBitMap[$expr])) {
throw new BuildException("Unable to interpret validator in expression ('$v'): " . $expr);
}
$bits |= self::$validatorBitMap[$expr];
}
}
$this->validatorBits = $bits;
} | [
"public",
"function",
"setAddValidators",
"(",
"$",
"v",
")",
"{",
"$",
"validKeys",
"=",
"array_keys",
"(",
"self",
"::",
"$",
"validatorBitMap",
")",
";",
"// lowercase input",
"$",
"v",
"=",
"strtolower",
"(",
"$",
"v",
")",
";",
"$",
"bits",
"=",
"self",
"::",
"VALIDATORS_NONE",
";",
"$",
"exprs",
"=",
"explode",
"(",
"','",
",",
"$",
"v",
")",
";",
"foreach",
"(",
"$",
"exprs",
"as",
"$",
"expr",
")",
"{",
"$",
"expr",
"=",
"trim",
"(",
"$",
"expr",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"expr",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"validatorBitMap",
"[",
"$",
"expr",
"]",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Unable to interpret validator in expression ('$v'): \"",
".",
"$",
"expr",
")",
";",
"}",
"$",
"bits",
"|=",
"self",
"::",
"$",
"validatorBitMap",
"[",
"$",
"expr",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"validatorBits",
"=",
"$",
"bits",
";",
"}"
] | Sets set validator bitfield from a comma-separated list of "validator bit" names.
@param string $v The comma-separated list of which validators to add.
@return void
@throws BuildException | [
"Sets",
"set",
"validator",
"bitfield",
"from",
"a",
"comma",
"-",
"separated",
"list",
"of",
"validator",
"bit",
"names",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSchemaReverseTask.php#L291-L312 |
propelorm/Propel | generator/lib/task/PropelSchemaReverseTask.php | PropelSchemaReverseTask.buildModel | protected function buildModel()
{
$config = $this->getGeneratorConfig();
$con = $this->getConnection();
$this->log('Reading database structure...');
$database = new Database($this->getDatabaseName());
$database->setPlatform($config->getConfiguredPlatform($con));
$database->setDefaultIdMethod(IDMethod::NATIVE);
$parser = $config->getConfiguredSchemaParser($con);
$nbTables = $parser->parse($database, $this);
$this->log(sprintf('Successfully reverse engineered %d tables', $nbTables));
return $database;
} | php | protected function buildModel()
{
$config = $this->getGeneratorConfig();
$con = $this->getConnection();
$this->log('Reading database structure...');
$database = new Database($this->getDatabaseName());
$database->setPlatform($config->getConfiguredPlatform($con));
$database->setDefaultIdMethod(IDMethod::NATIVE);
$parser = $config->getConfiguredSchemaParser($con);
$nbTables = $parser->parse($database, $this);
$this->log(sprintf('Successfully reverse engineered %d tables', $nbTables));
return $database;
} | [
"protected",
"function",
"buildModel",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
";",
"$",
"con",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Reading database structure...'",
")",
";",
"$",
"database",
"=",
"new",
"Database",
"(",
"$",
"this",
"->",
"getDatabaseName",
"(",
")",
")",
";",
"$",
"database",
"->",
"setPlatform",
"(",
"$",
"config",
"->",
"getConfiguredPlatform",
"(",
"$",
"con",
")",
")",
";",
"$",
"database",
"->",
"setDefaultIdMethod",
"(",
"IDMethod",
"::",
"NATIVE",
")",
";",
"$",
"parser",
"=",
"$",
"config",
"->",
"getConfiguredSchemaParser",
"(",
"$",
"con",
")",
";",
"$",
"nbTables",
"=",
"$",
"parser",
"->",
"parse",
"(",
"$",
"database",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Successfully reverse engineered %d tables'",
",",
"$",
"nbTables",
")",
")",
";",
"return",
"$",
"database",
";",
"}"
] | Builds the model classes from the database schema.
@return Database The built-out Database (with all tables, etc.) | [
"Builds",
"the",
"model",
"classes",
"from",
"the",
"database",
"schema",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSchemaReverseTask.php#L398-L414 |
propelorm/Propel | generator/lib/task/PropelSchemaReverseTask.php | PropelSchemaReverseTask.addValidators | protected function addValidators(Database $database)
{
$platform = $this->getGeneratorConfig()->getConfiguredPlatform();
foreach ($database->getTables() as $table) {
$set = new PropelSchemaReverse_ValidatorSet();
foreach ($table->getColumns() as $col) {
if ($col->isNotNull() && $this->isValidatorRequired(self::VALIDATORS_REQUIRED)) {
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'required'));
}
if (in_array($col->getType(), array(PropelTypes::CHAR, PropelTypes::VARCHAR, PropelTypes::LONGVARCHAR)) && $col->getSize() && $this->isValidatorRequired(self::VALIDATORS_MAXLENGTH)) {
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'maxLength', $col->getSize()));
}
if ($col->isNumericType() && $this->isValidatorRequired(self::VALIDATORS_MAXVALUE)) {
$this->log("WARNING: maxValue validator added for column " . $col->getName() . ". You will have to adjust the size value manually.", Project::MSG_WARN);
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'maxValue', 'REPLACEME'));
}
if ($col->isPhpPrimitiveType() && $this->isValidatorRequired(self::VALIDATORS_TYPE)) {
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'type', $col->getPhpType()));
}
}
foreach ($table->getUnices() as $unique) {
$colnames = $unique->getColumns();
if (count($colnames) == 1) { // currently 'unique' validator only works w/ single columns.
$col = $table->getColumn($colnames[0]);
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'unique'));
}
}
foreach ($set->getValidators() as $validator) {
$table->addValidator($validator);
}
} // foreach table
} | php | protected function addValidators(Database $database)
{
$platform = $this->getGeneratorConfig()->getConfiguredPlatform();
foreach ($database->getTables() as $table) {
$set = new PropelSchemaReverse_ValidatorSet();
foreach ($table->getColumns() as $col) {
if ($col->isNotNull() && $this->isValidatorRequired(self::VALIDATORS_REQUIRED)) {
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'required'));
}
if (in_array($col->getType(), array(PropelTypes::CHAR, PropelTypes::VARCHAR, PropelTypes::LONGVARCHAR)) && $col->getSize() && $this->isValidatorRequired(self::VALIDATORS_MAXLENGTH)) {
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'maxLength', $col->getSize()));
}
if ($col->isNumericType() && $this->isValidatorRequired(self::VALIDATORS_MAXVALUE)) {
$this->log("WARNING: maxValue validator added for column " . $col->getName() . ". You will have to adjust the size value manually.", Project::MSG_WARN);
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'maxValue', 'REPLACEME'));
}
if ($col->isPhpPrimitiveType() && $this->isValidatorRequired(self::VALIDATORS_TYPE)) {
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'type', $col->getPhpType()));
}
}
foreach ($table->getUnices() as $unique) {
$colnames = $unique->getColumns();
if (count($colnames) == 1) { // currently 'unique' validator only works w/ single columns.
$col = $table->getColumn($colnames[0]);
$validator = $set->getValidator($col);
$validator->addRule($this->getValidatorRule($col, 'unique'));
}
}
foreach ($set->getValidators() as $validator) {
$table->addValidator($validator);
}
} // foreach table
} | [
"protected",
"function",
"addValidators",
"(",
"Database",
"$",
"database",
")",
"{",
"$",
"platform",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredPlatform",
"(",
")",
";",
"foreach",
"(",
"$",
"database",
"->",
"getTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"$",
"set",
"=",
"new",
"PropelSchemaReverse_ValidatorSet",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
"&&",
"$",
"this",
"->",
"isValidatorRequired",
"(",
"self",
"::",
"VALIDATORS_REQUIRED",
")",
")",
"{",
"$",
"validator",
"=",
"$",
"set",
"->",
"getValidator",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"addRule",
"(",
"$",
"this",
"->",
"getValidatorRule",
"(",
"$",
"col",
",",
"'required'",
")",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"col",
"->",
"getType",
"(",
")",
",",
"array",
"(",
"PropelTypes",
"::",
"CHAR",
",",
"PropelTypes",
"::",
"VARCHAR",
",",
"PropelTypes",
"::",
"LONGVARCHAR",
")",
")",
"&&",
"$",
"col",
"->",
"getSize",
"(",
")",
"&&",
"$",
"this",
"->",
"isValidatorRequired",
"(",
"self",
"::",
"VALIDATORS_MAXLENGTH",
")",
")",
"{",
"$",
"validator",
"=",
"$",
"set",
"->",
"getValidator",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"addRule",
"(",
"$",
"this",
"->",
"getValidatorRule",
"(",
"$",
"col",
",",
"'maxLength'",
",",
"$",
"col",
"->",
"getSize",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"col",
"->",
"isNumericType",
"(",
")",
"&&",
"$",
"this",
"->",
"isValidatorRequired",
"(",
"self",
"::",
"VALIDATORS_MAXVALUE",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"WARNING: maxValue validator added for column \"",
".",
"$",
"col",
"->",
"getName",
"(",
")",
".",
"\". You will have to adjust the size value manually.\"",
",",
"Project",
"::",
"MSG_WARN",
")",
";",
"$",
"validator",
"=",
"$",
"set",
"->",
"getValidator",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"addRule",
"(",
"$",
"this",
"->",
"getValidatorRule",
"(",
"$",
"col",
",",
"'maxValue'",
",",
"'REPLACEME'",
")",
")",
";",
"}",
"if",
"(",
"$",
"col",
"->",
"isPhpPrimitiveType",
"(",
")",
"&&",
"$",
"this",
"->",
"isValidatorRequired",
"(",
"self",
"::",
"VALIDATORS_TYPE",
")",
")",
"{",
"$",
"validator",
"=",
"$",
"set",
"->",
"getValidator",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"addRule",
"(",
"$",
"this",
"->",
"getValidatorRule",
"(",
"$",
"col",
",",
"'type'",
",",
"$",
"col",
"->",
"getPhpType",
"(",
")",
")",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"table",
"->",
"getUnices",
"(",
")",
"as",
"$",
"unique",
")",
"{",
"$",
"colnames",
"=",
"$",
"unique",
"->",
"getColumns",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"colnames",
")",
"==",
"1",
")",
"{",
"// currently 'unique' validator only works w/ single columns.",
"$",
"col",
"=",
"$",
"table",
"->",
"getColumn",
"(",
"$",
"colnames",
"[",
"0",
"]",
")",
";",
"$",
"validator",
"=",
"$",
"set",
"->",
"getValidator",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"addRule",
"(",
"$",
"this",
"->",
"getValidatorRule",
"(",
"$",
"col",
",",
"'unique'",
")",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"set",
"->",
"getValidators",
"(",
")",
"as",
"$",
"validator",
")",
"{",
"$",
"table",
"->",
"addValidator",
"(",
"$",
"validator",
")",
";",
"}",
"}",
"// foreach table",
"}"
] | Adds any requested validators to the data model.
We will add the following type specific validators:
for notNull columns: required validator
for unique indexes: unique validator
for varchar types: maxLength validators (CHAR, VARCHAR, LONGVARCHAR)
for numeric types: maxValue validators (BIGINT, SMALLINT, TINYINT, INTEGER, FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL)
for integer and timestamp types: notMatch validator with [^\d]+ (BIGINT, SMALLINT, TINYINT, INTEGER, TIMESTAMP)
for float types: notMatch validator with [^\d\.]+ (FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL)
@param Database $database The Database model.
@return void
@todo find out how to evaluate the appropriate size and adjust maxValue rule values appropriate
@todo find out if float type column values must always notMatch('[^\d\.]+'), i.e. digits and point for any db vendor, language etc. | [
"Adds",
"any",
"requested",
"validators",
"to",
"the",
"data",
"model",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSchemaReverseTask.php#L434-L481 |
propelorm/Propel | generator/lib/task/PropelSchemaReverseTask.php | PropelSchemaReverseTask.getValidatorRule | protected function getValidatorRule(Column $column, $type, $value = null)
{
$rule = new Rule();
$rule->setName($type);
if ($value !== null) {
$rule->setValue($value);
}
$rule->setMessage($this->getRuleMessage($column, $type, $value));
return $rule;
} | php | protected function getValidatorRule(Column $column, $type, $value = null)
{
$rule = new Rule();
$rule->setName($type);
if ($value !== null) {
$rule->setValue($value);
}
$rule->setMessage($this->getRuleMessage($column, $type, $value));
return $rule;
} | [
"protected",
"function",
"getValidatorRule",
"(",
"Column",
"$",
"column",
",",
"$",
"type",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"rule",
"=",
"new",
"Rule",
"(",
")",
";",
"$",
"rule",
"->",
"setName",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"rule",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"rule",
"->",
"setMessage",
"(",
"$",
"this",
"->",
"getRuleMessage",
"(",
"$",
"column",
",",
"$",
"type",
",",
"$",
"value",
")",
")",
";",
"return",
"$",
"rule",
";",
"}"
] | Gets validator rule for specified type (string) .
@param Column $column The column that is being validated.
@param string $type The type (string) for validator (e.g. 'required').
@param mixed $value The value for the validator (if applicable)
@return Rule | [
"Gets",
"validator",
"rule",
"for",
"specified",
"type",
"(",
"string",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSchemaReverseTask.php#L492-L502 |
propelorm/Propel | generator/lib/task/PropelSchemaReverseTask.php | PropelSchemaReverseTask.getRuleMessage | protected function getRuleMessage(Column $column, $type, $value)
{
// create message
$colName = $column->getName();
$tableName = $column->getTable()->getName();
$msg = self::$validatorMessages[strtolower($type)];
$tmp = compact($msg['var']);
array_unshift($tmp, $msg['msg']);
$msg = call_user_func_array('sprintf', $tmp);
return $msg;
} | php | protected function getRuleMessage(Column $column, $type, $value)
{
// create message
$colName = $column->getName();
$tableName = $column->getTable()->getName();
$msg = self::$validatorMessages[strtolower($type)];
$tmp = compact($msg['var']);
array_unshift($tmp, $msg['msg']);
$msg = call_user_func_array('sprintf', $tmp);
return $msg;
} | [
"protected",
"function",
"getRuleMessage",
"(",
"Column",
"$",
"column",
",",
"$",
"type",
",",
"$",
"value",
")",
"{",
"// create message",
"$",
"colName",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"$",
"tableName",
"=",
"$",
"column",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"msg",
"=",
"self",
"::",
"$",
"validatorMessages",
"[",
"strtolower",
"(",
"$",
"type",
")",
"]",
";",
"$",
"tmp",
"=",
"compact",
"(",
"$",
"msg",
"[",
"'var'",
"]",
")",
";",
"array_unshift",
"(",
"$",
"tmp",
",",
"$",
"msg",
"[",
"'msg'",
"]",
")",
";",
"$",
"msg",
"=",
"call_user_func_array",
"(",
"'sprintf'",
",",
"$",
"tmp",
")",
";",
"return",
"$",
"msg",
";",
"}"
] | Gets the message for a specified rule.
@param Column $column
@param string $type
@param mixed $value
@return string | [
"Gets",
"the",
"message",
"for",
"a",
"specified",
"rule",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSchemaReverseTask.php#L513-L524 |
propelorm/Propel | generator/lib/task/PropelSchemaReverseTask.php | PropelSchemaReverse_ValidatorSet.getValidator | public function getValidator(Column $column)
{
$key = $column->getName();
if (!isset($this->validators[$key])) {
$this->validators[$key] = new Validator();
$this->validators[$key]->setColumn($column);
}
return $this->validators[$key];
} | php | public function getValidator(Column $column)
{
$key = $column->getName();
if (!isset($this->validators[$key])) {
$this->validators[$key] = new Validator();
$this->validators[$key]->setColumn($column);
}
return $this->validators[$key];
} | [
"public",
"function",
"getValidator",
"(",
"Column",
"$",
"column",
")",
"{",
"$",
"key",
"=",
"$",
"column",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"validators",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"validators",
"[",
"$",
"key",
"]",
"=",
"new",
"Validator",
"(",
")",
";",
"$",
"this",
"->",
"validators",
"[",
"$",
"key",
"]",
"->",
"setColumn",
"(",
"$",
"column",
")",
";",
"}",
"return",
"$",
"this",
"->",
"validators",
"[",
"$",
"key",
"]",
";",
"}"
] | Gets a single validator for specified column name.
@param Column $column
@return Validator | [
"Gets",
"a",
"single",
"validator",
"for",
"specified",
"column",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSchemaReverseTask.php#L549-L558 |
propelorm/Propel | runtime/lib/map/DatabaseMap.php | DatabaseMap.addTableObject | public function addTableObject(TableMap $table)
{
$table->setDatabaseMap($this);
$this->tables[$table->getName()] = $table;
$this->tablesByPhpName[$table->getClassname()] = $table;
} | php | public function addTableObject(TableMap $table)
{
$table->setDatabaseMap($this);
$this->tables[$table->getName()] = $table;
$this->tablesByPhpName[$table->getClassname()] = $table;
} | [
"public",
"function",
"addTableObject",
"(",
"TableMap",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"setDatabaseMap",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"tables",
"[",
"$",
"table",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"table",
";",
"$",
"this",
"->",
"tablesByPhpName",
"[",
"$",
"table",
"->",
"getClassname",
"(",
")",
"]",
"=",
"$",
"table",
";",
"}"
] | Add a new table object to the database.
@param TableMap $table The table to add | [
"Add",
"a",
"new",
"table",
"object",
"to",
"the",
"database",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/DatabaseMap.php#L77-L82 |
propelorm/Propel | runtime/lib/map/DatabaseMap.php | DatabaseMap.addTableFromMapClass | public function addTableFromMapClass($tableMapClass)
{
$table = new $tableMapClass();
if (!$this->hasTable($table->getName())) {
$this->addTableObject($table);
return $table;
} else {
return $this->getTable($table->getName());
}
} | php | public function addTableFromMapClass($tableMapClass)
{
$table = new $tableMapClass();
if (!$this->hasTable($table->getName())) {
$this->addTableObject($table);
return $table;
} else {
return $this->getTable($table->getName());
}
} | [
"public",
"function",
"addTableFromMapClass",
"(",
"$",
"tableMapClass",
")",
"{",
"$",
"table",
"=",
"new",
"$",
"tableMapClass",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasTable",
"(",
"$",
"table",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"addTableObject",
"(",
"$",
"table",
")",
";",
"return",
"$",
"table",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getTable",
"(",
"$",
"table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Add a new table to the database, using the tablemap class name.
@param string $tableMapClass The name of the table map to add
@return TableMap The TableMap object | [
"Add",
"a",
"new",
"table",
"to",
"the",
"database",
"using",
"the",
"tablemap",
"class",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/map/DatabaseMap.php#L91-L101 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.