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 | runtime/lib/query/Criteria.php | Criteria.getColumnForAs | public function getColumnForAs($as)
{
if (isset($this->asColumns[$as])) {
return $this->asColumns[$as];
}
return null;
} | php | public function getColumnForAs($as)
{
if (isset($this->asColumns[$as])) {
return $this->asColumns[$as];
}
return null;
} | [
"public",
"function",
"getColumnForAs",
"(",
"$",
"as",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"asColumns",
"[",
"$",
"as",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"asColumns",
"[",
"$",
"as",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the column name associated with an alias (AS-column).
@param string $as
@return string|null $string The name if found, null otherwise. | [
"Returns",
"the",
"column",
"name",
"associated",
"with",
"an",
"alias",
"(",
"AS",
"-",
"column",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L371-L378 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.getTableForAlias | public function getTableForAlias($alias)
{
if (isset($this->aliases[$alias])) {
return $this->aliases[$alias];
}
return null;
} | php | public function getTableForAlias($alias)
{
if (isset($this->aliases[$alias])) {
return $this->aliases[$alias];
}
return null;
} | [
"public",
"function",
"getTableForAlias",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the table name associated with an alias.
@param string $alias
@return string|null $string The name if given, null otherwise. | [
"Returns",
"the",
"table",
"name",
"associated",
"with",
"an",
"alias",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L427-L434 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.keyContainsValue | public function keyContainsValue($column)
{
// must use array_key_exists() because the key could
// exist but have a NULL value (that'd be valid).
return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null));
} | php | public function keyContainsValue($column)
{
// must use array_key_exists() because the key could
// exist but have a NULL value (that'd be valid).
return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null));
} | [
"public",
"function",
"keyContainsValue",
"(",
"$",
"column",
")",
"{",
"// must use array_key_exists() because the key could",
"// exist but have a NULL value (that'd be valid).",
"return",
"(",
"array_key_exists",
"(",
"$",
"column",
",",
"$",
"this",
"->",
"map",
")",
"&&",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"column",
"]",
"->",
"getValue",
"(",
")",
"!==",
"null",
")",
")",
";",
"}"
] | Does this Criteria object contain the specified key and does it have a value set for the key
@param string $column [table.]column
@return boolean True if this Criteria object contain the specified key and a value for that key | [
"Does",
"this",
"Criteria",
"object",
"contain",
"the",
"specified",
"key",
"and",
"does",
"it",
"have",
"a",
"value",
"set",
"for",
"the",
"key"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L489-L494 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.getLastCriterion | public function getLastCriterion()
{
if ($cnt = count($this->map)) {
$map = array_values($this->map);
return $map[$cnt - 1];
}
return null;
} | php | public function getLastCriterion()
{
if ($cnt = count($this->map)) {
$map = array_values($this->map);
return $map[$cnt - 1];
}
return null;
} | [
"public",
"function",
"getLastCriterion",
"(",
")",
"{",
"if",
"(",
"$",
"cnt",
"=",
"count",
"(",
"$",
"this",
"->",
"map",
")",
")",
"{",
"$",
"map",
"=",
"array_values",
"(",
"$",
"this",
"->",
"map",
")",
";",
"return",
"$",
"map",
"[",
"$",
"cnt",
"-",
"1",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Method to return the latest Criterion in a table.
@return Criterion A Criterion or null no Criterion is added. | [
"Method",
"to",
"return",
"the",
"latest",
"Criterion",
"in",
"a",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L555-L564 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.getNewCriterion | public function getNewCriterion($column, $value = null, $comparison = self::EQUAL)
{
return new Criterion($this, $column, $value, $comparison);
} | php | public function getNewCriterion($column, $value = null, $comparison = self::EQUAL)
{
return new Criterion($this, $column, $value, $comparison);
} | [
"public",
"function",
"getNewCriterion",
"(",
"$",
"column",
",",
"$",
"value",
"=",
"null",
",",
"$",
"comparison",
"=",
"self",
"::",
"EQUAL",
")",
"{",
"return",
"new",
"Criterion",
"(",
"$",
"this",
",",
"$",
"column",
",",
"$",
"value",
",",
"$",
"comparison",
")",
";",
"}"
] | Method to return criterion that is not added automatically
to this Criteria. This can be used to chain the
Criterions to form a more complex where clause.
@param string $column Full name of column (for example TABLE.COLUMN).
@param mixed $value
@param string $comparison
@return Criterion | [
"Method",
"to",
"return",
"criterion",
"that",
"is",
"not",
"added",
"automatically",
"to",
"this",
"Criteria",
".",
"This",
"can",
"be",
"used",
"to",
"chain",
"the",
"Criterions",
"to",
"form",
"a",
"more",
"complex",
"where",
"clause",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L577-L580 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.getTablesColumns | public function getTablesColumns()
{
$tables = array();
foreach ($this->keys() as $key) {
$tableName = substr($key, 0, strrpos($key, '.'));
$tables[$tableName][] = $key;
}
return $tables;
} | php | public function getTablesColumns()
{
$tables = array();
foreach ($this->keys() as $key) {
$tableName = substr($key, 0, strrpos($key, '.'));
$tables[$tableName][] = $key;
}
return $tables;
} | [
"public",
"function",
"getTablesColumns",
"(",
")",
"{",
"$",
"tables",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"tableName",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"strrpos",
"(",
"$",
"key",
",",
"'.'",
")",
")",
";",
"$",
"tables",
"[",
"$",
"tableName",
"]",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"$",
"tables",
";",
"}"
] | Shortcut method to get an array of columns indexed by table.
<code>
print_r($c->getTablesColumns());
=> array(
'book' => array('book.price', 'book.title'),
'author' => array('author.first_name')
)
</code>
@return array array(table => array(table.column1, table.column2)) | [
"Shortcut",
"method",
"to",
"get",
"an",
"array",
"of",
"columns",
"indexed",
"by",
"table",
".",
"<code",
">",
"print_r",
"(",
"$c",
"-",
">",
"getTablesColumns",
"()",
")",
";",
"=",
">",
"array",
"(",
"book",
"=",
">",
"array",
"(",
"book",
".",
"price",
"book",
".",
"title",
")",
"author",
"=",
">",
"array",
"(",
"author",
".",
"first_name",
")",
")",
"<",
"/",
"code",
">"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L610-L619 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.setDbName | public function setDbName($dbName = null)
{
$this->dbName = ($dbName === null ? Propel::getDefaultDB() : $dbName);
} | php | public function setDbName($dbName = null)
{
$this->dbName = ($dbName === null ? Propel::getDefaultDB() : $dbName);
} | [
"public",
"function",
"setDbName",
"(",
"$",
"dbName",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"dbName",
"=",
"(",
"$",
"dbName",
"===",
"null",
"?",
"Propel",
"::",
"getDefaultDB",
"(",
")",
":",
"$",
"dbName",
")",
";",
"}"
] | Set the DatabaseMap name. If <code>null</code> is supplied, uses value
provided by <code>Propel::getDefaultDB()</code>.
@param string $dbName The Database (Map) name.
@return void | [
"Set",
"the",
"DatabaseMap",
"name",
".",
"If",
"<code",
">",
"null<",
"/",
"code",
">",
"is",
"supplied",
"uses",
"value",
"provided",
"by",
"<code",
">",
"Propel",
"::",
"getDefaultDB",
"()",
"<",
"/",
"code",
">",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L655-L658 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.putAll | public function putAll($t)
{
if (is_array($t)) {
foreach ($t as $key => $value) {
if ($value instanceof Criterion) {
$this->map[$key] = $value;
} else {
$this->put($key, $value);
}
}
} elseif ($t instanceof Criteria) {
$this->joins = $t->joins;
}
} | php | public function putAll($t)
{
if (is_array($t)) {
foreach ($t as $key => $value) {
if ($value instanceof Criterion) {
$this->map[$key] = $value;
} else {
$this->put($key, $value);
}
}
} elseif ($t instanceof Criteria) {
$this->joins = $t->joins;
}
} | [
"public",
"function",
"putAll",
"(",
"$",
"t",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"t",
")",
")",
"{",
"foreach",
"(",
"$",
"t",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Criterion",
")",
"{",
"$",
"this",
"->",
"map",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"t",
"instanceof",
"Criteria",
")",
"{",
"$",
"this",
"->",
"joins",
"=",
"$",
"t",
"->",
"joins",
";",
"}",
"}"
] | Copies all of the mappings from the specified Map to this Criteria
These mappings will replace any mappings that this Criteria had for any
of the keys currently in the specified Map.
if the map was another Criteria, its attributes are copied to this
Criteria, overwriting previous settings.
@param mixed $t Mappings to be stored in this map. | [
"Copies",
"all",
"of",
"the",
"mappings",
"from",
"the",
"specified",
"Map",
"to",
"this",
"Criteria",
"These",
"mappings",
"will",
"replace",
"any",
"mappings",
"that",
"this",
"Criteria",
"had",
"for",
"any",
"of",
"the",
"keys",
"currently",
"in",
"the",
"specified",
"Map",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L762-L775 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.add | public function add($critOrColumn, $value = null, $comparison = null)
{
$criterion = $this->getCriterionForCondition($critOrColumn, $value, $comparison);
if ($critOrColumn instanceof Criterion) {
$this->map[$critOrColumn->getTable() . '.' . $critOrColumn->getColumn()] = $criterion;
} else {
$this->map[$critOrColumn] = $criterion;
}
return $this;
} | php | public function add($critOrColumn, $value = null, $comparison = null)
{
$criterion = $this->getCriterionForCondition($critOrColumn, $value, $comparison);
if ($critOrColumn instanceof Criterion) {
$this->map[$critOrColumn->getTable() . '.' . $critOrColumn->getColumn()] = $criterion;
} else {
$this->map[$critOrColumn] = $criterion;
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"critOrColumn",
",",
"$",
"value",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"$",
"criterion",
"=",
"$",
"this",
"->",
"getCriterionForCondition",
"(",
"$",
"critOrColumn",
",",
"$",
"value",
",",
"$",
"comparison",
")",
";",
"if",
"(",
"$",
"critOrColumn",
"instanceof",
"Criterion",
")",
"{",
"$",
"this",
"->",
"map",
"[",
"$",
"critOrColumn",
"->",
"getTable",
"(",
")",
".",
"'.'",
".",
"$",
"critOrColumn",
"->",
"getColumn",
"(",
")",
"]",
"=",
"$",
"criterion",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"map",
"[",
"$",
"critOrColumn",
"]",
"=",
"$",
"criterion",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | This method adds a new criterion to the list of criterias.
If a criterion for the requested column already exists, it is
replaced. If is used as follow:
<code>
$crit = new Criteria();
$crit->add($column, $value, Criteria::GREATER_THAN);
</code>
Any comparison can be used.
The name of the table must be used implicitly in the column name,
so the Column name must be something like 'TABLE.id'.
@param string $critOrColumn The column to run the comparison on, or a Criterion object.
@param mixed $value
@param string $comparison A String.
@return Criteria A modified Criteria object. | [
"This",
"method",
"adds",
"a",
"new",
"criterion",
"to",
"the",
"list",
"of",
"criterias",
".",
"If",
"a",
"criterion",
"for",
"the",
"requested",
"column",
"already",
"exists",
"it",
"is",
"replaced",
".",
"If",
"is",
"used",
"as",
"follow",
":"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L798-L808 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.combine | public function combine($criterions = array(), $operator = self::LOGICAL_AND, $name = null)
{
$operatorMethod = (strtoupper($operator) == self::LOGICAL_AND) ? 'addAnd' : 'addOr';
$namedCriterions = array();
foreach ($criterions as $key) {
if (array_key_exists($key, $this->namedCriterions)) {
$namedCriterions[] = $this->namedCriterions[$key];
unset($this->namedCriterions[$key]);
} else {
throw new PropelException('Cannot combine unknown condition ' . $key);
}
}
$firstCriterion = array_shift($namedCriterions);
foreach ($namedCriterions as $criterion) {
$firstCriterion->$operatorMethod($criterion);
}
if ($name === null) {
$this->addAnd($firstCriterion, null, null);
} else {
$this->addCond($name, $firstCriterion, null, null);
}
return $this;
} | php | public function combine($criterions = array(), $operator = self::LOGICAL_AND, $name = null)
{
$operatorMethod = (strtoupper($operator) == self::LOGICAL_AND) ? 'addAnd' : 'addOr';
$namedCriterions = array();
foreach ($criterions as $key) {
if (array_key_exists($key, $this->namedCriterions)) {
$namedCriterions[] = $this->namedCriterions[$key];
unset($this->namedCriterions[$key]);
} else {
throw new PropelException('Cannot combine unknown condition ' . $key);
}
}
$firstCriterion = array_shift($namedCriterions);
foreach ($namedCriterions as $criterion) {
$firstCriterion->$operatorMethod($criterion);
}
if ($name === null) {
$this->addAnd($firstCriterion, null, null);
} else {
$this->addCond($name, $firstCriterion, null, null);
}
return $this;
} | [
"public",
"function",
"combine",
"(",
"$",
"criterions",
"=",
"array",
"(",
")",
",",
"$",
"operator",
"=",
"self",
"::",
"LOGICAL_AND",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"operatorMethod",
"=",
"(",
"strtoupper",
"(",
"$",
"operator",
")",
"==",
"self",
"::",
"LOGICAL_AND",
")",
"?",
"'addAnd'",
":",
"'addOr'",
";",
"$",
"namedCriterions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criterions",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"namedCriterions",
")",
")",
"{",
"$",
"namedCriterions",
"[",
"]",
"=",
"$",
"this",
"->",
"namedCriterions",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"namedCriterions",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot combine unknown condition '",
".",
"$",
"key",
")",
";",
"}",
"}",
"$",
"firstCriterion",
"=",
"array_shift",
"(",
"$",
"namedCriterions",
")",
";",
"foreach",
"(",
"$",
"namedCriterions",
"as",
"$",
"criterion",
")",
"{",
"$",
"firstCriterion",
"->",
"$",
"operatorMethod",
"(",
"$",
"criterion",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"addAnd",
"(",
"$",
"firstCriterion",
",",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addCond",
"(",
"$",
"name",
",",
"$",
"firstCriterion",
",",
"null",
",",
"null",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Combine several named criterions with a logical operator
@param array $criterions array of the name of the criterions to combine
@param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR
@param string $name optional name to combine the criterion later
@return Criteria
@throws PropelException | [
"Combine",
"several",
"named",
"criterions",
"with",
"a",
"logical",
"operator"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L851-L874 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.addJoinObject | public function addJoinObject(Join $join)
{
$isAlreadyAdded = false;
foreach ($this->joins as $alreadyAddedJoin) {
if ($join->equals($alreadyAddedJoin)) {
$isAlreadyAdded = true;
break;
}
}
if (!$isAlreadyAdded) {
$this->joins[] = $join;
}
return $this;
} | php | public function addJoinObject(Join $join)
{
$isAlreadyAdded = false;
foreach ($this->joins as $alreadyAddedJoin) {
if ($join->equals($alreadyAddedJoin)) {
$isAlreadyAdded = true;
break;
}
}
if (!$isAlreadyAdded) {
$this->joins[] = $join;
}
return $this;
} | [
"public",
"function",
"addJoinObject",
"(",
"Join",
"$",
"join",
")",
"{",
"$",
"isAlreadyAdded",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"joins",
"as",
"$",
"alreadyAddedJoin",
")",
"{",
"if",
"(",
"$",
"join",
"->",
"equals",
"(",
"$",
"alreadyAddedJoin",
")",
")",
"{",
"$",
"isAlreadyAdded",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"isAlreadyAdded",
")",
"{",
"$",
"this",
"->",
"joins",
"[",
"]",
"=",
"$",
"join",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a join object to the Criteria
@param Join $join A join object
@return Criteria A modified Criteria object | [
"Add",
"a",
"join",
"object",
"to",
"the",
"Criteria"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1008-L1023 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.removeSelectModifier | public function removeSelectModifier($modifier)
{
$this->selectModifiers = array_values(array_diff($this->selectModifiers, array($modifier)));
return $this;
} | php | public function removeSelectModifier($modifier)
{
$this->selectModifiers = array_values(array_diff($this->selectModifiers, array($modifier)));
return $this;
} | [
"public",
"function",
"removeSelectModifier",
"(",
"$",
"modifier",
")",
"{",
"$",
"this",
"->",
"selectModifiers",
"=",
"array_values",
"(",
"array_diff",
"(",
"$",
"this",
"->",
"selectModifiers",
",",
"array",
"(",
"$",
"modifier",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes a modifier to the SQL statement.
Checks for existence before removal
@param string $modifier The modifier to add
@return Criteria Modified Criteria object (for fluent API) | [
"Removes",
"a",
"modifier",
"to",
"the",
"SQL",
"statement",
".",
"Checks",
"for",
"existence",
"before",
"removal"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1160-L1165 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.getCriterionForCondition | protected function getCriterionForCondition($p1, $value = null, $comparison = null)
{
if ($p1 instanceof Criterion) {
// it's already a Criterion, so ignore $value and $comparison
return $p1;
} elseif (is_int($comparison)) {
// $comparison is a PDO::PARAM_* constant value
// something like $c->add('foo like ?', '%bar%', PDO::PARAM_STR);
return new Criterion($this, $p1, $value, Criteria::RAW, $comparison);
}
// $comparison is one of Criteria's constants
// something like $c->add(BookPeer::TITLE, 'War%', Criteria::LIKE);
return new Criterion($this, $p1, $value, $comparison);
} | php | protected function getCriterionForCondition($p1, $value = null, $comparison = null)
{
if ($p1 instanceof Criterion) {
// it's already a Criterion, so ignore $value and $comparison
return $p1;
} elseif (is_int($comparison)) {
// $comparison is a PDO::PARAM_* constant value
// something like $c->add('foo like ?', '%bar%', PDO::PARAM_STR);
return new Criterion($this, $p1, $value, Criteria::RAW, $comparison);
}
// $comparison is one of Criteria's constants
// something like $c->add(BookPeer::TITLE, 'War%', Criteria::LIKE);
return new Criterion($this, $p1, $value, $comparison);
} | [
"protected",
"function",
"getCriterionForCondition",
"(",
"$",
"p1",
",",
"$",
"value",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"p1",
"instanceof",
"Criterion",
")",
"{",
"// it's already a Criterion, so ignore $value and $comparison",
"return",
"$",
"p1",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"comparison",
")",
")",
"{",
"// $comparison is a PDO::PARAM_* constant value",
"// something like $c->add('foo like ?', '%bar%', PDO::PARAM_STR);",
"return",
"new",
"Criterion",
"(",
"$",
"this",
",",
"$",
"p1",
",",
"$",
"value",
",",
"Criteria",
"::",
"RAW",
",",
"$",
"comparison",
")",
";",
"}",
"// $comparison is one of Criteria's constants",
"// something like $c->add(BookPeer::TITLE, 'War%', Criteria::LIKE);",
"return",
"new",
"Criterion",
"(",
"$",
"this",
",",
"$",
"p1",
",",
"$",
"value",
",",
"$",
"comparison",
")",
";",
"}"
] | Build a Criterion.
This method has multiple signatures, and behaves differently according to it:
- If the first argument is a Criterion, it just returns this Criterion.
<code>$c->getCriterionForCondition($criterion); // returns $criterion</code>
- If the last argument is a PDO::PARAM_* constant value, create a Criterion
using Criteria::RAW and $comparison as a type.
<code>$c->getCriterionForCondition('foo like ?', '%bar%', PDO::PARAM_STR);</code>
- Otherwise, create a classic Criterion based on a column name and a comparison.
<code>$c->getCriterionForCondition(BookPeer::TITLE, 'War%', Criteria::LIKE);</code>
@param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name
@param mixed $value The value to bind in the condition
@param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant
@return Criterion | [
"Build",
"a",
"Criterion",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1722-L1736 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.addAnd | public function addAnd($p1, $value = null, $comparison = null, $preferColumnCondition = true)
{
$criterion = $this->getCriterionForCondition($p1, $value, $comparison);
$key = $criterion->getTable() . '.' . $criterion->getColumn();
if ($preferColumnCondition && $this->containsKey($key)) {
// FIXME: addAnd() operates preferably on existing conditions on the same column
// this may cause unexpected results, but it's there for BC with Propel 14
$this->getCriterion($key)->addAnd($criterion);
} else {
// simply add the condition to the list - this is the expected behavior
$this->add($criterion);
}
return $this;
} | php | public function addAnd($p1, $value = null, $comparison = null, $preferColumnCondition = true)
{
$criterion = $this->getCriterionForCondition($p1, $value, $comparison);
$key = $criterion->getTable() . '.' . $criterion->getColumn();
if ($preferColumnCondition && $this->containsKey($key)) {
// FIXME: addAnd() operates preferably on existing conditions on the same column
// this may cause unexpected results, but it's there for BC with Propel 14
$this->getCriterion($key)->addAnd($criterion);
} else {
// simply add the condition to the list - this is the expected behavior
$this->add($criterion);
}
return $this;
} | [
"public",
"function",
"addAnd",
"(",
"$",
"p1",
",",
"$",
"value",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
",",
"$",
"preferColumnCondition",
"=",
"true",
")",
"{",
"$",
"criterion",
"=",
"$",
"this",
"->",
"getCriterionForCondition",
"(",
"$",
"p1",
",",
"$",
"value",
",",
"$",
"comparison",
")",
";",
"$",
"key",
"=",
"$",
"criterion",
"->",
"getTable",
"(",
")",
".",
"'.'",
".",
"$",
"criterion",
"->",
"getColumn",
"(",
")",
";",
"if",
"(",
"$",
"preferColumnCondition",
"&&",
"$",
"this",
"->",
"containsKey",
"(",
"$",
"key",
")",
")",
"{",
"// FIXME: addAnd() operates preferably on existing conditions on the same column",
"// this may cause unexpected results, but it's there for BC with Propel 14",
"$",
"this",
"->",
"getCriterion",
"(",
"$",
"key",
")",
"->",
"addAnd",
"(",
"$",
"criterion",
")",
";",
"}",
"else",
"{",
"// simply add the condition to the list - this is the expected behavior",
"$",
"this",
"->",
"add",
"(",
"$",
"criterion",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | If a criterion for the requested column already exists, the condition is "AND"ed to the existing criterion (necessary for Propel 1.4 compatibility).
If no criterion for the requested column already exists, the condition is "AND"ed to the latest criterion.
If no criterion exist, the condition is added a new criterion
Any comparison can be used.
Supports a number of different signatures:
- addAnd(column, value, comparison)
- addAnd(column, value)
- addAnd(Criterion)
@param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name
@param mixed $value The value to bind in the condition
@param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant
@param bool $preferColumnCondition
@return Criteria A modified Criteria object. | [
"If",
"a",
"criterion",
"for",
"the",
"requested",
"column",
"already",
"exists",
"the",
"condition",
"is",
"AND",
"ed",
"to",
"the",
"existing",
"criterion",
"(",
"necessary",
"for",
"Propel",
"1",
".",
"4",
"compatibility",
")",
".",
"If",
"no",
"criterion",
"for",
"the",
"requested",
"column",
"already",
"exists",
"the",
"condition",
"is",
"AND",
"ed",
"to",
"the",
"latest",
"criterion",
".",
"If",
"no",
"criterion",
"exist",
"the",
"condition",
"is",
"added",
"a",
"new",
"criterion"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1757-L1772 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.addOr | public function addOr($p1, $value = null, $comparison = null, $preferColumnCondition = true)
{
$rightCriterion = $this->getCriterionForCondition($p1, $value, $comparison);
$key = $rightCriterion->getTable() . '.' . $rightCriterion->getColumn();
if ($preferColumnCondition && $this->containsKey($key)) {
// FIXME: addOr() operates preferably on existing conditions on the same column
// this may cause unexpected results, but it's there for BC with Propel 14
$leftCriterion = $this->getCriterion($key);
} else {
// fallback to the latest condition - this is the expected behavior
$leftCriterion = $this->getLastCriterion();
}
if ($leftCriterion !== null) {
// combine the given criterion with the existing one with an 'OR'
$leftCriterion->addOr($rightCriterion);
} else {
// nothing to do OR / AND with, so make it first condition
$this->add($rightCriterion);
}
return $this;
} | php | public function addOr($p1, $value = null, $comparison = null, $preferColumnCondition = true)
{
$rightCriterion = $this->getCriterionForCondition($p1, $value, $comparison);
$key = $rightCriterion->getTable() . '.' . $rightCriterion->getColumn();
if ($preferColumnCondition && $this->containsKey($key)) {
// FIXME: addOr() operates preferably on existing conditions on the same column
// this may cause unexpected results, but it's there for BC with Propel 14
$leftCriterion = $this->getCriterion($key);
} else {
// fallback to the latest condition - this is the expected behavior
$leftCriterion = $this->getLastCriterion();
}
if ($leftCriterion !== null) {
// combine the given criterion with the existing one with an 'OR'
$leftCriterion->addOr($rightCriterion);
} else {
// nothing to do OR / AND with, so make it first condition
$this->add($rightCriterion);
}
return $this;
} | [
"public",
"function",
"addOr",
"(",
"$",
"p1",
",",
"$",
"value",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
",",
"$",
"preferColumnCondition",
"=",
"true",
")",
"{",
"$",
"rightCriterion",
"=",
"$",
"this",
"->",
"getCriterionForCondition",
"(",
"$",
"p1",
",",
"$",
"value",
",",
"$",
"comparison",
")",
";",
"$",
"key",
"=",
"$",
"rightCriterion",
"->",
"getTable",
"(",
")",
".",
"'.'",
".",
"$",
"rightCriterion",
"->",
"getColumn",
"(",
")",
";",
"if",
"(",
"$",
"preferColumnCondition",
"&&",
"$",
"this",
"->",
"containsKey",
"(",
"$",
"key",
")",
")",
"{",
"// FIXME: addOr() operates preferably on existing conditions on the same column",
"// this may cause unexpected results, but it's there for BC with Propel 14",
"$",
"leftCriterion",
"=",
"$",
"this",
"->",
"getCriterion",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"// fallback to the latest condition - this is the expected behavior",
"$",
"leftCriterion",
"=",
"$",
"this",
"->",
"getLastCriterion",
"(",
")",
";",
"}",
"if",
"(",
"$",
"leftCriterion",
"!==",
"null",
")",
"{",
"// combine the given criterion with the existing one with an 'OR'",
"$",
"leftCriterion",
"->",
"addOr",
"(",
"$",
"rightCriterion",
")",
";",
"}",
"else",
"{",
"// nothing to do OR / AND with, so make it first condition",
"$",
"this",
"->",
"add",
"(",
"$",
"rightCriterion",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | If a criterion for the requested column already exists, the condition is "OR"ed to the existing criterion (necessary for Propel 1.4 compatibility).
If no criterion for the requested column already exists, the condition is "OR"ed to the latest criterion.
If no criterion exist, the condition is added a new criterion
Any comparison can be used.
Supports a number of different signatures:
- addOr(column, value, comparison)
- addOr(column, value)
- addOr(Criterion)
@param mixed $p1 A Criterion, or a SQL clause with a question mark placeholder, or a column name
@param mixed $value The value to bind in the condition
@param mixed $comparison A Criteria class constant, or a PDO::PARAM_ class constant
@param bool $preferColumnCondition
@return Criteria A modified Criteria object. | [
"If",
"a",
"criterion",
"for",
"the",
"requested",
"column",
"already",
"exists",
"the",
"condition",
"is",
"OR",
"ed",
"to",
"the",
"existing",
"criterion",
"(",
"necessary",
"for",
"Propel",
"1",
".",
"4",
"compatibility",
")",
".",
"If",
"no",
"criterion",
"for",
"the",
"requested",
"column",
"already",
"exists",
"the",
"condition",
"is",
"OR",
"ed",
"to",
"the",
"latest",
"criterion",
".",
"If",
"no",
"criterion",
"exist",
"the",
"condition",
"is",
"added",
"a",
"new",
"criterion"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1793-L1816 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria.addUsingOperator | public function addUsingOperator($p1, $value = null, $operator = null, $preferColumnCondition = true)
{
if ($this->defaultCombineOperator == Criteria::LOGICAL_OR) {
$this->defaultCombineOperator = Criteria::LOGICAL_AND;
return $this->addOr($p1, $value, $operator, $preferColumnCondition);
} else {
return $this->addAnd($p1, $value, $operator, $preferColumnCondition);
}
} | php | public function addUsingOperator($p1, $value = null, $operator = null, $preferColumnCondition = true)
{
if ($this->defaultCombineOperator == Criteria::LOGICAL_OR) {
$this->defaultCombineOperator = Criteria::LOGICAL_AND;
return $this->addOr($p1, $value, $operator, $preferColumnCondition);
} else {
return $this->addAnd($p1, $value, $operator, $preferColumnCondition);
}
} | [
"public",
"function",
"addUsingOperator",
"(",
"$",
"p1",
",",
"$",
"value",
"=",
"null",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"preferColumnCondition",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"defaultCombineOperator",
"==",
"Criteria",
"::",
"LOGICAL_OR",
")",
"{",
"$",
"this",
"->",
"defaultCombineOperator",
"=",
"Criteria",
"::",
"LOGICAL_AND",
";",
"return",
"$",
"this",
"->",
"addOr",
"(",
"$",
"p1",
",",
"$",
"value",
",",
"$",
"operator",
",",
"$",
"preferColumnCondition",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"addAnd",
"(",
"$",
"p1",
",",
"$",
"value",
",",
"$",
"operator",
",",
"$",
"preferColumnCondition",
")",
";",
"}",
"}"
] | Overrides Criteria::add() to use the default combine operator
@see Criteria::add()
@param string|Criterion $p1 The column to run the comparison on (e.g. BookPeer::ID), or Criterion object
@param mixed $value
@param string $operator A String, like Criteria::EQUAL.
@param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column
(necessary for Propel 1.4 compatibility).
If false, the condition is combined with the last existing condition.
@return Criteria A modified Criteria object. | [
"Overrides",
"Criteria",
"::",
"add",
"()",
"to",
"use",
"the",
"default",
"combine",
"operator"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1832-L1841 |
propelorm/Propel | runtime/lib/query/Criteria.php | Criteria._endif | public function _endif()
{
if (!$this->conditionalProxy) {
throw new PropelException('_endif() must be called after _if()');
}
$this->conditionalProxy = $this->conditionalProxy->getParentProxy();
if ($this->conditionalProxy) {
return $this->conditionalProxy->getCriteriaOrProxy();
}
// reached last level
return $this;
} | php | public function _endif()
{
if (!$this->conditionalProxy) {
throw new PropelException('_endif() must be called after _if()');
}
$this->conditionalProxy = $this->conditionalProxy->getParentProxy();
if ($this->conditionalProxy) {
return $this->conditionalProxy->getCriteriaOrProxy();
}
// reached last level
return $this;
} | [
"public",
"function",
"_endif",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"conditionalProxy",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'_endif() must be called after _if()'",
")",
";",
"}",
"$",
"this",
"->",
"conditionalProxy",
"=",
"$",
"this",
"->",
"conditionalProxy",
"->",
"getParentProxy",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"conditionalProxy",
")",
"{",
"return",
"$",
"this",
"->",
"conditionalProxy",
"->",
"getCriteriaOrProxy",
"(",
")",
";",
"}",
"// reached last level",
"return",
"$",
"this",
";",
"}"
] | Returns the current object
Allows for conditional statements in a fluid interface.
@return Criteria
@throws PropelException | [
"Returns",
"the",
"current",
"object",
"Allows",
"for",
"conditional",
"statements",
"in",
"a",
"fluid",
"interface",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/query/Criteria.php#L1927-L1941 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.guessPeerCountMethod | private function guessPeerCountMethod()
{
$selectMethod = $this->getPeerSelectMethod();
if ($selectMethod == 'doSelect') {
$countMethod = 'doCount';
} elseif (($pos = stripos($selectMethod, 'doSelectJoin')) === 0) {
$countMethod = 'doCount' . substr($selectMethod, strlen('doSelect'));
} else {
// we will fall back to doCount() if we don't understand the join
// method; however, it probably won't be accurate. Maybe triggering an error would
// be appropriate ...
$countMethod = 'doCount';
}
$this->setPeerCountMethod($countMethod);
} | php | private function guessPeerCountMethod()
{
$selectMethod = $this->getPeerSelectMethod();
if ($selectMethod == 'doSelect') {
$countMethod = 'doCount';
} elseif (($pos = stripos($selectMethod, 'doSelectJoin')) === 0) {
$countMethod = 'doCount' . substr($selectMethod, strlen('doSelect'));
} else {
// we will fall back to doCount() if we don't understand the join
// method; however, it probably won't be accurate. Maybe triggering an error would
// be appropriate ...
$countMethod = 'doCount';
}
$this->setPeerCountMethod($countMethod);
} | [
"private",
"function",
"guessPeerCountMethod",
"(",
")",
"{",
"$",
"selectMethod",
"=",
"$",
"this",
"->",
"getPeerSelectMethod",
"(",
")",
";",
"if",
"(",
"$",
"selectMethod",
"==",
"'doSelect'",
")",
"{",
"$",
"countMethod",
"=",
"'doCount'",
";",
"}",
"elseif",
"(",
"(",
"$",
"pos",
"=",
"stripos",
"(",
"$",
"selectMethod",
",",
"'doSelectJoin'",
")",
")",
"===",
"0",
")",
"{",
"$",
"countMethod",
"=",
"'doCount'",
".",
"substr",
"(",
"$",
"selectMethod",
",",
"strlen",
"(",
"'doSelect'",
")",
")",
";",
"}",
"else",
"{",
"// we will fall back to doCount() if we don't understand the join",
"// method; however, it probably won't be accurate. Maybe triggering an error would",
"// be appropriate ...",
"$",
"countMethod",
"=",
"'doCount'",
";",
"}",
"$",
"this",
"->",
"setPeerCountMethod",
"(",
"$",
"countMethod",
")",
";",
"}"
] | Guesses the Peer count method based on the select method. | [
"Guesses",
"the",
"Peer",
"count",
"method",
"based",
"on",
"the",
"select",
"method",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L254-L268 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.doRs | private function doRs()
{
$this->criteria->setOffset($this->start);
$this->criteria->setLimit($this->max);
$this->rs = call_user_func(array($this->getPeerClass(), $this->getPeerSelectMethod()), $this->criteria);
} | php | private function doRs()
{
$this->criteria->setOffset($this->start);
$this->criteria->setLimit($this->max);
$this->rs = call_user_func(array($this->getPeerClass(), $this->getPeerSelectMethod()), $this->criteria);
} | [
"private",
"function",
"doRs",
"(",
")",
"{",
"$",
"this",
"->",
"criteria",
"->",
"setOffset",
"(",
"$",
"this",
"->",
"start",
")",
";",
"$",
"this",
"->",
"criteria",
"->",
"setLimit",
"(",
"$",
"this",
"->",
"max",
")",
";",
"$",
"this",
"->",
"rs",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"getPeerClass",
"(",
")",
",",
"$",
"this",
"->",
"getPeerSelectMethod",
"(",
")",
")",
",",
"$",
"this",
"->",
"criteria",
")",
";",
"}"
] | Get the paged resultset
Main method which creates a paged result set based on the criteria
and the requested peer select method. | [
"Get",
"the",
"paged",
"resultset"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L291-L296 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.getTotalPages | public function getTotalPages()
{
if (!isset($this->pages)) {
$recordCount = $this->getTotalRecordCount();
if ($this->max > 0) {
$this->pages = ceil($recordCount / $this->max);
} else {
$this->pages = 0;
}
}
return $this->pages;
} | php | public function getTotalPages()
{
if (!isset($this->pages)) {
$recordCount = $this->getTotalRecordCount();
if ($this->max > 0) {
$this->pages = ceil($recordCount / $this->max);
} else {
$this->pages = 0;
}
}
return $this->pages;
} | [
"public",
"function",
"getTotalPages",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pages",
")",
")",
"{",
"$",
"recordCount",
"=",
"$",
"this",
"->",
"getTotalRecordCount",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"max",
">",
"0",
")",
"{",
"$",
"this",
"->",
"pages",
"=",
"ceil",
"(",
"$",
"recordCount",
"/",
"$",
"this",
"->",
"max",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"pages",
"=",
"0",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"pages",
";",
"}"
] | get total pages
@return int $this->pages | [
"get",
"total",
"pages"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L351-L363 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.getPrevLinks | public function getPrevLinks($range = 5)
{
$total = $this->getTotalPages();
$start = $this->getPage() - 1;
$end = $this->getPage() - $range;
$first = $this->getFirstPage();
$links = array();
for ($i = $start; $i > $end; $i--) {
if ($i < $first) {
break;
}
$links[] = $i;
}
return array_reverse($links);
} | php | public function getPrevLinks($range = 5)
{
$total = $this->getTotalPages();
$start = $this->getPage() - 1;
$end = $this->getPage() - $range;
$first = $this->getFirstPage();
$links = array();
for ($i = $start; $i > $end; $i--) {
if ($i < $first) {
break;
}
$links[] = $i;
}
return array_reverse($links);
} | [
"public",
"function",
"getPrevLinks",
"(",
"$",
"range",
"=",
"5",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"getTotalPages",
"(",
")",
";",
"$",
"start",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"-",
"1",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"-",
"$",
"range",
";",
"$",
"first",
"=",
"$",
"this",
"->",
"getFirstPage",
"(",
")",
";",
"$",
"links",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"start",
";",
"$",
"i",
">",
"$",
"end",
";",
"$",
"i",
"--",
")",
"{",
"if",
"(",
"$",
"i",
"<",
"$",
"first",
")",
"{",
"break",
";",
"}",
"$",
"links",
"[",
"]",
"=",
"$",
"i",
";",
"}",
"return",
"array_reverse",
"(",
"$",
"links",
")",
";",
"}"
] | get an array of previous id's
@param int $range
@return array $links | [
"get",
"an",
"array",
"of",
"previous",
"id",
"s"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L372-L387 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.getNextLinks | public function getNextLinks($range = 5)
{
$total = $this->getTotalPages();
$start = $this->getPage() + 1;
$end = $this->getPage() + $range;
$last = $this->getLastPage();
$links = array();
for ($i = $start; $i < $end; $i++) {
if ($i > $last) {
break;
}
$links[] = $i;
}
return $links;
} | php | public function getNextLinks($range = 5)
{
$total = $this->getTotalPages();
$start = $this->getPage() + 1;
$end = $this->getPage() + $range;
$last = $this->getLastPage();
$links = array();
for ($i = $start; $i < $end; $i++) {
if ($i > $last) {
break;
}
$links[] = $i;
}
return $links;
} | [
"public",
"function",
"getNextLinks",
"(",
"$",
"range",
"=",
"5",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"getTotalPages",
"(",
")",
";",
"$",
"start",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"+",
"1",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"+",
"$",
"range",
";",
"$",
"last",
"=",
"$",
"this",
"->",
"getLastPage",
"(",
")",
";",
"$",
"links",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"start",
";",
"$",
"i",
"<",
"$",
"end",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
">",
"$",
"last",
")",
"{",
"break",
";",
"}",
"$",
"links",
"[",
"]",
"=",
"$",
"i",
";",
"}",
"return",
"$",
"links",
";",
"}"
] | get an array of next id's
@param int $range
@return array $links | [
"get",
"an",
"array",
"of",
"next",
"id",
"s"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L396-L411 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.getPrev | public function getPrev()
{
if ($this->getPage() != $this->getFirstPage()) {
$prev = $this->getPage() - 1;
} else {
$prev = false;
}
return $prev;
} | php | public function getPrev()
{
if ($this->getPage() != $this->getFirstPage()) {
$prev = $this->getPage() - 1;
} else {
$prev = false;
}
return $prev;
} | [
"public",
"function",
"getPrev",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPage",
"(",
")",
"!=",
"$",
"this",
"->",
"getFirstPage",
"(",
")",
")",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"prev",
"=",
"false",
";",
"}",
"return",
"$",
"prev",
";",
"}"
] | get previous id
@return mixed $prev | [
"get",
"previous",
"id"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L428-L437 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.getNext | public function getNext()
{
if ($this->getPage() != $this->getLastPage()) {
$next = $this->getPage() + 1;
} else {
$next = false;
}
return $next;
} | php | public function getNext()
{
if ($this->getPage() != $this->getLastPage()) {
$next = $this->getPage() + 1;
} else {
$next = false;
}
return $next;
} | [
"public",
"function",
"getNext",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPage",
"(",
")",
"!=",
"$",
"this",
"->",
"getLastPage",
"(",
")",
")",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"getPage",
"(",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"next",
"=",
"false",
";",
"}",
"return",
"$",
"next",
";",
"}"
] | get next id
@return mixed $next | [
"get",
"next",
"id"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L444-L453 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.getTotalRecordCount | public function getTotalRecordCount()
{
if (!isset($this->rs)) {
$this->doRs();
}
if (empty($this->recordCount)) {
$this->countCriteria = clone $this->criteria;
$this->countCriteria->setLimit(0);
$this->countCriteria->setOffset(0);
$this->recordCount = call_user_func(array($this->getPeerClass(), $this->getPeerCountMethod()), $this->countCriteria);
}
return $this->recordCount;
} | php | public function getTotalRecordCount()
{
if (!isset($this->rs)) {
$this->doRs();
}
if (empty($this->recordCount)) {
$this->countCriteria = clone $this->criteria;
$this->countCriteria->setLimit(0);
$this->countCriteria->setOffset(0);
$this->recordCount = call_user_func(array($this->getPeerClass(), $this->getPeerCountMethod()), $this->countCriteria);
}
return $this->recordCount;
} | [
"public",
"function",
"getTotalRecordCount",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"rs",
")",
")",
"{",
"$",
"this",
"->",
"doRs",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"recordCount",
")",
")",
"{",
"$",
"this",
"->",
"countCriteria",
"=",
"clone",
"$",
"this",
"->",
"criteria",
";",
"$",
"this",
"->",
"countCriteria",
"->",
"setLimit",
"(",
"0",
")",
";",
"$",
"this",
"->",
"countCriteria",
"->",
"setOffset",
"(",
"0",
")",
";",
"$",
"this",
"->",
"recordCount",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"getPeerClass",
"(",
")",
",",
"$",
"this",
"->",
"getPeerCountMethod",
"(",
")",
")",
",",
"$",
"this",
"->",
"countCriteria",
")",
";",
"}",
"return",
"$",
"this",
"->",
"recordCount",
";",
"}"
] | Gets the total number of (un-LIMITed) records.
This method will perform a query that executes un-LIMITed query.
@return int Total number of records - disregarding page, maxrows, etc. | [
"Gets",
"the",
"total",
"number",
"of",
"(",
"un",
"-",
"LIMITed",
")",
"records",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L518-L534 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.current | public function current()
{
if (!isset($this->rs)) {
$this->doRs();
}
return $this->rs[$this->currentKey];
} | php | public function current()
{
if (!isset($this->rs)) {
$this->doRs();
}
return $this->rs[$this->currentKey];
} | [
"public",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"rs",
")",
")",
"{",
"$",
"this",
"->",
"doRs",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rs",
"[",
"$",
"this",
"->",
"currentKey",
"]",
";",
"}"
] | Returns the current element of the iterator
@return mixed | [
"Returns",
"the",
"current",
"element",
"of",
"the",
"iterator"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L573-L580 |
propelorm/Propel | runtime/lib/util/PropelPager.php | PropelPager.valid | public function valid()
{
if (!isset($this->rs)) {
$this->doRs();
}
return in_array($this->currentKey, array_keys($this->rs));
} | php | public function valid()
{
if (!isset($this->rs)) {
$this->doRs();
}
return in_array($this->currentKey, array_keys($this->rs));
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"rs",
")",
")",
"{",
"$",
"this",
"->",
"doRs",
"(",
")",
";",
"}",
"return",
"in_array",
"(",
"$",
"this",
"->",
"currentKey",
",",
"array_keys",
"(",
"$",
"this",
"->",
"rs",
")",
")",
";",
"}"
] | Checks if the current key exists in the container
@return boolean | [
"Checks",
"if",
"the",
"current",
"key",
"exists",
"in",
"the",
"container"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelPager.php#L617-L624 |
propelorm/Propel | runtime/lib/collection/PropelArrayCollection.php | PropelArrayCollection.save | public function save($con = null)
{
if (!method_exists($this->getModel(), 'save')) {
throw new PropelException('Cannot save objects on a read-only model');
}
if (null === $con) {
$con = $this->getConnection(Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
$obj = $this->getWorkerObject();
foreach ($this as $element) {
$obj->clear();
$obj->fromArray($element);
$obj->setNew($obj->isPrimaryKeyNull());
$obj->save($con);
}
$con->commit();
} catch (Exception $e) {
$con->rollback();
}
} | php | public function save($con = null)
{
if (!method_exists($this->getModel(), 'save')) {
throw new PropelException('Cannot save objects on a read-only model');
}
if (null === $con) {
$con = $this->getConnection(Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
$obj = $this->getWorkerObject();
foreach ($this as $element) {
$obj->clear();
$obj->fromArray($element);
$obj->setNew($obj->isPrimaryKeyNull());
$obj->save($con);
}
$con->commit();
} catch (Exception $e) {
$con->rollback();
}
} | [
"public",
"function",
"save",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
",",
"'save'",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot save objects on a read-only model'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"$",
"this",
"->",
"getConnection",
"(",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"getWorkerObject",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"element",
")",
"{",
"$",
"obj",
"->",
"clear",
"(",
")",
";",
"$",
"obj",
"->",
"fromArray",
"(",
"$",
"element",
")",
";",
"$",
"obj",
"->",
"setNew",
"(",
"$",
"obj",
"->",
"isPrimaryKeyNull",
"(",
")",
")",
";",
"$",
"obj",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"}",
"}"
] | Save all the elements in the collection
@param PropelPDO $con
@throws PropelException | [
"Save",
"all",
"the",
"elements",
"in",
"the",
"collection"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelArrayCollection.php#L28-L49 |
propelorm/Propel | runtime/lib/collection/PropelArrayCollection.php | PropelArrayCollection.delete | public function delete($con = null)
{
if (!method_exists($this->getModel(), 'delete')) {
throw new PropelException('Cannot delete objects on a read-only model');
}
if (null === $con) {
$con = $this->getConnection(Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
foreach ($this as $element) {
$obj = $this->getWorkerObject();
$obj->setDeleted(false);
$obj->fromArray($element);
$obj->delete($con);
}
$con->commit();
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | php | public function delete($con = null)
{
if (!method_exists($this->getModel(), 'delete')) {
throw new PropelException('Cannot delete objects on a read-only model');
}
if (null === $con) {
$con = $this->getConnection(Propel::CONNECTION_WRITE);
}
$con->beginTransaction();
try {
foreach ($this as $element) {
$obj = $this->getWorkerObject();
$obj->setDeleted(false);
$obj->fromArray($element);
$obj->delete($con);
}
$con->commit();
} catch (Exception $e) {
$con->rollback();
throw $e;
}
} | [
"public",
"function",
"delete",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
",",
"'delete'",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot delete objects on a read-only model'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"$",
"this",
"->",
"getConnection",
"(",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"element",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"getWorkerObject",
"(",
")",
";",
"$",
"obj",
"->",
"setDeleted",
"(",
"false",
")",
";",
"$",
"obj",
"->",
"fromArray",
"(",
"$",
"element",
")",
";",
"$",
"obj",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"}",
"$",
"con",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"con",
"->",
"rollback",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Delete all the elements in the collection
@param PropelPDO $con
@throws PropelException | [
"Delete",
"all",
"the",
"elements",
"in",
"the",
"collection"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelArrayCollection.php#L58-L79 |
propelorm/Propel | runtime/lib/collection/PropelArrayCollection.php | PropelArrayCollection.toArray | public function toArray($keyColumn = null, $usePrefix = false, $keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
$ret = array();
foreach ($this as $key => $element) {
$key = null === $keyColumn ? $key : $element[$keyColumn];
$key = $usePrefix ? ($this->getModel() . '_' . $key) : $key;
$ret[$key] = $element;
}
return $ret;
} | php | public function toArray($keyColumn = null, $usePrefix = false, $keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
$ret = array();
foreach ($this as $key => $element) {
$key = null === $keyColumn ? $key : $element[$keyColumn];
$key = $usePrefix ? ($this->getModel() . '_' . $key) : $key;
$ret[$key] = $element;
}
return $ret;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyColumn",
"=",
"null",
",",
"$",
"usePrefix",
"=",
"false",
",",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"$",
"key",
"=",
"null",
"===",
"$",
"keyColumn",
"?",
"$",
"key",
":",
"$",
"element",
"[",
"$",
"keyColumn",
"]",
";",
"$",
"key",
"=",
"$",
"usePrefix",
"?",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
".",
"'_'",
".",
"$",
"key",
")",
":",
"$",
"key",
";",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"$",
"element",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Get an array representation of the collection
This is not an alias for getData(), since it returns a copy of the data
@param string $keyColumn If null, the returned array uses an incremental index.
Otherwise, the array is indexed using the specified column
@param boolean $usePrefix If true, the returned array prefixes keys
with the model class name ('Article_0', 'Article_1', etc).
<code>
$bookCollection->toArray();
array(
0 => array('Id' => 123, 'Title' => 'War And Peace'),
1 => array('Id' => 456, 'Title' => 'Don Juan'),
)
$bookCollection->toArray('Id');
array(
123 => array('Id' => 123, 'Title' => 'War And Peace'),
456 => array('Id' => 456, 'Title' => 'Don Juan'),
)
$bookCollection->toArray(null, true);
array(
'Book_0' => array('Id' => 123, 'Title' => 'War And Peace'),
'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'),
)
</code>
@return array | [
"Get",
"an",
"array",
"representation",
"of",
"the",
"collection",
"This",
"is",
"not",
"an",
"alias",
"for",
"getData",
"()",
"since",
"it",
"returns",
"a",
"copy",
"of",
"the",
"data"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelArrayCollection.php#L146-L156 |
propelorm/Propel | generator/lib/model/Table.php | Table.getStdSeparatedName | private function getStdSeparatedName()
{
if ($this->schema && $this->getBuildProperty('schemaAutoPrefix')) {
return $this->schema . NameGenerator::STD_SEPARATOR_CHAR . $this->nonPrefixedName;
} else {
return $this->nonPrefixedName;
}
} | php | private function getStdSeparatedName()
{
if ($this->schema && $this->getBuildProperty('schemaAutoPrefix')) {
return $this->schema . NameGenerator::STD_SEPARATOR_CHAR . $this->nonPrefixedName;
} else {
return $this->nonPrefixedName;
}
} | [
"private",
"function",
"getStdSeparatedName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"schema",
"&&",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'schemaAutoPrefix'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"schema",
".",
"NameGenerator",
"::",
"STD_SEPARATOR_CHAR",
".",
"$",
"this",
"->",
"nonPrefixedName",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"nonPrefixedName",
";",
"}",
"}"
] | get a qualified name of this table with scheme and common name separated by '_'
if schemaAutoPrefix is set. Otherwise get the common name.
@return string | [
"get",
"a",
"qualified",
"name",
"of",
"this",
"table",
"with",
"scheme",
"and",
"common",
"name",
"separated",
"by",
"_",
"if",
"schemaAutoPrefix",
"is",
"set",
".",
"Otherwise",
"get",
"the",
"common",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L321-L328 |
propelorm/Propel | generator/lib/model/Table.php | Table.setupObject | public function setupObject()
{
parent::setupObject();
$this->commonName = $this->getDatabase()->getTablePrefix() . $this->getAttribute("name");
$this->nonPrefixedName = $this->getAttribute('name');
// retrieves the method for converting from specified name to a PHP name.
$this->phpNamingMethod = $this->getAttribute("phpNamingMethod", $this->getDatabase()->getDefaultPhpNamingMethod());
$this->phpName = $this->getAttribute("phpName", $this->buildPhpName($this->getStdSeparatedName()));
$this->idMethod = $this->getAttribute("idMethod", $this->getDatabase()->getDefaultIdMethod());
$this->allowPkInsert = $this->booleanValue($this->getAttribute("allowPkInsert"));
$this->skipSql = $this->booleanValue($this->getAttribute("skipSql"));
$this->readOnly = $this->booleanValue($this->getAttribute("readOnly"));
$this->abstractValue = $this->booleanValue($this->getAttribute("abstract"));
$this->baseClass = $this->getAttribute("baseClass");
$this->basePeer = $this->getAttribute("basePeer");
$this->alias = $this->getAttribute("alias");
$this->heavyIndexing = ($this->booleanValue($this->getAttribute("heavyIndexing")) || ("false" !== $this->getAttribute("heavyIndexing") && $this->getDatabase()->isHeavyIndexing()));
$this->description = $this->getAttribute("description");
$this->interface = $this->getAttribute("interface"); // sic ('interface' is reserved word)
$this->treeMode = $this->getAttribute("treeMode");
$this->reloadOnInsert = $this->booleanValue($this->getAttribute("reloadOnInsert"));
$this->reloadOnUpdate = $this->booleanValue($this->getAttribute("reloadOnUpdate"));
$this->isCrossRef = $this->booleanValue($this->getAttribute("isCrossRef", false));
$this->defaultStringFormat = $this->getAttribute('defaultStringFormat');
} | php | public function setupObject()
{
parent::setupObject();
$this->commonName = $this->getDatabase()->getTablePrefix() . $this->getAttribute("name");
$this->nonPrefixedName = $this->getAttribute('name');
// retrieves the method for converting from specified name to a PHP name.
$this->phpNamingMethod = $this->getAttribute("phpNamingMethod", $this->getDatabase()->getDefaultPhpNamingMethod());
$this->phpName = $this->getAttribute("phpName", $this->buildPhpName($this->getStdSeparatedName()));
$this->idMethod = $this->getAttribute("idMethod", $this->getDatabase()->getDefaultIdMethod());
$this->allowPkInsert = $this->booleanValue($this->getAttribute("allowPkInsert"));
$this->skipSql = $this->booleanValue($this->getAttribute("skipSql"));
$this->readOnly = $this->booleanValue($this->getAttribute("readOnly"));
$this->abstractValue = $this->booleanValue($this->getAttribute("abstract"));
$this->baseClass = $this->getAttribute("baseClass");
$this->basePeer = $this->getAttribute("basePeer");
$this->alias = $this->getAttribute("alias");
$this->heavyIndexing = ($this->booleanValue($this->getAttribute("heavyIndexing")) || ("false" !== $this->getAttribute("heavyIndexing") && $this->getDatabase()->isHeavyIndexing()));
$this->description = $this->getAttribute("description");
$this->interface = $this->getAttribute("interface"); // sic ('interface' is reserved word)
$this->treeMode = $this->getAttribute("treeMode");
$this->reloadOnInsert = $this->booleanValue($this->getAttribute("reloadOnInsert"));
$this->reloadOnUpdate = $this->booleanValue($this->getAttribute("reloadOnUpdate"));
$this->isCrossRef = $this->booleanValue($this->getAttribute("isCrossRef", false));
$this->defaultStringFormat = $this->getAttribute('defaultStringFormat');
} | [
"public",
"function",
"setupObject",
"(",
")",
"{",
"parent",
"::",
"setupObject",
"(",
")",
";",
"$",
"this",
"->",
"commonName",
"=",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getTablePrefix",
"(",
")",
".",
"$",
"this",
"->",
"getAttribute",
"(",
"\"name\"",
")",
";",
"$",
"this",
"->",
"nonPrefixedName",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'name'",
")",
";",
"// retrieves the method for converting from specified name to a PHP name.",
"$",
"this",
"->",
"phpNamingMethod",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"phpNamingMethod\"",
",",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getDefaultPhpNamingMethod",
"(",
")",
")",
";",
"$",
"this",
"->",
"phpName",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"phpName\"",
",",
"$",
"this",
"->",
"buildPhpName",
"(",
"$",
"this",
"->",
"getStdSeparatedName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"idMethod",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"idMethod\"",
",",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getDefaultIdMethod",
"(",
")",
")",
";",
"$",
"this",
"->",
"allowPkInsert",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"allowPkInsert\"",
")",
")",
";",
"$",
"this",
"->",
"skipSql",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"skipSql\"",
")",
")",
";",
"$",
"this",
"->",
"readOnly",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"readOnly\"",
")",
")",
";",
"$",
"this",
"->",
"abstractValue",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"abstract\"",
")",
")",
";",
"$",
"this",
"->",
"baseClass",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"baseClass\"",
")",
";",
"$",
"this",
"->",
"basePeer",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"basePeer\"",
")",
";",
"$",
"this",
"->",
"alias",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"alias\"",
")",
";",
"$",
"this",
"->",
"heavyIndexing",
"=",
"(",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"heavyIndexing\"",
")",
")",
"||",
"(",
"\"false\"",
"!==",
"$",
"this",
"->",
"getAttribute",
"(",
"\"heavyIndexing\"",
")",
"&&",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"isHeavyIndexing",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"description",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"description\"",
")",
";",
"$",
"this",
"->",
"interface",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"interface\"",
")",
";",
"// sic ('interface' is reserved word)",
"$",
"this",
"->",
"treeMode",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"treeMode\"",
")",
";",
"$",
"this",
"->",
"reloadOnInsert",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"reloadOnInsert\"",
")",
")",
";",
"$",
"this",
"->",
"reloadOnUpdate",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"reloadOnUpdate\"",
")",
")",
";",
"$",
"this",
"->",
"isCrossRef",
"=",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"isCrossRef\"",
",",
"false",
")",
")",
";",
"$",
"this",
"->",
"defaultStringFormat",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'defaultStringFormat'",
")",
";",
"}"
] | Sets up the Rule object based on the attributes that were passed to loadFromXML().
@see parent::loadFromXML() | [
"Sets",
"up",
"the",
"Rule",
"object",
"based",
"on",
"the",
"attributes",
"that",
"were",
"passed",
"to",
"loadFromXML",
"()",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L335-L366 |
propelorm/Propel | generator/lib/model/Table.php | Table.getColumnList | public function getColumnList($columns, $delim = ',')
{
$list = array();
foreach ($columns as $col) {
if ($col instanceof Column) {
$col = $col->getName();
}
$list[] = $col;
}
return implode($delim, $list);
} | php | public function getColumnList($columns, $delim = ',')
{
$list = array();
foreach ($columns as $col) {
if ($col instanceof Column) {
$col = $col->getName();
}
$list[] = $col;
}
return implode($delim, $list);
} | [
"public",
"function",
"getColumnList",
"(",
"$",
"columns",
",",
"$",
"delim",
"=",
"','",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"instanceof",
"Column",
")",
"{",
"$",
"col",
"=",
"$",
"col",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"list",
"[",
"]",
"=",
"$",
"col",
";",
"}",
"return",
"implode",
"(",
"$",
"delim",
",",
"$",
"list",
")",
";",
"}"
] | Creates a delimiter-delimited string list of column names
@see Platform::getColumnList() if quoting is required
@param array Column[] or string[]
@param string $delim The delimiter to use in separating the column names.
@return string | [
"Creates",
"a",
"delimiter",
"-",
"delimited",
"string",
"list",
"of",
"column",
"names"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L580-L591 |
propelorm/Propel | generator/lib/model/Table.php | Table.doNaming | public function doNaming()
{
// Assure names are unique across all databases.
try {
for ($i = 0, $size = count($this->foreignKeys); $i < $size; $i++) {
$fk = $this->foreignKeys[$i];
$name = $fk->getName();
if (empty($name)) {
$name = $this->acquireConstraintName("FK", $i + 1);
$fk->setName($name);
}
}
for ($i = 0, $size = count($this->indices); $i < $size; $i++) {
$index = $this->indices[$i];
$name = $index->getName();
if (empty($name)) {
$name = $this->acquireConstraintName("I", $i + 1);
$index->setName($name);
}
}
for ($i = 0, $size = count($this->unices); $i < $size; $i++) {
$index = $this->unices[$i];
$name = $index->getName();
if (empty($name)) {
$name = $this->acquireConstraintName("U", $i + 1);
$index->setName($name);
}
}
// NOTE: Most RDBMSes can apparently name unique column
// constraints/indices themselves (using MySQL and Oracle
// as test cases), so we'll assume that we needn't add an
// entry to the system name list for these.
} catch (EngineException $nameAlreadyInUse) {
print $nameAlreadyInUse->getMessage() . "\n";
print $nameAlreadyInUse->getTraceAsString();
}
} | php | public function doNaming()
{
// Assure names are unique across all databases.
try {
for ($i = 0, $size = count($this->foreignKeys); $i < $size; $i++) {
$fk = $this->foreignKeys[$i];
$name = $fk->getName();
if (empty($name)) {
$name = $this->acquireConstraintName("FK", $i + 1);
$fk->setName($name);
}
}
for ($i = 0, $size = count($this->indices); $i < $size; $i++) {
$index = $this->indices[$i];
$name = $index->getName();
if (empty($name)) {
$name = $this->acquireConstraintName("I", $i + 1);
$index->setName($name);
}
}
for ($i = 0, $size = count($this->unices); $i < $size; $i++) {
$index = $this->unices[$i];
$name = $index->getName();
if (empty($name)) {
$name = $this->acquireConstraintName("U", $i + 1);
$index->setName($name);
}
}
// NOTE: Most RDBMSes can apparently name unique column
// constraints/indices themselves (using MySQL and Oracle
// as test cases), so we'll assume that we needn't add an
// entry to the system name list for these.
} catch (EngineException $nameAlreadyInUse) {
print $nameAlreadyInUse->getMessage() . "\n";
print $nameAlreadyInUse->getTraceAsString();
}
} | [
"public",
"function",
"doNaming",
"(",
")",
"{",
"// Assure names are unique across all databases.",
"try",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"foreignKeys",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"fk",
"=",
"$",
"this",
"->",
"foreignKeys",
"[",
"$",
"i",
"]",
";",
"$",
"name",
"=",
"$",
"fk",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"acquireConstraintName",
"(",
"\"FK\"",
",",
"$",
"i",
"+",
"1",
")",
";",
"$",
"fk",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"indices",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"indices",
"[",
"$",
"i",
"]",
";",
"$",
"name",
"=",
"$",
"index",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"acquireConstraintName",
"(",
"\"I\"",
",",
"$",
"i",
"+",
"1",
")",
";",
"$",
"index",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"unices",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"unices",
"[",
"$",
"i",
"]",
";",
"$",
"name",
"=",
"$",
"index",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"acquireConstraintName",
"(",
"\"U\"",
",",
"$",
"i",
"+",
"1",
")",
";",
"$",
"index",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"}",
"}",
"// NOTE: Most RDBMSes can apparently name unique column",
"// constraints/indices themselves (using MySQL and Oracle",
"// as test cases), so we'll assume that we needn't add an",
"// entry to the system name list for these.",
"}",
"catch",
"(",
"EngineException",
"$",
"nameAlreadyInUse",
")",
"{",
"print",
"$",
"nameAlreadyInUse",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
";",
"print",
"$",
"nameAlreadyInUse",
"->",
"getTraceAsString",
"(",
")",
";",
"}",
"}"
] | Names composing objects which haven't yet been named. This
currently consists of foreign-key and index entities. | [
"Names",
"composing",
"objects",
"which",
"haven",
"t",
"yet",
"been",
"named",
".",
"This",
"currently",
"consists",
"of",
"foreign",
"-",
"key",
"and",
"index",
"entities",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L597-L635 |
propelorm/Propel | generator/lib/model/Table.php | Table.acquireConstraintName | private function acquireConstraintName($nameType, $nbr)
{
$inputs = array();
$inputs[] = $this->getDatabase();
$inputs[] = $this->getCommonName();
$inputs[] = $nameType;
$inputs[] = $nbr;
return NameFactory::generateName(NameFactory::CONSTRAINT_GENERATOR, $inputs);
} | php | private function acquireConstraintName($nameType, $nbr)
{
$inputs = array();
$inputs[] = $this->getDatabase();
$inputs[] = $this->getCommonName();
$inputs[] = $nameType;
$inputs[] = $nbr;
return NameFactory::generateName(NameFactory::CONSTRAINT_GENERATOR, $inputs);
} | [
"private",
"function",
"acquireConstraintName",
"(",
"$",
"nameType",
",",
"$",
"nbr",
")",
"{",
"$",
"inputs",
"=",
"array",
"(",
")",
";",
"$",
"inputs",
"[",
"]",
"=",
"$",
"this",
"->",
"getDatabase",
"(",
")",
";",
"$",
"inputs",
"[",
"]",
"=",
"$",
"this",
"->",
"getCommonName",
"(",
")",
";",
"$",
"inputs",
"[",
"]",
"=",
"$",
"nameType",
";",
"$",
"inputs",
"[",
"]",
"=",
"$",
"nbr",
";",
"return",
"NameFactory",
"::",
"generateName",
"(",
"NameFactory",
"::",
"CONSTRAINT_GENERATOR",
",",
"$",
"inputs",
")",
";",
"}"
] | Macro to a constraint name.
@param nameType constraint type
@param nbr unique number for this constraint type
@return unique name for constraint
@throws EngineException | [
"Macro",
"to",
"a",
"constraint",
"name",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L646-L655 |
propelorm/Propel | generator/lib/model/Table.php | Table.getBaseClass | public function getBaseClass()
{
if ($this->isAlias() && $this->baseClass === null) {
return $this->alias;
} elseif ($this->baseClass === null) {
return $this->getDatabase()->getBaseClass();
} else {
return $this->baseClass;
}
} | php | public function getBaseClass()
{
if ($this->isAlias() && $this->baseClass === null) {
return $this->alias;
} elseif ($this->baseClass === null) {
return $this->getDatabase()->getBaseClass();
} else {
return $this->baseClass;
}
} | [
"public",
"function",
"getBaseClass",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAlias",
"(",
")",
"&&",
"$",
"this",
"->",
"baseClass",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"alias",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"baseClass",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getBaseClass",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"baseClass",
";",
"}",
"}"
] | Gets the value of base class for classes produced from this table.
@return The base class for classes produced from this table. | [
"Gets",
"the",
"value",
"of",
"base",
"class",
"for",
"classes",
"produced",
"from",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L662-L671 |
propelorm/Propel | generator/lib/model/Table.php | Table.getBasePeer | public function getBasePeer()
{
if ($this->isAlias() && $this->basePeer === null) {
return $this->alias . "Peer";
} elseif ($this->basePeer === null) {
return $this->getDatabase()->getBasePeer();
} else {
return $this->basePeer;
}
} | php | public function getBasePeer()
{
if ($this->isAlias() && $this->basePeer === null) {
return $this->alias . "Peer";
} elseif ($this->basePeer === null) {
return $this->getDatabase()->getBasePeer();
} else {
return $this->basePeer;
}
} | [
"public",
"function",
"getBasePeer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAlias",
"(",
")",
"&&",
"$",
"this",
"->",
"basePeer",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"alias",
".",
"\"Peer\"",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"basePeer",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getBasePeer",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"basePeer",
";",
"}",
"}"
] | Get the value of basePeer.
@return value of basePeer. | [
"Get",
"the",
"value",
"of",
"basePeer",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L688-L697 |
propelorm/Propel | generator/lib/model/Table.php | Table.removeColumn | public function removeColumn($col)
{
if (is_string($col)) {
$col = $this->getColumn($col);
}
$pos = array_search($col, $this->columnList);
if (false === $pos) {
throw new EngineException(sprintf('No column named %s found in table %s', $col->getName(), $this->getName()));
}
unset($this->columnList[$pos]);
unset($this->columnsByName[$col->getName()]);
unset($this->columnsByLowercaseName[strtolower($col->getName())]);
unset($this->columnsByPhpName[$col->getPhpName()]);
$this->adjustColumnPositions();
// FIXME: also remove indexes and validators on this column?
} | php | public function removeColumn($col)
{
if (is_string($col)) {
$col = $this->getColumn($col);
}
$pos = array_search($col, $this->columnList);
if (false === $pos) {
throw new EngineException(sprintf('No column named %s found in table %s', $col->getName(), $this->getName()));
}
unset($this->columnList[$pos]);
unset($this->columnsByName[$col->getName()]);
unset($this->columnsByLowercaseName[strtolower($col->getName())]);
unset($this->columnsByPhpName[$col->getPhpName()]);
$this->adjustColumnPositions();
// FIXME: also remove indexes and validators on this column?
} | [
"public",
"function",
"removeColumn",
"(",
"$",
"col",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"col",
")",
")",
"{",
"$",
"col",
"=",
"$",
"this",
"->",
"getColumn",
"(",
"$",
"col",
")",
";",
"}",
"$",
"pos",
"=",
"array_search",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"columnList",
")",
";",
"if",
"(",
"false",
"===",
"$",
"pos",
")",
"{",
"throw",
"new",
"EngineException",
"(",
"sprintf",
"(",
"'No column named %s found in table %s'",
",",
"$",
"col",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"columnList",
"[",
"$",
"pos",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"columnsByName",
"[",
"$",
"col",
"->",
"getName",
"(",
")",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"columnsByLowercaseName",
"[",
"strtolower",
"(",
"$",
"col",
"->",
"getName",
"(",
")",
")",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"columnsByPhpName",
"[",
"$",
"col",
"->",
"getPhpName",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"adjustColumnPositions",
"(",
")",
";",
"// FIXME: also remove indexes and validators on this column?",
"}"
] | Removed a column from the table
@param Column|string $col the column to remove
@throws EngineException | [
"Removed",
"a",
"column",
"from",
"the",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L756-L771 |
propelorm/Propel | generator/lib/model/Table.php | Table.addValidator | public function addValidator($data)
{
if ($data instanceof Validator) {
$validator = $data;
$col = $this->getColumn($validator->getColumnName());
if ($col == null) {
throw new EngineException("Failed adding validator to table '" . $this->getName() . "': column '" . $validator->getColumnName() . "' does not exist !");
}
$validator->setColumn($col);
$validator->setTable($this);
$this->validatorList[] = $validator;
return $validator;
} else {
$validator = new Validator();
$validator->setTable($this);
$validator->loadFromXML($data);
return $this->addValidator($validator);
}
} | php | public function addValidator($data)
{
if ($data instanceof Validator) {
$validator = $data;
$col = $this->getColumn($validator->getColumnName());
if ($col == null) {
throw new EngineException("Failed adding validator to table '" . $this->getName() . "': column '" . $validator->getColumnName() . "' does not exist !");
}
$validator->setColumn($col);
$validator->setTable($this);
$this->validatorList[] = $validator;
return $validator;
} else {
$validator = new Validator();
$validator->setTable($this);
$validator->loadFromXML($data);
return $this->addValidator($validator);
}
} | [
"public",
"function",
"addValidator",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Validator",
")",
"{",
"$",
"validator",
"=",
"$",
"data",
";",
"$",
"col",
"=",
"$",
"this",
"->",
"getColumn",
"(",
"$",
"validator",
"->",
"getColumnName",
"(",
")",
")",
";",
"if",
"(",
"$",
"col",
"==",
"null",
")",
"{",
"throw",
"new",
"EngineException",
"(",
"\"Failed adding validator to table '\"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"\"': column '\"",
".",
"$",
"validator",
"->",
"getColumnName",
"(",
")",
".",
"\"' does not exist !\"",
")",
";",
"}",
"$",
"validator",
"->",
"setColumn",
"(",
"$",
"col",
")",
";",
"$",
"validator",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"validatorList",
"[",
"]",
"=",
"$",
"validator",
";",
"return",
"$",
"validator",
";",
"}",
"else",
"{",
"$",
"validator",
"=",
"new",
"Validator",
"(",
")",
";",
"$",
"validator",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"$",
"validator",
"->",
"loadFromXML",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"addValidator",
"(",
"$",
"validator",
")",
";",
"}",
"}"
] | Add a validator to this table.
Supports two signatures:
- addValidator(Validator $validator)
- addValidator(array $attribs)
@param mixed $data Validator object or XML attribs (array) from <validator /> element.
@return Validator The added Validator.
@throws EngineException | [
"Add",
"a",
"validator",
"to",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L794-L814 |
propelorm/Propel | generator/lib/model/Table.php | Table.removeValidatorForColumn | public function removeValidatorForColumn($columnName)
{
foreach ($this->validatorList as $key => $validator) {
if ($validator->getColumnName() == $columnName) {
unset($this->validatorList[$key]);
}
}
} | php | public function removeValidatorForColumn($columnName)
{
foreach ($this->validatorList as $key => $validator) {
if ($validator->getColumnName() == $columnName) {
unset($this->validatorList[$key]);
}
}
} | [
"public",
"function",
"removeValidatorForColumn",
"(",
"$",
"columnName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"validatorList",
"as",
"$",
"key",
"=>",
"$",
"validator",
")",
"{",
"if",
"(",
"$",
"validator",
"->",
"getColumnName",
"(",
")",
"==",
"$",
"columnName",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"validatorList",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}"
] | Removes validators based on a column name
@param string $columnName The name of the column bearing a validator. | [
"Removes",
"validators",
"based",
"on",
"a",
"column",
"name"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L821-L828 |
propelorm/Propel | generator/lib/model/Table.php | Table.addForeignKey | public function addForeignKey($fkdata)
{
if ($fkdata instanceof ForeignKey) {
$fk = $fkdata;
$fk->setTable($this);
$this->foreignKeys[] = $fk;
if ($this->foreignTableNames === null) {
$this->foreignTableNames = array();
}
if (!in_array($fk->getForeignTableName(), $this->foreignTableNames)) {
$this->foreignTableNames[] = $fk->getForeignTableName();
}
return $fk;
} else {
$fk = new ForeignKey();
$fk->setTable($this);
$fk->loadFromXML($fkdata);
return $this->addForeignKey($fk);
}
} | php | public function addForeignKey($fkdata)
{
if ($fkdata instanceof ForeignKey) {
$fk = $fkdata;
$fk->setTable($this);
$this->foreignKeys[] = $fk;
if ($this->foreignTableNames === null) {
$this->foreignTableNames = array();
}
if (!in_array($fk->getForeignTableName(), $this->foreignTableNames)) {
$this->foreignTableNames[] = $fk->getForeignTableName();
}
return $fk;
} else {
$fk = new ForeignKey();
$fk->setTable($this);
$fk->loadFromXML($fkdata);
return $this->addForeignKey($fk);
}
} | [
"public",
"function",
"addForeignKey",
"(",
"$",
"fkdata",
")",
"{",
"if",
"(",
"$",
"fkdata",
"instanceof",
"ForeignKey",
")",
"{",
"$",
"fk",
"=",
"$",
"fkdata",
";",
"$",
"fk",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"foreignKeys",
"[",
"]",
"=",
"$",
"fk",
";",
"if",
"(",
"$",
"this",
"->",
"foreignTableNames",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"foreignTableNames",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"fk",
"->",
"getForeignTableName",
"(",
")",
",",
"$",
"this",
"->",
"foreignTableNames",
")",
")",
"{",
"$",
"this",
"->",
"foreignTableNames",
"[",
"]",
"=",
"$",
"fk",
"->",
"getForeignTableName",
"(",
")",
";",
"}",
"return",
"$",
"fk",
";",
"}",
"else",
"{",
"$",
"fk",
"=",
"new",
"ForeignKey",
"(",
")",
";",
"$",
"fk",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"$",
"fk",
"->",
"loadFromXML",
"(",
"$",
"fkdata",
")",
";",
"return",
"$",
"this",
"->",
"addForeignKey",
"(",
"$",
"fk",
")",
";",
"}",
"}"
] | A utility function to create a new foreign key
from attrib and add it to this table. | [
"A",
"utility",
"function",
"to",
"create",
"a",
"new",
"foreign",
"key",
"from",
"attrib",
"and",
"add",
"it",
"to",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L834-L856 |
propelorm/Propel | generator/lib/model/Table.php | Table.getChildrenNames | public function getChildrenNames()
{
if ($this->inheritanceColumn === null || !$this->inheritanceColumn->isEnumeratedClasses()) {
return null;
}
$children = $this->inheritanceColumn->getChildren();
$names = array();
for ($i = 0, $size = count($children); $i < $size; $i++) {
$names[] = get_class($children[$i]);
}
return $names;
} | php | public function getChildrenNames()
{
if ($this->inheritanceColumn === null || !$this->inheritanceColumn->isEnumeratedClasses()) {
return null;
}
$children = $this->inheritanceColumn->getChildren();
$names = array();
for ($i = 0, $size = count($children); $i < $size; $i++) {
$names[] = get_class($children[$i]);
}
return $names;
} | [
"public",
"function",
"getChildrenNames",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inheritanceColumn",
"===",
"null",
"||",
"!",
"$",
"this",
"->",
"inheritanceColumn",
"->",
"isEnumeratedClasses",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"children",
"=",
"$",
"this",
"->",
"inheritanceColumn",
"->",
"getChildren",
"(",
")",
";",
"$",
"names",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"children",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"get_class",
"(",
"$",
"children",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"names",
";",
"}"
] | Get the subclasses that can be created from this table.
@return array string[] Class names | [
"Get",
"the",
"subclasses",
"that",
"can",
"be",
"created",
"from",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L874-L886 |
propelorm/Propel | generator/lib/model/Table.php | Table.addIdMethodParameter | public function addIdMethodParameter($impdata)
{
if ($impdata instanceof IdMethodParameter) {
$imp = $impdata;
$imp->setTable($this);
if ($this->idMethodParameters === null) {
$this->idMethodParameters = array();
}
$this->idMethodParameters[] = $imp;
return $imp;
} else {
$imp = new IdMethodParameter();
$imp->loadFromXML($impdata);
return $this->addIdMethodParameter($imp); // call self w/ diff param
}
} | php | public function addIdMethodParameter($impdata)
{
if ($impdata instanceof IdMethodParameter) {
$imp = $impdata;
$imp->setTable($this);
if ($this->idMethodParameters === null) {
$this->idMethodParameters = array();
}
$this->idMethodParameters[] = $imp;
return $imp;
} else {
$imp = new IdMethodParameter();
$imp->loadFromXML($impdata);
return $this->addIdMethodParameter($imp); // call self w/ diff param
}
} | [
"public",
"function",
"addIdMethodParameter",
"(",
"$",
"impdata",
")",
"{",
"if",
"(",
"$",
"impdata",
"instanceof",
"IdMethodParameter",
")",
"{",
"$",
"imp",
"=",
"$",
"impdata",
";",
"$",
"imp",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"this",
"->",
"idMethodParameters",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"idMethodParameters",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"idMethodParameters",
"[",
"]",
"=",
"$",
"imp",
";",
"return",
"$",
"imp",
";",
"}",
"else",
"{",
"$",
"imp",
"=",
"new",
"IdMethodParameter",
"(",
")",
";",
"$",
"imp",
"->",
"loadFromXML",
"(",
"$",
"impdata",
")",
";",
"return",
"$",
"this",
"->",
"addIdMethodParameter",
"(",
"$",
"imp",
")",
";",
"// call self w/ diff param",
"}",
"}"
] | A utility function to create a new id method parameter
from attrib or object and add it to this table. | [
"A",
"utility",
"function",
"to",
"create",
"a",
"new",
"id",
"method",
"parameter",
"from",
"attrib",
"or",
"object",
"and",
"add",
"it",
"to",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1036-L1053 |
propelorm/Propel | generator/lib/model/Table.php | Table.removeIndex | public function removeIndex($name)
{
//check if we have a index with this name already, then delete it
foreach ($this->indices as $n => $idx) {
if ($idx->getName() == $name) {
unset($this->indices[$n]);
return;
}
}
} | php | public function removeIndex($name)
{
//check if we have a index with this name already, then delete it
foreach ($this->indices as $n => $idx) {
if ($idx->getName() == $name) {
unset($this->indices[$n]);
return;
}
}
} | [
"public",
"function",
"removeIndex",
"(",
"$",
"name",
")",
"{",
"//check if we have a index with this name already, then delete it",
"foreach",
"(",
"$",
"this",
"->",
"indices",
"as",
"$",
"n",
"=>",
"$",
"idx",
")",
"{",
"if",
"(",
"$",
"idx",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"indices",
"[",
"$",
"n",
"]",
")",
";",
"return",
";",
"}",
"}",
"}"
] | Removed a index from the table
@param string $name | [
"Removed",
"a",
"index",
"from",
"the",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1060-L1070 |
propelorm/Propel | generator/lib/model/Table.php | Table.addIndex | public function addIndex($idxdata)
{
if ($idxdata instanceof Index) {
$index = $idxdata;
$index->setTable($this);
$index->getName(); // we call this method so that the name is created now if it doesn't already exist.
$this->indices[] = $index;
return $index;
} else {
$index = new Index($this);
$index->loadFromXML($idxdata);
return $this->addIndex($index);
}
} | php | public function addIndex($idxdata)
{
if ($idxdata instanceof Index) {
$index = $idxdata;
$index->setTable($this);
$index->getName(); // we call this method so that the name is created now if it doesn't already exist.
$this->indices[] = $index;
return $index;
} else {
$index = new Index($this);
$index->loadFromXML($idxdata);
return $this->addIndex($index);
}
} | [
"public",
"function",
"addIndex",
"(",
"$",
"idxdata",
")",
"{",
"if",
"(",
"$",
"idxdata",
"instanceof",
"Index",
")",
"{",
"$",
"index",
"=",
"$",
"idxdata",
";",
"$",
"index",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"$",
"index",
"->",
"getName",
"(",
")",
";",
"// we call this method so that the name is created now if it doesn't already exist.",
"$",
"this",
"->",
"indices",
"[",
"]",
"=",
"$",
"index",
";",
"return",
"$",
"index",
";",
"}",
"else",
"{",
"$",
"index",
"=",
"new",
"Index",
"(",
"$",
"this",
")",
";",
"$",
"index",
"->",
"loadFromXML",
"(",
"$",
"idxdata",
")",
";",
"return",
"$",
"this",
"->",
"addIndex",
"(",
"$",
"index",
")",
";",
"}",
"}"
] | Adds a new index to the index list and set the
parent table of the column to the current table | [
"Adds",
"a",
"new",
"index",
"to",
"the",
"index",
"list",
"and",
"set",
"the",
"parent",
"table",
"of",
"the",
"column",
"to",
"the",
"current",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1095-L1110 |
propelorm/Propel | generator/lib/model/Table.php | Table.addUnique | public function addUnique($unqdata)
{
if ($unqdata instanceof Unique) {
$unique = $unqdata;
$unique->setTable($this);
$unique->getName(); // we call this method so that the name is created now if it doesn't already exist.
$this->unices[] = $unique;
return $unique;
} else {
$unique = new Unique($this);
$unique->loadFromXML($unqdata);
return $this->addUnique($unique);
}
} | php | public function addUnique($unqdata)
{
if ($unqdata instanceof Unique) {
$unique = $unqdata;
$unique->setTable($this);
$unique->getName(); // we call this method so that the name is created now if it doesn't already exist.
$this->unices[] = $unique;
return $unique;
} else {
$unique = new Unique($this);
$unique->loadFromXML($unqdata);
return $this->addUnique($unique);
}
} | [
"public",
"function",
"addUnique",
"(",
"$",
"unqdata",
")",
"{",
"if",
"(",
"$",
"unqdata",
"instanceof",
"Unique",
")",
"{",
"$",
"unique",
"=",
"$",
"unqdata",
";",
"$",
"unique",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"$",
"unique",
"->",
"getName",
"(",
")",
";",
"// we call this method so that the name is created now if it doesn't already exist.",
"$",
"this",
"->",
"unices",
"[",
"]",
"=",
"$",
"unique",
";",
"return",
"$",
"unique",
";",
"}",
"else",
"{",
"$",
"unique",
"=",
"new",
"Unique",
"(",
"$",
"this",
")",
";",
"$",
"unique",
"->",
"loadFromXML",
"(",
"$",
"unqdata",
")",
";",
"return",
"$",
"this",
"->",
"addUnique",
"(",
"$",
"unique",
")",
";",
"}",
"}"
] | Adds a new Unique to the Unique list and set the
parent table of the column to the current table | [
"Adds",
"a",
"new",
"Unique",
"to",
"the",
"Unique",
"list",
"and",
"set",
"the",
"parent",
"table",
"of",
"the",
"column",
"to",
"the",
"current",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1116-L1131 |
propelorm/Propel | generator/lib/model/Table.php | Table.getEarlyBehaviors | public function getEarlyBehaviors()
{
$behaviors = array();
foreach ($this->behaviors as $name => $behavior) {
if ($behavior->isEarly()) {
$behaviors[$name] = $behavior;
}
}
return $behaviors;
} | php | public function getEarlyBehaviors()
{
$behaviors = array();
foreach ($this->behaviors as $name => $behavior) {
if ($behavior->isEarly()) {
$behaviors[$name] = $behavior;
}
}
return $behaviors;
} | [
"public",
"function",
"getEarlyBehaviors",
"(",
")",
"{",
"$",
"behaviors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"behaviors",
"as",
"$",
"name",
"=>",
"$",
"behavior",
")",
"{",
"if",
"(",
"$",
"behavior",
"->",
"isEarly",
"(",
")",
")",
"{",
"$",
"behaviors",
"[",
"$",
"name",
"]",
"=",
"$",
"behavior",
";",
"}",
"}",
"return",
"$",
"behaviors",
";",
"}"
] | Get the early table behaviors
@return Behavior[] | [
"Get",
"the",
"early",
"table",
"behaviors"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1180-L1190 |
propelorm/Propel | generator/lib/model/Table.php | Table.getAdditionalBuilders | public function getAdditionalBuilders()
{
$additionalBuilders = array();
foreach ($this->getBehaviors() as $behavior) {
$additionalBuilders = array_merge($additionalBuilders, $behavior->getAdditionalBuilders());
}
return $additionalBuilders;
} | php | public function getAdditionalBuilders()
{
$additionalBuilders = array();
foreach ($this->getBehaviors() as $behavior) {
$additionalBuilders = array_merge($additionalBuilders, $behavior->getAdditionalBuilders());
}
return $additionalBuilders;
} | [
"public",
"function",
"getAdditionalBuilders",
"(",
")",
"{",
"$",
"additionalBuilders",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getBehaviors",
"(",
")",
"as",
"$",
"behavior",
")",
"{",
"$",
"additionalBuilders",
"=",
"array_merge",
"(",
"$",
"additionalBuilders",
",",
"$",
"behavior",
"->",
"getAdditionalBuilders",
"(",
")",
")",
";",
"}",
"return",
"$",
"additionalBuilders",
";",
"}"
] | Get the additional builders provided by the table behaviors
@return array list of builder class names | [
"Get",
"the",
"additional",
"builders",
"provided",
"by",
"the",
"table",
"behaviors"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1238-L1246 |
propelorm/Propel | generator/lib/model/Table.php | Table.getName | public function getName()
{
if ($this->schema && $this->getDatabase() && $this->getDatabase()->getPlatform() && $this->getDatabase()->getPlatform()->supportsSchemas()) {
return $this->schema . '.' . $this->commonName;
} else {
return $this->commonName;
}
} | php | public function getName()
{
if ($this->schema && $this->getDatabase() && $this->getDatabase()->getPlatform() && $this->getDatabase()->getPlatform()->supportsSchemas()) {
return $this->schema . '.' . $this->commonName;
} else {
return $this->commonName;
}
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"schema",
"&&",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"&&",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getPlatform",
"(",
")",
"&&",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getPlatform",
"(",
")",
"->",
"supportsSchemas",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"schema",
".",
"'.'",
".",
"$",
"this",
"->",
"commonName",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"commonName",
";",
"}",
"}"
] | Get the name of the Table | [
"Get",
"the",
"name",
"of",
"the",
"Table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1251-L1258 |
propelorm/Propel | generator/lib/model/Table.php | Table.getPhpName | public function getPhpName()
{
if ($this->phpName === null) {
$inputs = array();
$inputs[] = $this->getStdSeparatedName();
$inputs[] = $this->phpNamingMethod;
try {
$this->phpName = NameFactory::generateName(NameFactory::PHP_GENERATOR, $inputs);
} catch (EngineException $e) {
print $e->getMessage() . "\n";
print $e->getTraceAsString();
}
}
return $this->phpName;
} | php | public function getPhpName()
{
if ($this->phpName === null) {
$inputs = array();
$inputs[] = $this->getStdSeparatedName();
$inputs[] = $this->phpNamingMethod;
try {
$this->phpName = NameFactory::generateName(NameFactory::PHP_GENERATOR, $inputs);
} catch (EngineException $e) {
print $e->getMessage() . "\n";
print $e->getTraceAsString();
}
}
return $this->phpName;
} | [
"public",
"function",
"getPhpName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"phpName",
"===",
"null",
")",
"{",
"$",
"inputs",
"=",
"array",
"(",
")",
";",
"$",
"inputs",
"[",
"]",
"=",
"$",
"this",
"->",
"getStdSeparatedName",
"(",
")",
";",
"$",
"inputs",
"[",
"]",
"=",
"$",
"this",
"->",
"phpNamingMethod",
";",
"try",
"{",
"$",
"this",
"->",
"phpName",
"=",
"NameFactory",
"::",
"generateName",
"(",
"NameFactory",
"::",
"PHP_GENERATOR",
",",
"$",
"inputs",
")",
";",
"}",
"catch",
"(",
"EngineException",
"$",
"e",
")",
"{",
"print",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
";",
"print",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"phpName",
";",
"}"
] | Get name to use in PHP sources
@return string | [
"Get",
"name",
"to",
"use",
"in",
"PHP",
"sources"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1291-L1306 |
propelorm/Propel | generator/lib/model/Table.php | Table.getDefaultStringFormat | public function getDefaultStringFormat()
{
if (!$this->defaultStringFormat && $this->getDatabase() && $this->getDatabase()->getDefaultStringFormat()) {
return $this->getDatabase()->getDefaultStringFormat();
}
return $this->defaultStringFormat;
} | php | public function getDefaultStringFormat()
{
if (!$this->defaultStringFormat && $this->getDatabase() && $this->getDatabase()->getDefaultStringFormat()) {
return $this->getDatabase()->getDefaultStringFormat();
}
return $this->defaultStringFormat;
} | [
"public",
"function",
"getDefaultStringFormat",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"defaultStringFormat",
"&&",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"&&",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getDefaultStringFormat",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getDefaultStringFormat",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"defaultStringFormat",
";",
"}"
] | Get the default string format for ActiveRecord objects in this Table,
or the one for the whole database if not set.
@return string The default string representation | [
"Get",
"the",
"default",
"string",
"format",
"for",
"ActiveRecord",
"objects",
"in",
"this",
"Table",
"or",
"the",
"one",
"for",
"the",
"whole",
"database",
"if",
"not",
"set",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1373-L1380 |
propelorm/Propel | generator/lib/model/Table.php | Table.getNumLazyLoadColumns | public function getNumLazyLoadColumns()
{
$count = 0;
foreach ($this->columnList as $col) {
if ($col->isLazyLoad()) {
$count++;
}
}
return $count;
} | php | public function getNumLazyLoadColumns()
{
$count = 0;
foreach ($this->columnList as $col) {
if ($col->isLazyLoad()) {
$count++;
}
}
return $count;
} | [
"public",
"function",
"getNumLazyLoadColumns",
"(",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"columnList",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isLazyLoad",
"(",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] | Utility method to get the number of columns in this table | [
"Utility",
"method",
"to",
"get",
"the",
"number",
"of",
"columns",
"in",
"this",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1570-L1580 |
propelorm/Propel | generator/lib/model/Table.php | Table.hasEnumColumns | public function hasEnumColumns()
{
foreach ($this->getColumns() as $col) {
if ($col->isEnumType() || $col->getValueSet()) {
return true;
}
}
return false;
} | php | public function hasEnumColumns()
{
foreach ($this->getColumns() as $col) {
if ($col->isEnumType() || $col->getValueSet()) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasEnumColumns",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isEnumType",
"(",
")",
"||",
"$",
"col",
"->",
"getValueSet",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks whether one of the columns is of type ENUM
@return boolean | [
"Checks",
"whether",
"one",
"of",
"the",
"columns",
"is",
"of",
"type",
"ENUM"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1587-L1597 |
propelorm/Propel | generator/lib/model/Table.php | Table.hasColumn | public function hasColumn($col, $caseInsensitive = false)
{
if ($col instanceof Column) {
$col = $col->getName();
}
if ($caseInsensitive) {
return array_key_exists(strtolower($col), $this->columnsByLowercaseName);
} else {
return array_key_exists($col, $this->columnsByName);
}
} | php | public function hasColumn($col, $caseInsensitive = false)
{
if ($col instanceof Column) {
$col = $col->getName();
}
if ($caseInsensitive) {
return array_key_exists(strtolower($col), $this->columnsByLowercaseName);
} else {
return array_key_exists($col, $this->columnsByName);
}
} | [
"public",
"function",
"hasColumn",
"(",
"$",
"col",
",",
"$",
"caseInsensitive",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"col",
"instanceof",
"Column",
")",
"{",
"$",
"col",
"=",
"$",
"col",
"->",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"$",
"caseInsensitive",
")",
"{",
"return",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"col",
")",
",",
"$",
"this",
"->",
"columnsByLowercaseName",
")",
";",
"}",
"else",
"{",
"return",
"array_key_exists",
"(",
"$",
"col",
",",
"$",
"this",
"->",
"columnsByName",
")",
";",
"}",
"}"
] | Check whether the table has a column.
@param Column|string $col the column object or name (e.g. 'my_column')
@param boolean $caseInsensitive Whether the check is case insensitive. False by default.
@return boolean | [
"Check",
"whether",
"the",
"table",
"has",
"a",
"column",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1656-L1666 |
propelorm/Propel | generator/lib/model/Table.php | Table.getForeignKeysReferencingTable | public function getForeignKeysReferencingTable($tablename)
{
$matches = array();
$keys = $this->getForeignKeys();
foreach ($keys as $fk) {
if ($fk->getForeignTableName() === $tablename) {
$matches[] = $fk;
}
}
return $matches;
} | php | public function getForeignKeysReferencingTable($tablename)
{
$matches = array();
$keys = $this->getForeignKeys();
foreach ($keys as $fk) {
if ($fk->getForeignTableName() === $tablename) {
$matches[] = $fk;
}
}
return $matches;
} | [
"public",
"function",
"getForeignKeysReferencingTable",
"(",
"$",
"tablename",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"keys",
"=",
"$",
"this",
"->",
"getForeignKeys",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"fk",
")",
"{",
"if",
"(",
"$",
"fk",
"->",
"getForeignTableName",
"(",
")",
"===",
"$",
"tablename",
")",
"{",
"$",
"matches",
"[",
"]",
"=",
"$",
"fk",
";",
"}",
"}",
"return",
"$",
"matches",
";",
"}"
] | Get all the foreign keys from this table to the specified table.
@return array ForeignKey[] | [
"Get",
"all",
"the",
"foreign",
"keys",
"from",
"this",
"table",
"to",
"the",
"specified",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1708-L1719 |
propelorm/Propel | generator/lib/model/Table.php | Table.appendXml | public function appendXml(DOMNode $node)
{
$doc = ($node instanceof DOMDocument) ? $node : $node->ownerDocument;
$tableNode = $node->appendChild($doc->createElement('table'));
$tableNode->setAttribute('name', $this->getCommonName());
if ($this->getSchema() !== null) {
$tableNode->setAttribute('schema', $this->getSchema());
}
if ($this->phpName !== null) {
$tableNode->setAttribute('phpName', $this->phpName);
}
if ($this->idMethod !== null) {
$tableNode->setAttribute('idMethod', $this->idMethod);
}
if ($this->skipSql !== null) {
$tableNode->setAttribute('skipSql', var_export($this->skipSql, true));
}
if ($this->readOnly !== null) {
$tableNode->setAttribute('readOnly', var_export($this->readOnly, true));
}
if ($this->treeMode !== null) {
$tableNode->setAttribute('treeMode', $this->treeMode);
}
if ($this->reloadOnInsert !== null) {
$tableNode->setAttribute('reloadOnInsert', var_export($this->reloadOnInsert, true));
}
if ($this->reloadOnUpdate !== null) {
$tableNode->setAttribute('reloadOnUpdate', var_export($this->reloadOnUpdate, true));
}
if ($this->forReferenceOnly !== null) {
$tableNode->setAttribute('forReferenceOnly', var_export($this->forReferenceOnly, true));
}
if ($this->abstractValue !== null) {
$tableNode->setAttribute('abstract', var_export($this->abstractValue, true));
}
if ($this->interface !== null) {
$tableNode->setAttribute('interface', $this->interface);
}
if ($this->description !== null) {
$tableNode->setAttribute('description', $this->description);
}
if ($this->namespace !== null) {
$tableNode->setAttribute('namespace', $this->namespace);
}
if ($this->pkg !== null && !$this->pkgOverridden) {
$tableNode->setAttribute('package', $this->pkg);
}
if ($this->baseClass !== null) {
$tableNode->setAttribute('baseClass', $this->baseClass);
}
if ($this->basePeer !== null) {
$tableNode->setAttribute('basePeer', $this->basePeer);
}
if ($this->getIsCrossRef()) {
$tableNode->setAttribute('isCrossRef', $this->getIsCrossRef());
}
foreach ($this->columnList as $col) {
$col->appendXml($tableNode);
}
foreach ($this->validatorList as $validator) {
$validator->appendXml($tableNode);
}
foreach ($this->foreignKeys as $fk) {
$fk->appendXml($tableNode);
}
foreach ($this->idMethodParameters as $param) {
$param->appendXml($tableNode);
}
foreach ($this->indices as $index) {
$index->appendXml($tableNode);
}
foreach ($this->unices as $unique) {
$unique->appendXml($tableNode);
}
foreach ($this->vendorInfos as $vi) {
$vi->appendXml($tableNode);
}
} | php | public function appendXml(DOMNode $node)
{
$doc = ($node instanceof DOMDocument) ? $node : $node->ownerDocument;
$tableNode = $node->appendChild($doc->createElement('table'));
$tableNode->setAttribute('name', $this->getCommonName());
if ($this->getSchema() !== null) {
$tableNode->setAttribute('schema', $this->getSchema());
}
if ($this->phpName !== null) {
$tableNode->setAttribute('phpName', $this->phpName);
}
if ($this->idMethod !== null) {
$tableNode->setAttribute('idMethod', $this->idMethod);
}
if ($this->skipSql !== null) {
$tableNode->setAttribute('skipSql', var_export($this->skipSql, true));
}
if ($this->readOnly !== null) {
$tableNode->setAttribute('readOnly', var_export($this->readOnly, true));
}
if ($this->treeMode !== null) {
$tableNode->setAttribute('treeMode', $this->treeMode);
}
if ($this->reloadOnInsert !== null) {
$tableNode->setAttribute('reloadOnInsert', var_export($this->reloadOnInsert, true));
}
if ($this->reloadOnUpdate !== null) {
$tableNode->setAttribute('reloadOnUpdate', var_export($this->reloadOnUpdate, true));
}
if ($this->forReferenceOnly !== null) {
$tableNode->setAttribute('forReferenceOnly', var_export($this->forReferenceOnly, true));
}
if ($this->abstractValue !== null) {
$tableNode->setAttribute('abstract', var_export($this->abstractValue, true));
}
if ($this->interface !== null) {
$tableNode->setAttribute('interface', $this->interface);
}
if ($this->description !== null) {
$tableNode->setAttribute('description', $this->description);
}
if ($this->namespace !== null) {
$tableNode->setAttribute('namespace', $this->namespace);
}
if ($this->pkg !== null && !$this->pkgOverridden) {
$tableNode->setAttribute('package', $this->pkg);
}
if ($this->baseClass !== null) {
$tableNode->setAttribute('baseClass', $this->baseClass);
}
if ($this->basePeer !== null) {
$tableNode->setAttribute('basePeer', $this->basePeer);
}
if ($this->getIsCrossRef()) {
$tableNode->setAttribute('isCrossRef', $this->getIsCrossRef());
}
foreach ($this->columnList as $col) {
$col->appendXml($tableNode);
}
foreach ($this->validatorList as $validator) {
$validator->appendXml($tableNode);
}
foreach ($this->foreignKeys as $fk) {
$fk->appendXml($tableNode);
}
foreach ($this->idMethodParameters as $param) {
$param->appendXml($tableNode);
}
foreach ($this->indices as $index) {
$index->appendXml($tableNode);
}
foreach ($this->unices as $unique) {
$unique->appendXml($tableNode);
}
foreach ($this->vendorInfos as $vi) {
$vi->appendXml($tableNode);
}
} | [
"public",
"function",
"appendXml",
"(",
"DOMNode",
"$",
"node",
")",
"{",
"$",
"doc",
"=",
"(",
"$",
"node",
"instanceof",
"DOMDocument",
")",
"?",
"$",
"node",
":",
"$",
"node",
"->",
"ownerDocument",
";",
"$",
"tableNode",
"=",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"doc",
"->",
"createElement",
"(",
"'table'",
")",
")",
";",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'name'",
",",
"$",
"this",
"->",
"getCommonName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getSchema",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'schema'",
",",
"$",
"this",
"->",
"getSchema",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"phpName",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'phpName'",
",",
"$",
"this",
"->",
"phpName",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"idMethod",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'idMethod'",
",",
"$",
"this",
"->",
"idMethod",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"skipSql",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'skipSql'",
",",
"var_export",
"(",
"$",
"this",
"->",
"skipSql",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"readOnly",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'readOnly'",
",",
"var_export",
"(",
"$",
"this",
"->",
"readOnly",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"treeMode",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'treeMode'",
",",
"$",
"this",
"->",
"treeMode",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"reloadOnInsert",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'reloadOnInsert'",
",",
"var_export",
"(",
"$",
"this",
"->",
"reloadOnInsert",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"reloadOnUpdate",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'reloadOnUpdate'",
",",
"var_export",
"(",
"$",
"this",
"->",
"reloadOnUpdate",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"forReferenceOnly",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'forReferenceOnly'",
",",
"var_export",
"(",
"$",
"this",
"->",
"forReferenceOnly",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"abstractValue",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'abstract'",
",",
"var_export",
"(",
"$",
"this",
"->",
"abstractValue",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"interface",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'interface'",
",",
"$",
"this",
"->",
"interface",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"description",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'description'",
",",
"$",
"this",
"->",
"description",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"namespace",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'namespace'",
",",
"$",
"this",
"->",
"namespace",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pkg",
"!==",
"null",
"&&",
"!",
"$",
"this",
"->",
"pkgOverridden",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'package'",
",",
"$",
"this",
"->",
"pkg",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"baseClass",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'baseClass'",
",",
"$",
"this",
"->",
"baseClass",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"basePeer",
"!==",
"null",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'basePeer'",
",",
"$",
"this",
"->",
"basePeer",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getIsCrossRef",
"(",
")",
")",
"{",
"$",
"tableNode",
"->",
"setAttribute",
"(",
"'isCrossRef'",
",",
"$",
"this",
"->",
"getIsCrossRef",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"columnList",
"as",
"$",
"col",
")",
"{",
"$",
"col",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"validatorList",
"as",
"$",
"validator",
")",
"{",
"$",
"validator",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"foreignKeys",
"as",
"$",
"fk",
")",
"{",
"$",
"fk",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"idMethodParameters",
"as",
"$",
"param",
")",
"{",
"$",
"param",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"indices",
"as",
"$",
"index",
")",
"{",
"$",
"index",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"unices",
"as",
"$",
"unique",
")",
"{",
"$",
"unique",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"vendorInfos",
"as",
"$",
"vi",
")",
"{",
"$",
"vi",
"->",
"appendXml",
"(",
"$",
"tableNode",
")",
";",
"}",
"}"
] | Appends XML nodes to passed-in DOMNode.
@param DOMNode $node | [
"Appends",
"XML",
"nodes",
"to",
"passed",
"-",
"in",
"DOMNode",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1821-L1923 |
propelorm/Propel | generator/lib/model/Table.php | Table.getPrimaryKey | public function getPrimaryKey()
{
$pk = array();
foreach ($this->columnList as $col) {
if ($col->isPrimaryKey()) {
$pk[] = $col;
}
}
return $pk;
} | php | public function getPrimaryKey()
{
$pk = array();
foreach ($this->columnList as $col) {
if ($col->isPrimaryKey()) {
$pk[] = $col;
}
}
return $pk;
} | [
"public",
"function",
"getPrimaryKey",
"(",
")",
"{",
"$",
"pk",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columnList",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isPrimaryKey",
"(",
")",
")",
"{",
"$",
"pk",
"[",
"]",
"=",
"$",
"col",
";",
"}",
"}",
"return",
"$",
"pk",
";",
"}"
] | Returns the collection of Columns which make up the single primary
key for this table.
@return Column[] A list of the primary key parts. | [
"Returns",
"the",
"collection",
"of",
"Columns",
"which",
"make",
"up",
"the",
"single",
"primary",
"key",
"for",
"this",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1931-L1941 |
propelorm/Propel | generator/lib/model/Table.php | Table.hasAutoIncrementPrimaryKey | public function hasAutoIncrementPrimaryKey()
{
if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) {
$pks = $this->getPrimaryKey();
foreach ($pks as $pk) {
if ($pk->isAutoIncrement()) {
return true;
}
}
}
return false;
} | php | public function hasAutoIncrementPrimaryKey()
{
if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) {
$pks = $this->getPrimaryKey();
foreach ($pks as $pk) {
if ($pk->isAutoIncrement()) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"hasAutoIncrementPrimaryKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIdMethod",
"(",
")",
"!=",
"IDMethod",
"::",
"NO_ID_METHOD",
")",
"{",
"$",
"pks",
"=",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
";",
"foreach",
"(",
"$",
"pks",
"as",
"$",
"pk",
")",
"{",
"if",
"(",
"$",
"pk",
"->",
"isAutoIncrement",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Determine whether this table has any auto-increment primary key(s).
@return boolean Whether this table has a non-"none" id method and has a primary key column that is auto-increment. | [
"Determine",
"whether",
"this",
"table",
"has",
"any",
"auto",
"-",
"increment",
"primary",
"key",
"(",
"s",
")",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L1981-L1993 |
propelorm/Propel | generator/lib/model/Table.php | Table.getAutoIncrementPrimaryKey | public function getAutoIncrementPrimaryKey()
{
if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) {
$pks = $this->getPrimaryKey();
foreach ($pks as $pk) {
if ($pk->isAutoIncrement()) {
return $pk;
}
}
}
return null;
} | php | public function getAutoIncrementPrimaryKey()
{
if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) {
$pks = $this->getPrimaryKey();
foreach ($pks as $pk) {
if ($pk->isAutoIncrement()) {
return $pk;
}
}
}
return null;
} | [
"public",
"function",
"getAutoIncrementPrimaryKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIdMethod",
"(",
")",
"!=",
"IDMethod",
"::",
"NO_ID_METHOD",
")",
"{",
"$",
"pks",
"=",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
";",
"foreach",
"(",
"$",
"pks",
"as",
"$",
"pk",
")",
"{",
"if",
"(",
"$",
"pk",
"->",
"isAutoIncrement",
"(",
")",
")",
"{",
"return",
"$",
"pk",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Gets the auto increment PK
@return Column|null | [
"Gets",
"the",
"auto",
"increment",
"PK"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L2000-L2012 |
propelorm/Propel | generator/lib/model/Table.php | Table.printList | private function printList($list)
{
$result = "";
$comma = 0;
for ($i = 0, $_i = count($list); $i < $_i; $i++) {
$col = $list[$i];
if ($col->isPrimaryKey()) {
$result .= ($comma++ ? ',' : '') . $this->getDatabase()->getPlatform()->quoteIdentifier($col->getName());
}
}
return $result;
} | php | private function printList($list)
{
$result = "";
$comma = 0;
for ($i = 0, $_i = count($list); $i < $_i; $i++) {
$col = $list[$i];
if ($col->isPrimaryKey()) {
$result .= ($comma++ ? ',' : '') . $this->getDatabase()->getPlatform()->quoteIdentifier($col->getName());
}
}
return $result;
} | [
"private",
"function",
"printList",
"(",
"$",
"list",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"$",
"comma",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"_i",
"=",
"count",
"(",
"$",
"list",
")",
";",
"$",
"i",
"<",
"$",
"_i",
";",
"$",
"i",
"++",
")",
"{",
"$",
"col",
"=",
"$",
"list",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"col",
"->",
"isPrimaryKey",
"(",
")",
")",
"{",
"$",
"result",
".=",
"(",
"$",
"comma",
"++",
"?",
"','",
":",
"''",
")",
".",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getPlatform",
"(",
")",
"->",
"quoteIdentifier",
"(",
"$",
"col",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the elements of the list, separated by commas.
@param array $list
@return A CSV list.
@deprecated Use the Platform::getColumnListDDL() method. | [
"Returns",
"the",
"elements",
"of",
"the",
"list",
"separated",
"by",
"commas",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Table.php#L2053-L2065 |
propelorm/Propel | generator/lib/model/Domain.php | Domain.copy | public function copy(Domain $domain)
{
$this->defaultValue = $domain->getDefaultValue();
$this->description = $domain->getDescription();
$this->name = $domain->getName();
$this->scale = $domain->getScale();
$this->size = $domain->getSize();
$this->sqlType = $domain->getSqlType();
$this->propelType = $domain->getType();
} | php | public function copy(Domain $domain)
{
$this->defaultValue = $domain->getDefaultValue();
$this->description = $domain->getDescription();
$this->name = $domain->getName();
$this->scale = $domain->getScale();
$this->size = $domain->getSize();
$this->sqlType = $domain->getSqlType();
$this->propelType = $domain->getType();
} | [
"public",
"function",
"copy",
"(",
"Domain",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"defaultValue",
"=",
"$",
"domain",
"->",
"getDefaultValue",
"(",
")",
";",
"$",
"this",
"->",
"description",
"=",
"$",
"domain",
"->",
"getDescription",
"(",
")",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"domain",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"scale",
"=",
"$",
"domain",
"->",
"getScale",
"(",
")",
";",
"$",
"this",
"->",
"size",
"=",
"$",
"domain",
"->",
"getSize",
"(",
")",
";",
"$",
"this",
"->",
"sqlType",
"=",
"$",
"domain",
"->",
"getSqlType",
"(",
")",
";",
"$",
"this",
"->",
"propelType",
"=",
"$",
"domain",
"->",
"getType",
"(",
")",
";",
"}"
] | Copy the values from current object into passed-in Domain.
@param Domain $domain Domain to copy values into. | [
"Copy",
"the",
"values",
"from",
"current",
"object",
"into",
"passed",
"-",
"in",
"Domain",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Domain.php#L86-L95 |
propelorm/Propel | generator/lib/model/Domain.php | Domain.setupObject | protected function setupObject()
{
$schemaType = strtoupper($this->getAttribute("type"));
$this->copy($this->getDatabase()->getPlatform()->getDomainForType($schemaType));
//Name
$this->name = $this->getAttribute("name");
// Default value
$defval = $this->getAttribute("defaultValue", $this->getAttribute("default"));
if ($defval !== null) {
$this->setDefaultValue(new ColumnDefaultValue($defval, ColumnDefaultValue::TYPE_VALUE));
} elseif ($this->getAttribute("defaultExpr") !== null) {
$this->setDefaultValue(new ColumnDefaultValue($this->getAttribute("defaultExpr"), ColumnDefaultValue::TYPE_EXPR));
}
$this->size = $this->getAttribute("size");
$this->scale = $this->getAttribute("scale");
$this->description = $this->getAttribute("description");
} | php | protected function setupObject()
{
$schemaType = strtoupper($this->getAttribute("type"));
$this->copy($this->getDatabase()->getPlatform()->getDomainForType($schemaType));
//Name
$this->name = $this->getAttribute("name");
// Default value
$defval = $this->getAttribute("defaultValue", $this->getAttribute("default"));
if ($defval !== null) {
$this->setDefaultValue(new ColumnDefaultValue($defval, ColumnDefaultValue::TYPE_VALUE));
} elseif ($this->getAttribute("defaultExpr") !== null) {
$this->setDefaultValue(new ColumnDefaultValue($this->getAttribute("defaultExpr"), ColumnDefaultValue::TYPE_EXPR));
}
$this->size = $this->getAttribute("size");
$this->scale = $this->getAttribute("scale");
$this->description = $this->getAttribute("description");
} | [
"protected",
"function",
"setupObject",
"(",
")",
"{",
"$",
"schemaType",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"type\"",
")",
")",
";",
"$",
"this",
"->",
"copy",
"(",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"->",
"getPlatform",
"(",
")",
"->",
"getDomainForType",
"(",
"$",
"schemaType",
")",
")",
";",
"//Name",
"$",
"this",
"->",
"name",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"name\"",
")",
";",
"// Default value",
"$",
"defval",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultValue\"",
",",
"$",
"this",
"->",
"getAttribute",
"(",
"\"default\"",
")",
")",
";",
"if",
"(",
"$",
"defval",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setDefaultValue",
"(",
"new",
"ColumnDefaultValue",
"(",
"$",
"defval",
",",
"ColumnDefaultValue",
"::",
"TYPE_VALUE",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultExpr\"",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setDefaultValue",
"(",
"new",
"ColumnDefaultValue",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"\"defaultExpr\"",
")",
",",
"ColumnDefaultValue",
"::",
"TYPE_EXPR",
")",
")",
";",
"}",
"$",
"this",
"->",
"size",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"size\"",
")",
";",
"$",
"this",
"->",
"scale",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"scale\"",
")",
";",
"$",
"this",
"->",
"description",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"description\"",
")",
";",
"}"
] | Sets up the Domain object based on the attributes that were passed to loadFromXML().
@see parent::loadFromXML() | [
"Sets",
"up",
"the",
"Domain",
"object",
"based",
"on",
"the",
"attributes",
"that",
"were",
"passed",
"to",
"loadFromXML",
"()",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Domain.php#L102-L121 |
propelorm/Propel | generator/lib/model/Domain.php | Domain.getPhpDefaultValue | public function getPhpDefaultValue()
{
if ($this->defaultValue === null) {
return null;
}
if ($this->defaultValue->isExpression()) {
throw new EngineException("Cannot get PHP version of default value for default value EXPRESSION.");
}
if ($this->propelType === PropelTypes::BOOLEAN || $this->propelType === PropelTypes::BOOLEAN_EMU) {
return $this->booleanValue($this->defaultValue->getValue());
}
if (PropelTypes::PHP_ARRAY === $this->propelType) {
return $this->getDefaultValueForArray($this->defaultValue->getValue());
}
return $this->defaultValue->getValue();
} | php | public function getPhpDefaultValue()
{
if ($this->defaultValue === null) {
return null;
}
if ($this->defaultValue->isExpression()) {
throw new EngineException("Cannot get PHP version of default value for default value EXPRESSION.");
}
if ($this->propelType === PropelTypes::BOOLEAN || $this->propelType === PropelTypes::BOOLEAN_EMU) {
return $this->booleanValue($this->defaultValue->getValue());
}
if (PropelTypes::PHP_ARRAY === $this->propelType) {
return $this->getDefaultValueForArray($this->defaultValue->getValue());
}
return $this->defaultValue->getValue();
} | [
"public",
"function",
"getPhpDefaultValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"defaultValue",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"defaultValue",
"->",
"isExpression",
"(",
")",
")",
"{",
"throw",
"new",
"EngineException",
"(",
"\"Cannot get PHP version of default value for default value EXPRESSION.\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"propelType",
"===",
"PropelTypes",
"::",
"BOOLEAN",
"||",
"$",
"this",
"->",
"propelType",
"===",
"PropelTypes",
"::",
"BOOLEAN_EMU",
")",
"{",
"return",
"$",
"this",
"->",
"booleanValue",
"(",
"$",
"this",
"->",
"defaultValue",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"PropelTypes",
"::",
"PHP_ARRAY",
"===",
"$",
"this",
"->",
"propelType",
")",
"{",
"return",
"$",
"this",
"->",
"getDefaultValueForArray",
"(",
"$",
"this",
"->",
"defaultValue",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"defaultValue",
"->",
"getValue",
"(",
")",
";",
"}"
] | Gets the default value, type-casted for use in PHP OM.
@return mixed
@see getDefaultValue()
@throws EngineException | [
"Gets",
"the",
"default",
"value",
"type",
"-",
"casted",
"for",
"use",
"in",
"PHP",
"OM",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Domain.php#L276-L295 |
propelorm/Propel | generator/lib/model/Domain.php | Domain.printSize | public function printSize()
{
if ($this->size !== null && $this->scale !== null) {
return '(' . $this->size . ',' . $this->scale . ')';
} elseif ($this->size !== null) {
return '(' . $this->size . ')';
} else {
return "";
}
} | php | public function printSize()
{
if ($this->size !== null && $this->scale !== null) {
return '(' . $this->size . ',' . $this->scale . ')';
} elseif ($this->size !== null) {
return '(' . $this->size . ')';
} else {
return "";
}
} | [
"public",
"function",
"printSize",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"size",
"!==",
"null",
"&&",
"$",
"this",
"->",
"scale",
"!==",
"null",
")",
"{",
"return",
"'('",
".",
"$",
"this",
"->",
"size",
".",
"','",
".",
"$",
"this",
"->",
"scale",
".",
"')'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"size",
"!==",
"null",
")",
"{",
"return",
"'('",
".",
"$",
"this",
"->",
"size",
".",
"')'",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] | Return the size and scale in brackets for use in an sql schema.
@return string Size and scale or an empty String if there are no values
available. | [
"Return",
"the",
"size",
"and",
"scale",
"in",
"brackets",
"for",
"use",
"in",
"an",
"sql",
"schema",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Domain.php#L351-L360 |
propelorm/Propel | runtime/lib/util/PropelModelPager.php | PropelModelPager.getResults | public function getResults()
{
if (null === $this->results) {
$this->results = $this->getQuery()
->find($this->con);
}
return $this->results;
} | php | public function getResults()
{
if (null === $this->results) {
$this->results = $this->getQuery()
->find($this->con);
}
return $this->results;
} | [
"public",
"function",
"getResults",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"results",
")",
"{",
"$",
"this",
"->",
"results",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
"->",
"find",
"(",
"$",
"this",
"->",
"con",
")",
";",
"}",
"return",
"$",
"this",
"->",
"results",
";",
"}"
] | Get the collection of results in the page
@return PropelCollection A collection of results | [
"Get",
"the",
"collection",
"of",
"results",
"in",
"the",
"page"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelModelPager.php#L97-L105 |
propelorm/Propel | runtime/lib/util/PropelModelPager.php | PropelModelPager.getLastIndex | public function getLastIndex()
{
if ($this->page == 0) {
return $this->nbResults;
} else {
if (($this->page * $this->maxPerPage) >= $this->nbResults) {
return $this->nbResults;
} else {
return ($this->page * $this->maxPerPage);
}
}
} | php | public function getLastIndex()
{
if ($this->page == 0) {
return $this->nbResults;
} else {
if (($this->page * $this->maxPerPage) >= $this->nbResults) {
return $this->nbResults;
} else {
return ($this->page * $this->maxPerPage);
}
}
} | [
"public",
"function",
"getLastIndex",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"page",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"nbResults",
";",
"}",
"else",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"page",
"*",
"$",
"this",
"->",
"maxPerPage",
")",
">=",
"$",
"this",
"->",
"nbResults",
")",
"{",
"return",
"$",
"this",
"->",
"nbResults",
";",
"}",
"else",
"{",
"return",
"(",
"$",
"this",
"->",
"page",
"*",
"$",
"this",
"->",
"maxPerPage",
")",
";",
"}",
"}",
"}"
] | Get the index of the last element in the page
Always less than or equal to $maxPerPage
@return int | [
"Get",
"the",
"index",
"of",
"the",
"last",
"element",
"in",
"the",
"page",
"Always",
"less",
"than",
"or",
"equal",
"to",
"$maxPerPage"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelModelPager.php#L171-L182 |
propelorm/Propel | generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php | AggregateColumnBehavior.modifyTable | public function modifyTable()
{
$table = $this->getTable();
if (!$columnName = $this->getParameter('name')) {
throw new InvalidArgumentException(sprintf('You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $table->getName()));
}
// add the aggregate column if not present
if (!$this->getTable()->containsColumn($columnName)) {
$column = $this->getTable()->addColumn(array(
'name' => $columnName,
'type' => 'INTEGER',
));
}
// add a behavior in the foreign table to autoupdate the aggregate column
$foreignTable = $this->getForeignTable();
if (!$foreignTable->hasBehavior('concrete_inheritance_parent')) {
$relationBehavior = new AggregateColumnRelationBehavior();
$relationBehavior->setName('aggregate_column_relation');
$foreignKey = $this->getForeignKey();
$relationBehavior->addParameter(array('name' => 'foreign_table', 'value' => $table->getName()));
$relationBehavior->addParameter(array('name' => 'update_method', 'value' => 'update' . $this->getColumn()->getPhpName()));
$foreignTable->addBehavior($relationBehavior);
}
} | php | public function modifyTable()
{
$table = $this->getTable();
if (!$columnName = $this->getParameter('name')) {
throw new InvalidArgumentException(sprintf('You must define a \'name\' parameter for the \'aggregate_column\' behavior in the \'%s\' table', $table->getName()));
}
// add the aggregate column if not present
if (!$this->getTable()->containsColumn($columnName)) {
$column = $this->getTable()->addColumn(array(
'name' => $columnName,
'type' => 'INTEGER',
));
}
// add a behavior in the foreign table to autoupdate the aggregate column
$foreignTable = $this->getForeignTable();
if (!$foreignTable->hasBehavior('concrete_inheritance_parent')) {
$relationBehavior = new AggregateColumnRelationBehavior();
$relationBehavior->setName('aggregate_column_relation');
$foreignKey = $this->getForeignKey();
$relationBehavior->addParameter(array('name' => 'foreign_table', 'value' => $table->getName()));
$relationBehavior->addParameter(array('name' => 'update_method', 'value' => 'update' . $this->getColumn()->getPhpName()));
$foreignTable->addBehavior($relationBehavior);
}
} | [
"public",
"function",
"modifyTable",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"columnName",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'name'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'You must define a \\'name\\' parameter for the \\'aggregate_column\\' behavior in the \\'%s\\' table'",
",",
"$",
"table",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"// add the aggregate column if not present",
"if",
"(",
"!",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"containsColumn",
"(",
"$",
"columnName",
")",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"addColumn",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"columnName",
",",
"'type'",
"=>",
"'INTEGER'",
",",
")",
")",
";",
"}",
"// add a behavior in the foreign table to autoupdate the aggregate column",
"$",
"foreignTable",
"=",
"$",
"this",
"->",
"getForeignTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"foreignTable",
"->",
"hasBehavior",
"(",
"'concrete_inheritance_parent'",
")",
")",
"{",
"$",
"relationBehavior",
"=",
"new",
"AggregateColumnRelationBehavior",
"(",
")",
";",
"$",
"relationBehavior",
"->",
"setName",
"(",
"'aggregate_column_relation'",
")",
";",
"$",
"foreignKey",
"=",
"$",
"this",
"->",
"getForeignKey",
"(",
")",
";",
"$",
"relationBehavior",
"->",
"addParameter",
"(",
"array",
"(",
"'name'",
"=>",
"'foreign_table'",
",",
"'value'",
"=>",
"$",
"table",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"relationBehavior",
"->",
"addParameter",
"(",
"array",
"(",
"'name'",
"=>",
"'update_method'",
",",
"'value'",
"=>",
"'update'",
".",
"$",
"this",
"->",
"getColumn",
"(",
")",
"->",
"getPhpName",
"(",
")",
")",
")",
";",
"$",
"foreignTable",
"->",
"addBehavior",
"(",
"$",
"relationBehavior",
")",
";",
"}",
"}"
] | Add the aggregate key to the current table | [
"Add",
"the",
"aggregate",
"key",
"to",
"the",
"current",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/aggregate_column/AggregateColumnBehavior.php#L35-L60 |
propelorm/Propel | runtime/lib/parser/yaml/sfYamlInline.php | sfYamlInline.load | public static function load($value)
{
$value = trim($value);
if (0 == strlen($value)) {
return '';
}
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
switch ($value[0]) {
case '[':
$result = self::parseSequence($value);
break;
case '{':
$result = self::parseMapping($value);
break;
default:
$result = self::parseScalar($value);
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
return $result;
} | php | public static function load($value)
{
$value = trim($value);
if (0 == strlen($value)) {
return '';
}
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
switch ($value[0]) {
case '[':
$result = self::parseSequence($value);
break;
case '{':
$result = self::parseMapping($value);
break;
default:
$result = self::parseScalar($value);
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
return $result;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"if",
"(",
"0",
"==",
"strlen",
"(",
"$",
"value",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"function_exists",
"(",
"'mb_internal_encoding'",
")",
"&&",
"(",
"(",
"int",
")",
"ini_get",
"(",
"'mbstring.func_overload'",
")",
")",
"&",
"2",
")",
"{",
"$",
"mbEncoding",
"=",
"mb_internal_encoding",
"(",
")",
";",
"mb_internal_encoding",
"(",
"'ASCII'",
")",
";",
"}",
"switch",
"(",
"$",
"value",
"[",
"0",
"]",
")",
"{",
"case",
"'['",
":",
"$",
"result",
"=",
"self",
"::",
"parseSequence",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'{'",
":",
"$",
"result",
"=",
"self",
"::",
"parseMapping",
"(",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"$",
"result",
"=",
"self",
"::",
"parseScalar",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"mbEncoding",
")",
")",
"{",
"mb_internal_encoding",
"(",
"$",
"mbEncoding",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Convert a YAML string to a PHP array.
@param string $value A YAML string
@return array A PHP array representing the YAML string | [
"Convert",
"a",
"YAML",
"string",
"to",
"a",
"PHP",
"array",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlInline.php#L32-L61 |
propelorm/Propel | runtime/lib/parser/yaml/sfYamlInline.php | sfYamlInline.dumpArray | protected static function dumpArray($value)
{
// array
$keys = array_keys($value);
if (
(1 == count($keys) && '0' == $keys[0])
||
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
{
$output = array();
foreach ($value as $val) {
$output[] = self::dump($val);
}
return sprintf('[%s]', implode(', ', $output));
}
// mapping
$output = array();
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key), self::dump($val));
}
return sprintf('{ %s }', implode(', ', $output));
} | php | protected static function dumpArray($value)
{
// array
$keys = array_keys($value);
if (
(1 == count($keys) && '0' == $keys[0])
||
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
{
$output = array();
foreach ($value as $val) {
$output[] = self::dump($val);
}
return sprintf('[%s]', implode(', ', $output));
}
// mapping
$output = array();
foreach ($value as $key => $val) {
$output[] = sprintf('%s: %s', self::dump($key), self::dump($val));
}
return sprintf('{ %s }', implode(', ', $output));
} | [
"protected",
"static",
"function",
"dumpArray",
"(",
"$",
"value",
")",
"{",
"// array",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"value",
")",
";",
"if",
"(",
"(",
"1",
"==",
"count",
"(",
"$",
"keys",
")",
"&&",
"'0'",
"==",
"$",
"keys",
"[",
"0",
"]",
")",
"||",
"(",
"count",
"(",
"$",
"keys",
")",
">",
"1",
"&&",
"array_reduce",
"(",
"$",
"keys",
",",
"create_function",
"(",
"'$v,$w'",
",",
"'return (integer) $v + $w;'",
")",
",",
"0",
")",
"==",
"count",
"(",
"$",
"keys",
")",
"*",
"(",
"count",
"(",
"$",
"keys",
")",
"-",
"1",
")",
"/",
"2",
")",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"self",
"::",
"dump",
"(",
"$",
"val",
")",
";",
"}",
"return",
"sprintf",
"(",
"'[%s]'",
",",
"implode",
"(",
"', '",
",",
"$",
"output",
")",
")",
";",
"}",
"// mapping",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"sprintf",
"(",
"'%s: %s'",
",",
"self",
"::",
"dump",
"(",
"$",
"key",
")",
",",
"self",
"::",
"dump",
"(",
"$",
"val",
")",
")",
";",
"}",
"return",
"sprintf",
"(",
"'{ %s }'",
",",
"implode",
"(",
"', '",
",",
"$",
"output",
")",
")",
";",
"}"
] | Dumps a PHP array to a YAML string.
@param array $value The PHP array to dump
@return string The YAML string representing the PHP array | [
"Dumps",
"a",
"PHP",
"array",
"to",
"a",
"YAML",
"string",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlInline.php#L123-L147 |
propelorm/Propel | runtime/lib/parser/yaml/sfYamlInline.php | sfYamlInline.parseQuotedScalar | protected static function parseQuotedScalar($scalar, &$i)
{
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
}
$output = substr($match[0], 1, strlen($match[0]) - 2);
if ('"' == $scalar[$i]) {
// evaluate the string
$output = str_replace(array('\\"', '\\n', '\\r'), array('"', "\n", "\r"), $output);
} else {
// unescape '
$output = str_replace('\'\'', '\'', $output);
}
$i += strlen($match[0]);
return $output;
} | php | protected static function parseQuotedScalar($scalar, &$i)
{
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
throw new InvalidArgumentException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
}
$output = substr($match[0], 1, strlen($match[0]) - 2);
if ('"' == $scalar[$i]) {
// evaluate the string
$output = str_replace(array('\\"', '\\n', '\\r'), array('"', "\n", "\r"), $output);
} else {
// unescape '
$output = str_replace('\'\'', '\'', $output);
}
$i += strlen($match[0]);
return $output;
} | [
"protected",
"static",
"function",
"parseQuotedScalar",
"(",
"$",
"scalar",
",",
"&",
"$",
"i",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/'",
".",
"self",
"::",
"REGEX_QUOTED_STRING",
".",
"'/Au'",
",",
"substr",
"(",
"$",
"scalar",
",",
"$",
"i",
")",
",",
"$",
"match",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Malformed inline YAML string (%s).'",
",",
"substr",
"(",
"$",
"scalar",
",",
"$",
"i",
")",
")",
")",
";",
"}",
"$",
"output",
"=",
"substr",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"1",
",",
"strlen",
"(",
"$",
"match",
"[",
"0",
"]",
")",
"-",
"2",
")",
";",
"if",
"(",
"'\"'",
"==",
"$",
"scalar",
"[",
"$",
"i",
"]",
")",
"{",
"// evaluate the string",
"$",
"output",
"=",
"str_replace",
"(",
"array",
"(",
"'\\\\\"'",
",",
"'\\\\n'",
",",
"'\\\\r'",
")",
",",
"array",
"(",
"'\"'",
",",
"\"\\n\"",
",",
"\"\\r\"",
")",
",",
"$",
"output",
")",
";",
"}",
"else",
"{",
"// unescape '",
"$",
"output",
"=",
"str_replace",
"(",
"'\\'\\''",
",",
"'\\''",
",",
"$",
"output",
")",
";",
"}",
"$",
"i",
"+=",
"strlen",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Parses a quoted scalar to YAML.
@param string $scalar
@param integer $i
@return string A YAML string | [
"Parses",
"a",
"quoted",
"scalar",
"to",
"YAML",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlInline.php#L196-L215 |
propelorm/Propel | runtime/lib/parser/yaml/sfYamlInline.php | sfYamlInline.parseSequence | protected static function parseSequence($sequence, &$i = 0)
{
$output = array();
$len = strlen($sequence);
$i += 1;
// [foo, bar, ...]
while ($i < $len) {
switch ($sequence[$i]) {
case '[':
// nested sequence
$output[] = self::parseSequence($sequence, $i);
break;
case '{':
// nested mapping
$output[] = self::parseMapping($sequence, $i);
break;
case ']':
return $output;
case ',':
case ' ':
break;
default:
$isQuoted = in_array($sequence[$i], array('"', "'"));
$value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);
if (!$isQuoted && false !== strpos($value, ': ')) {
// embedded mapping?
try {
$value = self::parseMapping('{'.$value.'}');
} catch (InvalidArgumentException $e) {
// no, it's not
}
}
$output[] = $value;
--$i;
}
++$i;
}
throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence));
} | php | protected static function parseSequence($sequence, &$i = 0)
{
$output = array();
$len = strlen($sequence);
$i += 1;
// [foo, bar, ...]
while ($i < $len) {
switch ($sequence[$i]) {
case '[':
// nested sequence
$output[] = self::parseSequence($sequence, $i);
break;
case '{':
// nested mapping
$output[] = self::parseMapping($sequence, $i);
break;
case ']':
return $output;
case ',':
case ' ':
break;
default:
$isQuoted = in_array($sequence[$i], array('"', "'"));
$value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);
if (!$isQuoted && false !== strpos($value, ': ')) {
// embedded mapping?
try {
$value = self::parseMapping('{'.$value.'}');
} catch (InvalidArgumentException $e) {
// no, it's not
}
}
$output[] = $value;
--$i;
}
++$i;
}
throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence));
} | [
"protected",
"static",
"function",
"parseSequence",
"(",
"$",
"sequence",
",",
"&",
"$",
"i",
"=",
"0",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"sequence",
")",
";",
"$",
"i",
"+=",
"1",
";",
"// [foo, bar, ...]",
"while",
"(",
"$",
"i",
"<",
"$",
"len",
")",
"{",
"switch",
"(",
"$",
"sequence",
"[",
"$",
"i",
"]",
")",
"{",
"case",
"'['",
":",
"// nested sequence",
"$",
"output",
"[",
"]",
"=",
"self",
"::",
"parseSequence",
"(",
"$",
"sequence",
",",
"$",
"i",
")",
";",
"break",
";",
"case",
"'{'",
":",
"// nested mapping",
"$",
"output",
"[",
"]",
"=",
"self",
"::",
"parseMapping",
"(",
"$",
"sequence",
",",
"$",
"i",
")",
";",
"break",
";",
"case",
"']'",
":",
"return",
"$",
"output",
";",
"case",
"','",
":",
"case",
"' '",
":",
"break",
";",
"default",
":",
"$",
"isQuoted",
"=",
"in_array",
"(",
"$",
"sequence",
"[",
"$",
"i",
"]",
",",
"array",
"(",
"'\"'",
",",
"\"'\"",
")",
")",
";",
"$",
"value",
"=",
"self",
"::",
"parseScalar",
"(",
"$",
"sequence",
",",
"array",
"(",
"','",
",",
"']'",
")",
",",
"array",
"(",
"'\"'",
",",
"\"'\"",
")",
",",
"$",
"i",
")",
";",
"if",
"(",
"!",
"$",
"isQuoted",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"value",
",",
"': '",
")",
")",
"{",
"// embedded mapping?",
"try",
"{",
"$",
"value",
"=",
"self",
"::",
"parseMapping",
"(",
"'{'",
".",
"$",
"value",
".",
"'}'",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"// no, it's not",
"}",
"}",
"$",
"output",
"[",
"]",
"=",
"$",
"value",
";",
"--",
"$",
"i",
";",
"}",
"++",
"$",
"i",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Malformed inline YAML string %s'",
",",
"$",
"sequence",
")",
")",
";",
"}"
] | Parses a sequence to a YAML string.
@param string $sequence
@param integer $i
@return string A YAML string | [
"Parses",
"a",
"sequence",
"to",
"a",
"YAML",
"string",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlInline.php#L225-L269 |
propelorm/Propel | generator/lib/behavior/sortable/SortableBehavior.php | SortableBehavior.modifyTable | public function modifyTable()
{
$table = $this->getTable();
if (!$table->containsColumn($this->getParameter('rank_column'))) {
$table->addColumn(array(
'name' => $this->getParameter('rank_column'),
'type' => 'INTEGER'
));
}
if ($this->useScope() && !$this->hasMultipleScopes() &&
!$table->containsColumn($this->getParameter('scope_column'))) {
$table->addColumn(array(
'name' => $this->getParameter('scope_column'),
'type' => 'INTEGER'
));
}
if ($this->useScope()) {
$scopes = $this->getScopes();
if (0 === count($scopes)) {
throw new \InvalidArgumentException(sprintf(
'The sortable behavior in `%s` needs a `scope_column` parameter.',
$this->getTable()->getName()
));
}
foreach ($scopes as $scope) {
$keys = $table->getColumnForeignKeys($scope);
foreach ($keys as $key) {
if ($key->isForeignPrimaryKey() && $key->getOnDelete() == ForeignKey::SETNULL) {
$foreignTable = $key->getForeignTable();
$relationBehavior = new SortableRelationBehavior();
$relationBehavior->addParameter(array('name' => 'foreign_table', 'value' => $table->getName()));
$relationBehavior->addParameter(array('name' => 'foreign_scope_column', 'value' => $scope));
$relationBehavior->addParameter(array('name' => 'foreign_rank_column', 'value' => $this->getParameter('rank_column')));
$foreignTable->addBehavior($relationBehavior);
}
}
}
}
} | php | public function modifyTable()
{
$table = $this->getTable();
if (!$table->containsColumn($this->getParameter('rank_column'))) {
$table->addColumn(array(
'name' => $this->getParameter('rank_column'),
'type' => 'INTEGER'
));
}
if ($this->useScope() && !$this->hasMultipleScopes() &&
!$table->containsColumn($this->getParameter('scope_column'))) {
$table->addColumn(array(
'name' => $this->getParameter('scope_column'),
'type' => 'INTEGER'
));
}
if ($this->useScope()) {
$scopes = $this->getScopes();
if (0 === count($scopes)) {
throw new \InvalidArgumentException(sprintf(
'The sortable behavior in `%s` needs a `scope_column` parameter.',
$this->getTable()->getName()
));
}
foreach ($scopes as $scope) {
$keys = $table->getColumnForeignKeys($scope);
foreach ($keys as $key) {
if ($key->isForeignPrimaryKey() && $key->getOnDelete() == ForeignKey::SETNULL) {
$foreignTable = $key->getForeignTable();
$relationBehavior = new SortableRelationBehavior();
$relationBehavior->addParameter(array('name' => 'foreign_table', 'value' => $table->getName()));
$relationBehavior->addParameter(array('name' => 'foreign_scope_column', 'value' => $scope));
$relationBehavior->addParameter(array('name' => 'foreign_rank_column', 'value' => $this->getParameter('rank_column')));
$foreignTable->addBehavior($relationBehavior);
}
}
}
}
} | [
"public",
"function",
"modifyTable",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"table",
"->",
"containsColumn",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'rank_column'",
")",
")",
")",
"{",
"$",
"table",
"->",
"addColumn",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'rank_column'",
")",
",",
"'type'",
"=>",
"'INTEGER'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"useScope",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"hasMultipleScopes",
"(",
")",
"&&",
"!",
"$",
"table",
"->",
"containsColumn",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'scope_column'",
")",
")",
")",
"{",
"$",
"table",
"->",
"addColumn",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'scope_column'",
")",
",",
"'type'",
"=>",
"'INTEGER'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"useScope",
"(",
")",
")",
"{",
"$",
"scopes",
"=",
"$",
"this",
"->",
"getScopes",
"(",
")",
";",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"scopes",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The sortable behavior in `%s` needs a `scope_column` parameter.'",
",",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"scopes",
"as",
"$",
"scope",
")",
"{",
"$",
"keys",
"=",
"$",
"table",
"->",
"getColumnForeignKeys",
"(",
"$",
"scope",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"->",
"isForeignPrimaryKey",
"(",
")",
"&&",
"$",
"key",
"->",
"getOnDelete",
"(",
")",
"==",
"ForeignKey",
"::",
"SETNULL",
")",
"{",
"$",
"foreignTable",
"=",
"$",
"key",
"->",
"getForeignTable",
"(",
")",
";",
"$",
"relationBehavior",
"=",
"new",
"SortableRelationBehavior",
"(",
")",
";",
"$",
"relationBehavior",
"->",
"addParameter",
"(",
"array",
"(",
"'name'",
"=>",
"'foreign_table'",
",",
"'value'",
"=>",
"$",
"table",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"relationBehavior",
"->",
"addParameter",
"(",
"array",
"(",
"'name'",
"=>",
"'foreign_scope_column'",
",",
"'value'",
"=>",
"$",
"scope",
")",
")",
";",
"$",
"relationBehavior",
"->",
"addParameter",
"(",
"array",
"(",
"'name'",
"=>",
"'foreign_rank_column'",
",",
"'value'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'rank_column'",
")",
")",
")",
";",
"$",
"foreignTable",
"->",
"addBehavior",
"(",
"$",
"relationBehavior",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Add the rank_column to the current table | [
"Add",
"the",
"rank_column",
"to",
"the",
"current",
"table"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/sortable/SortableBehavior.php#L39-L79 |
propelorm/Propel | generator/lib/behavior/sortable/SortableBehavior.php | SortableBehavior.addParameter | public function addParameter($attribute)
{
if ('scope_column' === $attribute['name']) {
$this->parameters['scope_column'] .= ($this->parameters['scope_column'] ? ',' : '') . $attribute['value'];
} else {
parent::addParameter($attribute);
}
} | php | public function addParameter($attribute)
{
if ('scope_column' === $attribute['name']) {
$this->parameters['scope_column'] .= ($this->parameters['scope_column'] ? ',' : '') . $attribute['value'];
} else {
parent::addParameter($attribute);
}
} | [
"public",
"function",
"addParameter",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"'scope_column'",
"===",
"$",
"attribute",
"[",
"'name'",
"]",
")",
"{",
"$",
"this",
"->",
"parameters",
"[",
"'scope_column'",
"]",
".=",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'scope_column'",
"]",
"?",
"','",
":",
"''",
")",
".",
"$",
"attribute",
"[",
"'value'",
"]",
";",
"}",
"else",
"{",
"parent",
"::",
"addParameter",
"(",
"$",
"attribute",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/sortable/SortableBehavior.php#L159-L166 |
propelorm/Propel | generator/lib/builder/om/PHP5TableMapBuilder.php | PHP5TableMapBuilder.addClassOpen | protected function addClassOpen(&$script)
{
$table = $this->getTable();
$script .= "
/**
* This class defines the structure of the '" . $table->getName() . "' table.
*
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
}
$script .= "
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator." . $this->getPackage() . "
*/
class " . $this->getClassname() . " extends TableMap
{
";
} | php | protected function addClassOpen(&$script)
{
$table = $this->getTable();
$script .= "
/**
* This class defines the structure of the '" . $table->getName() . "' table.
*
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
}
$script .= "
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package propel.generator." . $this->getPackage() . "
*/
class " . $this->getClassname() . " extends TableMap
{
";
} | [
"protected",
"function",
"addClassOpen",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"script",
".=",
"\"\n\n/**\n * This class defines the structure of the '\"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
".",
"\"' table.\n *\n *\"",
";",
"if",
"(",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'addTimeStamp'",
")",
")",
"{",
"$",
"now",
"=",
"strftime",
"(",
"'%c'",
")",
";",
"$",
"script",
".=",
"\"\n * This class was autogenerated by Propel \"",
".",
"$",
"this",
"->",
"getBuildProperty",
"(",
"'version'",
")",
".",
"\" on:\n *\n * $now\n *\"",
";",
"}",
"$",
"script",
".=",
"\"\n *\n * This map class is used by Propel to do runtime db structure discovery.\n * For example, the createSelectSql() method checks the type of a given column used in an\n * ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive\n * (i.e. if it's a text column type).\n *\n * @package propel.generator.\"",
".",
"$",
"this",
"->",
"getPackage",
"(",
")",
".",
"\"\n */\nclass \"",
".",
"$",
"this",
"->",
"getClassname",
"(",
")",
".",
"\" extends TableMap\n{\n\"",
";",
"}"
] | Adds class phpdoc comment and opening of class.
@param string &$script The script will be modified in this method. | [
"Adds",
"class",
"phpdoc",
"comment",
"and",
"opening",
"of",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5TableMapBuilder.php#L67-L96 |
propelorm/Propel | generator/lib/builder/om/PHP5TableMapBuilder.php | PHP5TableMapBuilder.addClassBody | protected function addClassBody(&$script)
{
$this->declareClasses('TableMap', 'RelationMap');
$this->addConstants($script);
$this->addAttributes($script);
$this->addInitialize($script);
$this->addBuildRelations($script);
$this->addGetBehaviors($script);
} | php | protected function addClassBody(&$script)
{
$this->declareClasses('TableMap', 'RelationMap');
$this->addConstants($script);
$this->addAttributes($script);
$this->addInitialize($script);
$this->addBuildRelations($script);
$this->addGetBehaviors($script);
} | [
"protected",
"function",
"addClassBody",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"this",
"->",
"declareClasses",
"(",
"'TableMap'",
",",
"'RelationMap'",
")",
";",
"$",
"this",
"->",
"addConstants",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addAttributes",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addInitialize",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addBuildRelations",
"(",
"$",
"script",
")",
";",
"$",
"this",
"->",
"addGetBehaviors",
"(",
"$",
"script",
")",
";",
"}"
] | Specifies the methods that are added as part of the map builder class.
This can be overridden by subclasses that wish to add more methods.
@see ObjectBuilder::addClassBody() | [
"Specifies",
"the",
"methods",
"that",
"are",
"added",
"as",
"part",
"of",
"the",
"map",
"builder",
"class",
".",
"This",
"can",
"be",
"overridden",
"by",
"subclasses",
"that",
"wish",
"to",
"add",
"more",
"methods",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5TableMapBuilder.php#L104-L112 |
propelorm/Propel | generator/lib/builder/om/PHP5TableMapBuilder.php | PHP5TableMapBuilder.addInitialize | protected function addInitialize(&$script)
{
$table = $this->getTable();
$platform = $this->getPlatform();
$script .= "
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
\$this->setName('" . $table->getName() . "');
\$this->setPhpName('" . $table->getPhpName() . "');
\$this->setClassname('" . addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassname()) . "');
\$this->setPackage('" . parent::getPackage() . "');";
if ($table->getIdMethod() == "native") {
$script .= "
\$this->setUseIdGenerator(true);";
} else {
$script .= "
\$this->setUseIdGenerator(false);";
}
if ($table->getIdMethodParameters()) {
$params = $table->getIdMethodParameters();
$imp = $params[0];
$script .= "
\$this->setPrimaryKeyMethodInfo('" . $imp->getValue() . "');";
} elseif ($table->getIdMethod() == IDMethod::NATIVE && ($platform->getNativeIdMethod() == PropelPlatformInterface::SEQUENCE || $platform->getNativeIdMethod() == PropelPlatformInterface::SERIAL)) {
$script .= "
\$this->setPrimaryKeyMethodInfo('" . $platform->getSequenceName($table) . "');";
}
if ($this->getTable()->getChildrenColumn()) {
$script .= "
\$this->setSingleTableInheritance(true);";
}
if ($this->getTable()->getIsCrossRef()) {
$script .= "
\$this->setIsCrossRef(true);";
}
// Add columns to map
$script .= "
// columns";
foreach ($table->getColumns() as $col) {
$cup = $col->getName();
$cfc = $col->getPhpName();
if (!$col->getSize()) {
$size = "null";
} else {
$size = $col->getSize();
}
$default = $col->getDefaultValueString();
if ($col->isPrimaryKey()) {
if ($col->isForeignKey()) {
foreach ($col->getForeignKeys() as $fk) {
$script .= "
\$this->addForeignPrimaryKey('$cup', '$cfc', '" . $col->getType() . "' , '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", $default);";
}
} else {
$script .= "
\$this->addPrimaryKey('$cup', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", $default);";
}
} else {
if ($col->isForeignKey()) {
foreach ($col->getForeignKeys() as $fk) {
$script .= "
\$this->addForeignKey('$cup', '$cfc', '" . $col->getType() . "', '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", $default);";
}
} else {
$script .= "
\$this->addColumn('$cup', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", $default);";
}
} // if col-is prim key
if ($col->getValueSet()) {
$script .= "
\$this->getColumn('$cup', false)->setValueSet(" . var_export($col->getValueSet(), true) . ");";
}
if ($col->isPrimaryString()) {
$script .= "
\$this->getColumn('$cup', false)->setPrimaryString(true);";
}
} // foreach
// validators
$script .= "
// validators";
foreach ($table->getValidators() as $val) {
$col = $val->getColumn();
$cup = $col->getName();
foreach ($val->getRules() as $rule) {
if ($val->getTranslate() !== Validator::TRANSLATE_NONE) {
$script .= "
\$this->addValidator('$cup', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\'", $rule->getValue()) . "', " . $val->getTranslate() . "('" . str_replace("'", "\'", $rule->getMessage()) . "'));";
} else {
$script .= "
\$this->addValidator('$cup', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\'", $rule->getValue()) . "', '" . str_replace("'", "\'", $rule->getMessage()) . "');";
} // if ($rule->getTranslation() ...
} // foreach rule
} // foreach validator
$script .= "
} // initialize()
";
} | php | protected function addInitialize(&$script)
{
$table = $this->getTable();
$platform = $this->getPlatform();
$script .= "
/**
* Initialize the table attributes, columns and validators
* Relations are not initialized by this method since they are lazy loaded
*
* @return void
* @throws PropelException
*/
public function initialize()
{
// attributes
\$this->setName('" . $table->getName() . "');
\$this->setPhpName('" . $table->getPhpName() . "');
\$this->setClassname('" . addslashes($this->getStubObjectBuilder()->getFullyQualifiedClassname()) . "');
\$this->setPackage('" . parent::getPackage() . "');";
if ($table->getIdMethod() == "native") {
$script .= "
\$this->setUseIdGenerator(true);";
} else {
$script .= "
\$this->setUseIdGenerator(false);";
}
if ($table->getIdMethodParameters()) {
$params = $table->getIdMethodParameters();
$imp = $params[0];
$script .= "
\$this->setPrimaryKeyMethodInfo('" . $imp->getValue() . "');";
} elseif ($table->getIdMethod() == IDMethod::NATIVE && ($platform->getNativeIdMethod() == PropelPlatformInterface::SEQUENCE || $platform->getNativeIdMethod() == PropelPlatformInterface::SERIAL)) {
$script .= "
\$this->setPrimaryKeyMethodInfo('" . $platform->getSequenceName($table) . "');";
}
if ($this->getTable()->getChildrenColumn()) {
$script .= "
\$this->setSingleTableInheritance(true);";
}
if ($this->getTable()->getIsCrossRef()) {
$script .= "
\$this->setIsCrossRef(true);";
}
// Add columns to map
$script .= "
// columns";
foreach ($table->getColumns() as $col) {
$cup = $col->getName();
$cfc = $col->getPhpName();
if (!$col->getSize()) {
$size = "null";
} else {
$size = $col->getSize();
}
$default = $col->getDefaultValueString();
if ($col->isPrimaryKey()) {
if ($col->isForeignKey()) {
foreach ($col->getForeignKeys() as $fk) {
$script .= "
\$this->addForeignPrimaryKey('$cup', '$cfc', '" . $col->getType() . "' , '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", $default);";
}
} else {
$script .= "
\$this->addPrimaryKey('$cup', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", $default);";
}
} else {
if ($col->isForeignKey()) {
foreach ($col->getForeignKeys() as $fk) {
$script .= "
\$this->addForeignKey('$cup', '$cfc', '" . $col->getType() . "', '" . $fk->getForeignTableName() . "', '" . $fk->getMappedForeignColumn($col->getName()) . "', " . ($col->isNotNull() ? 'true' : 'false') . ", " . $size . ", $default);";
}
} else {
$script .= "
\$this->addColumn('$cup', '$cfc', '" . $col->getType() . "', " . var_export($col->isNotNull(), true) . ", " . $size . ", $default);";
}
} // if col-is prim key
if ($col->getValueSet()) {
$script .= "
\$this->getColumn('$cup', false)->setValueSet(" . var_export($col->getValueSet(), true) . ");";
}
if ($col->isPrimaryString()) {
$script .= "
\$this->getColumn('$cup', false)->setPrimaryString(true);";
}
} // foreach
// validators
$script .= "
// validators";
foreach ($table->getValidators() as $val) {
$col = $val->getColumn();
$cup = $col->getName();
foreach ($val->getRules() as $rule) {
if ($val->getTranslate() !== Validator::TRANSLATE_NONE) {
$script .= "
\$this->addValidator('$cup', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\'", $rule->getValue()) . "', " . $val->getTranslate() . "('" . str_replace("'", "\'", $rule->getMessage()) . "'));";
} else {
$script .= "
\$this->addValidator('$cup', '" . $rule->getName() . "', '" . $rule->getClass() . "', '" . str_replace("'", "\'", $rule->getValue()) . "', '" . str_replace("'", "\'", $rule->getMessage()) . "');";
} // if ($rule->getTranslation() ...
} // foreach rule
} // foreach validator
$script .= "
} // initialize()
";
} | [
"protected",
"function",
"addInitialize",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"platform",
"=",
"$",
"this",
"->",
"getPlatform",
"(",
")",
";",
"$",
"script",
".=",
"\"\n /**\n * Initialize the table attributes, columns and validators\n * Relations are not initialized by this method since they are lazy loaded\n *\n * @return void\n * @throws PropelException\n */\n public function initialize()\n {\n // attributes\n \\$this->setName('\"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
".",
"\"');\n \\$this->setPhpName('\"",
".",
"$",
"table",
"->",
"getPhpName",
"(",
")",
".",
"\"');\n \\$this->setClassname('\"",
".",
"addslashes",
"(",
"$",
"this",
"->",
"getStubObjectBuilder",
"(",
")",
"->",
"getFullyQualifiedClassname",
"(",
")",
")",
".",
"\"');\n \\$this->setPackage('\"",
".",
"parent",
"::",
"getPackage",
"(",
")",
".",
"\"');\"",
";",
"if",
"(",
"$",
"table",
"->",
"getIdMethod",
"(",
")",
"==",
"\"native\"",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->setUseIdGenerator(true);\"",
";",
"}",
"else",
"{",
"$",
"script",
".=",
"\"\n \\$this->setUseIdGenerator(false);\"",
";",
"}",
"if",
"(",
"$",
"table",
"->",
"getIdMethodParameters",
"(",
")",
")",
"{",
"$",
"params",
"=",
"$",
"table",
"->",
"getIdMethodParameters",
"(",
")",
";",
"$",
"imp",
"=",
"$",
"params",
"[",
"0",
"]",
";",
"$",
"script",
".=",
"\"\n \\$this->setPrimaryKeyMethodInfo('\"",
".",
"$",
"imp",
"->",
"getValue",
"(",
")",
".",
"\"');\"",
";",
"}",
"elseif",
"(",
"$",
"table",
"->",
"getIdMethod",
"(",
")",
"==",
"IDMethod",
"::",
"NATIVE",
"&&",
"(",
"$",
"platform",
"->",
"getNativeIdMethod",
"(",
")",
"==",
"PropelPlatformInterface",
"::",
"SEQUENCE",
"||",
"$",
"platform",
"->",
"getNativeIdMethod",
"(",
")",
"==",
"PropelPlatformInterface",
"::",
"SERIAL",
")",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->setPrimaryKeyMethodInfo('\"",
".",
"$",
"platform",
"->",
"getSequenceName",
"(",
"$",
"table",
")",
".",
"\"');\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getChildrenColumn",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->setSingleTableInheritance(true);\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getIsCrossRef",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->setIsCrossRef(true);\"",
";",
"}",
"// Add columns to map",
"$",
"script",
".=",
"\"\n // columns\"",
";",
"foreach",
"(",
"$",
"table",
"->",
"getColumns",
"(",
")",
"as",
"$",
"col",
")",
"{",
"$",
"cup",
"=",
"$",
"col",
"->",
"getName",
"(",
")",
";",
"$",
"cfc",
"=",
"$",
"col",
"->",
"getPhpName",
"(",
")",
";",
"if",
"(",
"!",
"$",
"col",
"->",
"getSize",
"(",
")",
")",
"{",
"$",
"size",
"=",
"\"null\"",
";",
"}",
"else",
"{",
"$",
"size",
"=",
"$",
"col",
"->",
"getSize",
"(",
")",
";",
"}",
"$",
"default",
"=",
"$",
"col",
"->",
"getDefaultValueString",
"(",
")",
";",
"if",
"(",
"$",
"col",
"->",
"isPrimaryKey",
"(",
")",
")",
"{",
"if",
"(",
"$",
"col",
"->",
"isForeignKey",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"col",
"->",
"getForeignKeys",
"(",
")",
"as",
"$",
"fk",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->addForeignPrimaryKey('$cup', '$cfc', '\"",
".",
"$",
"col",
"->",
"getType",
"(",
")",
".",
"\"' , '\"",
".",
"$",
"fk",
"->",
"getForeignTableName",
"(",
")",
".",
"\"', '\"",
".",
"$",
"fk",
"->",
"getMappedForeignColumn",
"(",
"$",
"col",
"->",
"getName",
"(",
")",
")",
".",
"\"', \"",
".",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
"?",
"'true'",
":",
"'false'",
")",
".",
"\", \"",
".",
"$",
"size",
".",
"\", $default);\"",
";",
"}",
"}",
"else",
"{",
"$",
"script",
".=",
"\"\n \\$this->addPrimaryKey('$cup', '$cfc', '\"",
".",
"$",
"col",
"->",
"getType",
"(",
")",
".",
"\"', \"",
".",
"var_export",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
",",
"true",
")",
".",
"\", \"",
".",
"$",
"size",
".",
"\", $default);\"",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"col",
"->",
"isForeignKey",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"col",
"->",
"getForeignKeys",
"(",
")",
"as",
"$",
"fk",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->addForeignKey('$cup', '$cfc', '\"",
".",
"$",
"col",
"->",
"getType",
"(",
")",
".",
"\"', '\"",
".",
"$",
"fk",
"->",
"getForeignTableName",
"(",
")",
".",
"\"', '\"",
".",
"$",
"fk",
"->",
"getMappedForeignColumn",
"(",
"$",
"col",
"->",
"getName",
"(",
")",
")",
".",
"\"', \"",
".",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
"?",
"'true'",
":",
"'false'",
")",
".",
"\", \"",
".",
"$",
"size",
".",
"\", $default);\"",
";",
"}",
"}",
"else",
"{",
"$",
"script",
".=",
"\"\n \\$this->addColumn('$cup', '$cfc', '\"",
".",
"$",
"col",
"->",
"getType",
"(",
")",
".",
"\"', \"",
".",
"var_export",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
",",
"true",
")",
".",
"\", \"",
".",
"$",
"size",
".",
"\", $default);\"",
";",
"}",
"}",
"// if col-is prim key",
"if",
"(",
"$",
"col",
"->",
"getValueSet",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->getColumn('$cup', false)->setValueSet(\"",
".",
"var_export",
"(",
"$",
"col",
"->",
"getValueSet",
"(",
")",
",",
"true",
")",
".",
"\");\"",
";",
"}",
"if",
"(",
"$",
"col",
"->",
"isPrimaryString",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->getColumn('$cup', false)->setPrimaryString(true);\"",
";",
"}",
"}",
"// foreach",
"// validators",
"$",
"script",
".=",
"\"\n // validators\"",
";",
"foreach",
"(",
"$",
"table",
"->",
"getValidators",
"(",
")",
"as",
"$",
"val",
")",
"{",
"$",
"col",
"=",
"$",
"val",
"->",
"getColumn",
"(",
")",
";",
"$",
"cup",
"=",
"$",
"col",
"->",
"getName",
"(",
")",
";",
"foreach",
"(",
"$",
"val",
"->",
"getRules",
"(",
")",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"val",
"->",
"getTranslate",
"(",
")",
"!==",
"Validator",
"::",
"TRANSLATE_NONE",
")",
"{",
"$",
"script",
".=",
"\"\n \\$this->addValidator('$cup', '\"",
".",
"$",
"rule",
"->",
"getName",
"(",
")",
".",
"\"', '\"",
".",
"$",
"rule",
"->",
"getClass",
"(",
")",
".",
"\"', '\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"rule",
"->",
"getValue",
"(",
")",
")",
".",
"\"', \"",
".",
"$",
"val",
"->",
"getTranslate",
"(",
")",
".",
"\"('\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"rule",
"->",
"getMessage",
"(",
")",
")",
".",
"\"'));\"",
";",
"}",
"else",
"{",
"$",
"script",
".=",
"\"\n \\$this->addValidator('$cup', '\"",
".",
"$",
"rule",
"->",
"getName",
"(",
")",
".",
"\"', '\"",
".",
"$",
"rule",
"->",
"getClass",
"(",
")",
".",
"\"', '\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"rule",
"->",
"getValue",
"(",
")",
")",
".",
"\"', '\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"rule",
"->",
"getMessage",
"(",
")",
")",
".",
"\"');\"",
";",
"}",
"// if ($rule->getTranslation() ...",
"}",
"// foreach rule",
"}",
"// foreach validator",
"$",
"script",
".=",
"\"\n } // initialize()\n\"",
";",
"}"
] | Adds the addInitialize() method to the table map class.
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"addInitialize",
"()",
"method",
"to",
"the",
"table",
"map",
"class",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5TableMapBuilder.php#L156-L268 |
propelorm/Propel | generator/lib/builder/om/PHP5TableMapBuilder.php | PHP5TableMapBuilder.addBuildRelations | protected function addBuildRelations(&$script)
{
$script .= "
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{";
foreach ($this->getTable()->getForeignKeys() as $fkey) {
$columnMapping = 'array(';
foreach ($fkey->getLocalForeignMapping() as $key => $value) {
$columnMapping .= "'$key' => '$value', ";
}
$columnMapping .= ')';
$onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null';
$onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null';
$script .= "
\$this->addRelation('" . $this->getFKPhpNameAffix($fkey) . "', '" . addslashes($this->getNewStubObjectBuilder($fkey->getForeignTable())->getFullyQualifiedClassname()) . "', RelationMap::MANY_TO_ONE, $columnMapping, $onDelete, $onUpdate);";
}
foreach ($this->getTable()->getReferrers() as $fkey) {
$relationName = $this->getRefFKPhpNameAffix($fkey);
$columnMapping = 'array(';
foreach ($fkey->getForeignLocalMapping() as $key => $value) {
$columnMapping .= "'$key' => '$value', ";
}
$columnMapping .= ')';
$onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null';
$onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null';
$script .= "
\$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($fkey->getTable())->getFullyQualifiedClassname()) . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") . ", $columnMapping, $onDelete, $onUpdate";
if ($fkey->isLocalPrimaryKey()) {
$script .= ");";
} else {
$script .= ", '" . $this->getRefFKPhpNameAffix($fkey, true) . "');";
}
}
foreach ($this->getTable()->getCrossFks() as $fkList) {
list($refFK, $crossFK) = $fkList;
$relationName = $this->getFKPhpNameAffix($crossFK);
$pluralName = "'" . $this->getFKPhpNameAffix($crossFK, true) . "'";
$onDelete = $crossFK->hasOnDelete() ? "'" . $crossFK->getOnDelete() . "'" : 'null';
$onUpdate = $crossFK->hasOnUpdate() ? "'" . $crossFK->getOnUpdate() . "'" : 'null';
$script .= "
\$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($crossFK->getForeignTable())->getFullyQualifiedClassname()) . "', RelationMap::MANY_TO_MANY, array(), $onDelete, $onUpdate, $pluralName);";
}
$script .= "
} // buildRelations()
";
} | php | protected function addBuildRelations(&$script)
{
$script .= "
/**
* Build the RelationMap objects for this table relationships
*/
public function buildRelations()
{";
foreach ($this->getTable()->getForeignKeys() as $fkey) {
$columnMapping = 'array(';
foreach ($fkey->getLocalForeignMapping() as $key => $value) {
$columnMapping .= "'$key' => '$value', ";
}
$columnMapping .= ')';
$onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null';
$onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null';
$script .= "
\$this->addRelation('" . $this->getFKPhpNameAffix($fkey) . "', '" . addslashes($this->getNewStubObjectBuilder($fkey->getForeignTable())->getFullyQualifiedClassname()) . "', RelationMap::MANY_TO_ONE, $columnMapping, $onDelete, $onUpdate);";
}
foreach ($this->getTable()->getReferrers() as $fkey) {
$relationName = $this->getRefFKPhpNameAffix($fkey);
$columnMapping = 'array(';
foreach ($fkey->getForeignLocalMapping() as $key => $value) {
$columnMapping .= "'$key' => '$value', ";
}
$columnMapping .= ')';
$onDelete = $fkey->hasOnDelete() ? "'" . $fkey->getOnDelete() . "'" : 'null';
$onUpdate = $fkey->hasOnUpdate() ? "'" . $fkey->getOnUpdate() . "'" : 'null';
$script .= "
\$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($fkey->getTable())->getFullyQualifiedClassname()) . "', RelationMap::ONE_TO_" . ($fkey->isLocalPrimaryKey() ? "ONE" : "MANY") . ", $columnMapping, $onDelete, $onUpdate";
if ($fkey->isLocalPrimaryKey()) {
$script .= ");";
} else {
$script .= ", '" . $this->getRefFKPhpNameAffix($fkey, true) . "');";
}
}
foreach ($this->getTable()->getCrossFks() as $fkList) {
list($refFK, $crossFK) = $fkList;
$relationName = $this->getFKPhpNameAffix($crossFK);
$pluralName = "'" . $this->getFKPhpNameAffix($crossFK, true) . "'";
$onDelete = $crossFK->hasOnDelete() ? "'" . $crossFK->getOnDelete() . "'" : 'null';
$onUpdate = $crossFK->hasOnUpdate() ? "'" . $crossFK->getOnUpdate() . "'" : 'null';
$script .= "
\$this->addRelation('$relationName', '" . addslashes($this->getNewStubObjectBuilder($crossFK->getForeignTable())->getFullyQualifiedClassname()) . "', RelationMap::MANY_TO_MANY, array(), $onDelete, $onUpdate, $pluralName);";
}
$script .= "
} // buildRelations()
";
} | [
"protected",
"function",
"addBuildRelations",
"(",
"&",
"$",
"script",
")",
"{",
"$",
"script",
".=",
"\"\n /**\n * Build the RelationMap objects for this table relationships\n */\n public function buildRelations()\n {\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getForeignKeys",
"(",
")",
"as",
"$",
"fkey",
")",
"{",
"$",
"columnMapping",
"=",
"'array('",
";",
"foreach",
"(",
"$",
"fkey",
"->",
"getLocalForeignMapping",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"columnMapping",
".=",
"\"'$key' => '$value', \"",
";",
"}",
"$",
"columnMapping",
".=",
"')'",
";",
"$",
"onDelete",
"=",
"$",
"fkey",
"->",
"hasOnDelete",
"(",
")",
"?",
"\"'\"",
".",
"$",
"fkey",
"->",
"getOnDelete",
"(",
")",
".",
"\"'\"",
":",
"'null'",
";",
"$",
"onUpdate",
"=",
"$",
"fkey",
"->",
"hasOnUpdate",
"(",
")",
"?",
"\"'\"",
".",
"$",
"fkey",
"->",
"getOnUpdate",
"(",
")",
".",
"\"'\"",
":",
"'null'",
";",
"$",
"script",
".=",
"\"\n \\$this->addRelation('\"",
".",
"$",
"this",
"->",
"getFKPhpNameAffix",
"(",
"$",
"fkey",
")",
".",
"\"', '\"",
".",
"addslashes",
"(",
"$",
"this",
"->",
"getNewStubObjectBuilder",
"(",
"$",
"fkey",
"->",
"getForeignTable",
"(",
")",
")",
"->",
"getFullyQualifiedClassname",
"(",
")",
")",
".",
"\"', RelationMap::MANY_TO_ONE, $columnMapping, $onDelete, $onUpdate);\"",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getReferrers",
"(",
")",
"as",
"$",
"fkey",
")",
"{",
"$",
"relationName",
"=",
"$",
"this",
"->",
"getRefFKPhpNameAffix",
"(",
"$",
"fkey",
")",
";",
"$",
"columnMapping",
"=",
"'array('",
";",
"foreach",
"(",
"$",
"fkey",
"->",
"getForeignLocalMapping",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"columnMapping",
".=",
"\"'$key' => '$value', \"",
";",
"}",
"$",
"columnMapping",
".=",
"')'",
";",
"$",
"onDelete",
"=",
"$",
"fkey",
"->",
"hasOnDelete",
"(",
")",
"?",
"\"'\"",
".",
"$",
"fkey",
"->",
"getOnDelete",
"(",
")",
".",
"\"'\"",
":",
"'null'",
";",
"$",
"onUpdate",
"=",
"$",
"fkey",
"->",
"hasOnUpdate",
"(",
")",
"?",
"\"'\"",
".",
"$",
"fkey",
"->",
"getOnUpdate",
"(",
")",
".",
"\"'\"",
":",
"'null'",
";",
"$",
"script",
".=",
"\"\n \\$this->addRelation('$relationName', '\"",
".",
"addslashes",
"(",
"$",
"this",
"->",
"getNewStubObjectBuilder",
"(",
"$",
"fkey",
"->",
"getTable",
"(",
")",
")",
"->",
"getFullyQualifiedClassname",
"(",
")",
")",
".",
"\"', RelationMap::ONE_TO_\"",
".",
"(",
"$",
"fkey",
"->",
"isLocalPrimaryKey",
"(",
")",
"?",
"\"ONE\"",
":",
"\"MANY\"",
")",
".",
"\", $columnMapping, $onDelete, $onUpdate\"",
";",
"if",
"(",
"$",
"fkey",
"->",
"isLocalPrimaryKey",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\");\"",
";",
"}",
"else",
"{",
"$",
"script",
".=",
"\", '\"",
".",
"$",
"this",
"->",
"getRefFKPhpNameAffix",
"(",
"$",
"fkey",
",",
"true",
")",
".",
"\"');\"",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getCrossFks",
"(",
")",
"as",
"$",
"fkList",
")",
"{",
"list",
"(",
"$",
"refFK",
",",
"$",
"crossFK",
")",
"=",
"$",
"fkList",
";",
"$",
"relationName",
"=",
"$",
"this",
"->",
"getFKPhpNameAffix",
"(",
"$",
"crossFK",
")",
";",
"$",
"pluralName",
"=",
"\"'\"",
".",
"$",
"this",
"->",
"getFKPhpNameAffix",
"(",
"$",
"crossFK",
",",
"true",
")",
".",
"\"'\"",
";",
"$",
"onDelete",
"=",
"$",
"crossFK",
"->",
"hasOnDelete",
"(",
")",
"?",
"\"'\"",
".",
"$",
"crossFK",
"->",
"getOnDelete",
"(",
")",
".",
"\"'\"",
":",
"'null'",
";",
"$",
"onUpdate",
"=",
"$",
"crossFK",
"->",
"hasOnUpdate",
"(",
")",
"?",
"\"'\"",
".",
"$",
"crossFK",
"->",
"getOnUpdate",
"(",
")",
".",
"\"'\"",
":",
"'null'",
";",
"$",
"script",
".=",
"\"\n \\$this->addRelation('$relationName', '\"",
".",
"addslashes",
"(",
"$",
"this",
"->",
"getNewStubObjectBuilder",
"(",
"$",
"crossFK",
"->",
"getForeignTable",
"(",
")",
")",
"->",
"getFullyQualifiedClassname",
"(",
")",
")",
".",
"\"', RelationMap::MANY_TO_MANY, array(), $onDelete, $onUpdate, $pluralName);\"",
";",
"}",
"$",
"script",
".=",
"\"\n } // buildRelations()\n\"",
";",
"}"
] | Adds the method that build the RelationMap objects
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"method",
"that",
"build",
"the",
"RelationMap",
"objects"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5TableMapBuilder.php#L275-L323 |
propelorm/Propel | generator/lib/builder/om/PHP5TableMapBuilder.php | PHP5TableMapBuilder.addGetBehaviors | protected function addGetBehaviors(&$script)
{
if ($behaviors = $this->getTable()->getBehaviors()) {
$script .= "
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(";
foreach ($behaviors as $behavior) {
$script .= "
'{$behavior->getName()}' => " . var_export($behavior->getParameters(), true) . ",";
}
$script .= "
);
} // getBehaviors()
";
}
} | php | protected function addGetBehaviors(&$script)
{
if ($behaviors = $this->getTable()->getBehaviors()) {
$script .= "
/**
*
* Gets the list of behaviors registered for this table
*
* @return array Associative array (name => parameters) of behaviors
*/
public function getBehaviors()
{
return array(";
foreach ($behaviors as $behavior) {
$script .= "
'{$behavior->getName()}' => " . var_export($behavior->getParameters(), true) . ",";
}
$script .= "
);
} // getBehaviors()
";
}
} | [
"protected",
"function",
"addGetBehaviors",
"(",
"&",
"$",
"script",
")",
"{",
"if",
"(",
"$",
"behaviors",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getBehaviors",
"(",
")",
")",
"{",
"$",
"script",
".=",
"\"\n /**\n *\n * Gets the list of behaviors registered for this table\n *\n * @return array Associative array (name => parameters) of behaviors\n */\n public function getBehaviors()\n {\n return array(\"",
";",
"foreach",
"(",
"$",
"behaviors",
"as",
"$",
"behavior",
")",
"{",
"$",
"script",
".=",
"\"\n '{$behavior->getName()}' => \"",
".",
"var_export",
"(",
"$",
"behavior",
"->",
"getParameters",
"(",
")",
",",
"true",
")",
".",
"\",\"",
";",
"}",
"$",
"script",
".=",
"\"\n );\n } // getBehaviors()\n\"",
";",
"}",
"}"
] | Adds the behaviors getter
@param string &$script The script will be modified in this method. | [
"Adds",
"the",
"behaviors",
"getter"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5TableMapBuilder.php#L330-L352 |
propelorm/Propel | generator/lib/model/Rule.php | Rule.setupObject | protected function setupObject()
{
$this->name = $this->getAttribute("name");
$this->value = $this->getAttribute("value");
$this->classname = $this->getAttribute("class");
/*
* Set some default values if they are not specified.
* This is especially useful for maxLength; the size
* is already known by the column and this way it is
* not necessary to manage the same size two times.
*
* Currently there is only one such supported default:
* - maxLength value = column max length
* (this default cannot be easily set at runtime w/o changing
* design of class system in undesired ways)
*/
if ($this->value === null) {
switch ($this->name) {
case 'maxLength':
$this->value = $this->validator->getColumn()->getSize();
break;
}
}
$this->message = $this->getAttribute("message");
} | php | protected function setupObject()
{
$this->name = $this->getAttribute("name");
$this->value = $this->getAttribute("value");
$this->classname = $this->getAttribute("class");
/*
* Set some default values if they are not specified.
* This is especially useful for maxLength; the size
* is already known by the column and this way it is
* not necessary to manage the same size two times.
*
* Currently there is only one such supported default:
* - maxLength value = column max length
* (this default cannot be easily set at runtime w/o changing
* design of class system in undesired ways)
*/
if ($this->value === null) {
switch ($this->name) {
case 'maxLength':
$this->value = $this->validator->getColumn()->getSize();
break;
}
}
$this->message = $this->getAttribute("message");
} | [
"protected",
"function",
"setupObject",
"(",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"name\"",
")",
";",
"$",
"this",
"->",
"value",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"value\"",
")",
";",
"$",
"this",
"->",
"classname",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"class\"",
")",
";",
"/*\n * Set some default values if they are not specified.\n * This is especially useful for maxLength; the size\n * is already known by the column and this way it is\n * not necessary to manage the same size two times.\n *\n * Currently there is only one such supported default:\n * - maxLength value = column max length\n * (this default cannot be easily set at runtime w/o changing\n * design of class system in undesired ways)\n */",
"if",
"(",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"name",
")",
"{",
"case",
"'maxLength'",
":",
"$",
"this",
"->",
"value",
"=",
"$",
"this",
"->",
"validator",
"->",
"getColumn",
"(",
")",
"->",
"getSize",
"(",
")",
";",
"break",
";",
"}",
"}",
"$",
"this",
"->",
"message",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"\"message\"",
")",
";",
"}"
] | Sets up the Rule object based on the attributes that were passed to loadFromXML().
@see parent::loadFromXML() | [
"Sets",
"up",
"the",
"Rule",
"object",
"based",
"on",
"the",
"attributes",
"that",
"were",
"passed",
"to",
"loadFromXML",
"()",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Rule.php#L35-L61 |
propelorm/Propel | generator/lib/model/Rule.php | Rule.getClass | public function getClass()
{
if ($this->classname === null && $this->name !== null) {
return "propel.validator." . ucfirst($this->name) . "Validator";
}
return $this->classname;
} | php | public function getClass()
{
if ($this->classname === null && $this->name !== null) {
return "propel.validator." . ucfirst($this->name) . "Validator";
}
return $this->classname;
} | [
"public",
"function",
"getClass",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"classname",
"===",
"null",
"&&",
"$",
"this",
"->",
"name",
"!==",
"null",
")",
"{",
"return",
"\"propel.validator.\"",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"name",
")",
".",
"\"Validator\"",
";",
"}",
"return",
"$",
"this",
"->",
"classname",
";",
"}"
] | Gets the dot-path name of class to use for rule.
If no class was specified, this method will build a default classname
based on the 'name' attribute. E.g. 'maxLength' -> 'propel.validator.MaxLengthValidator'
@return string dot-path classname (e.g. myapp.propel.MyValidator) | [
"Gets",
"the",
"dot",
"-",
"path",
"name",
"of",
"class",
"to",
"use",
"for",
"rule",
".",
"If",
"no",
"class",
"was",
"specified",
"this",
"method",
"will",
"build",
"a",
"default",
"classname",
"based",
"on",
"the",
"name",
"attribute",
".",
"E",
".",
"g",
".",
"maxLength",
"-",
">",
"propel",
".",
"validator",
".",
"MaxLengthValidator"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Rule.php#L104-L111 |
propelorm/Propel | runtime/lib/parser/PropelXMLParser.php | PropelXMLParser.getRootNode | protected function getRootNode($rootElementName = 'data')
{
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->preserveWhiteSpace = false;
$xml->formatOutput = true;
$rootElement = $xml->createElement($rootElementName);
$xml->appendChild($rootElement);
return $rootElement;
} | php | protected function getRootNode($rootElementName = 'data')
{
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->preserveWhiteSpace = false;
$xml->formatOutput = true;
$rootElement = $xml->createElement($rootElementName);
$xml->appendChild($rootElement);
return $rootElement;
} | [
"protected",
"function",
"getRootNode",
"(",
"$",
"rootElementName",
"=",
"'data'",
")",
"{",
"$",
"xml",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"xml",
"->",
"preserveWhiteSpace",
"=",
"false",
";",
"$",
"xml",
"->",
"formatOutput",
"=",
"true",
";",
"$",
"rootElement",
"=",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"rootElementName",
")",
";",
"$",
"xml",
"->",
"appendChild",
"(",
"$",
"rootElement",
")",
";",
"return",
"$",
"rootElement",
";",
"}"
] | Create a DOMDocument and get the root DOMNode using a root element name
@param string $rootElementName The Root Element Name
@return DOMNode The root DOMNode | [
"Create",
"a",
"DOMDocument",
"and",
"get",
"the",
"root",
"DOMNode",
"using",
"a",
"root",
"element",
"name"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/PropelXMLParser.php#L52-L61 |
propelorm/Propel | runtime/lib/parser/PropelXMLParser.php | PropelXMLParser.arrayToDOM | protected function arrayToDOM($array, $rootElement, $charset = null, $removeNumbersFromKeys = false)
{
foreach ($array as $key => $value) {
if ($removeNumbersFromKeys) {
$key = preg_replace('/[^a-z]/i', '', $key);
}
$element = $rootElement->ownerDocument->createElement($key);
if (is_array($value)) {
if (!empty($value)) {
$element = $this->arrayToDOM($value, $element, $charset);
}
} elseif (is_string($value)) {
$charset = $charset ? $charset : 'utf-8';
if (function_exists('iconv') && strcasecmp($charset, 'utf-8') !== 0 && strcasecmp($charset, 'utf8') !== 0) {
$value = iconv($charset, 'UTF-8', $value);
}
$value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
$child = $element->ownerDocument->createCDATASection($value);
$element->appendChild($child);
} else {
$child = $element->ownerDocument->createTextNode($value);
$element->appendChild($child);
}
$rootElement->appendChild($element);
}
return $rootElement;
} | php | protected function arrayToDOM($array, $rootElement, $charset = null, $removeNumbersFromKeys = false)
{
foreach ($array as $key => $value) {
if ($removeNumbersFromKeys) {
$key = preg_replace('/[^a-z]/i', '', $key);
}
$element = $rootElement->ownerDocument->createElement($key);
if (is_array($value)) {
if (!empty($value)) {
$element = $this->arrayToDOM($value, $element, $charset);
}
} elseif (is_string($value)) {
$charset = $charset ? $charset : 'utf-8';
if (function_exists('iconv') && strcasecmp($charset, 'utf-8') !== 0 && strcasecmp($charset, 'utf8') !== 0) {
$value = iconv($charset, 'UTF-8', $value);
}
$value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
$child = $element->ownerDocument->createCDATASection($value);
$element->appendChild($child);
} else {
$child = $element->ownerDocument->createTextNode($value);
$element->appendChild($child);
}
$rootElement->appendChild($element);
}
return $rootElement;
} | [
"protected",
"function",
"arrayToDOM",
"(",
"$",
"array",
",",
"$",
"rootElement",
",",
"$",
"charset",
"=",
"null",
",",
"$",
"removeNumbersFromKeys",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"removeNumbersFromKeys",
")",
"{",
"$",
"key",
"=",
"preg_replace",
"(",
"'/[^a-z]/i'",
",",
"''",
",",
"$",
"key",
")",
";",
"}",
"$",
"element",
"=",
"$",
"rootElement",
"->",
"ownerDocument",
"->",
"createElement",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"arrayToDOM",
"(",
"$",
"value",
",",
"$",
"element",
",",
"$",
"charset",
")",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"charset",
"=",
"$",
"charset",
"?",
"$",
"charset",
":",
"'utf-8'",
";",
"if",
"(",
"function_exists",
"(",
"'iconv'",
")",
"&&",
"strcasecmp",
"(",
"$",
"charset",
",",
"'utf-8'",
")",
"!==",
"0",
"&&",
"strcasecmp",
"(",
"$",
"charset",
",",
"'utf8'",
")",
"!==",
"0",
")",
"{",
"$",
"value",
"=",
"iconv",
"(",
"$",
"charset",
",",
"'UTF-8'",
",",
"$",
"value",
")",
";",
"}",
"$",
"value",
"=",
"htmlspecialchars",
"(",
"$",
"value",
",",
"ENT_COMPAT",
",",
"'UTF-8'",
")",
";",
"$",
"child",
"=",
"$",
"element",
"->",
"ownerDocument",
"->",
"createCDATASection",
"(",
"$",
"value",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"child",
")",
";",
"}",
"else",
"{",
"$",
"child",
"=",
"$",
"element",
"->",
"ownerDocument",
"->",
"createTextNode",
"(",
"$",
"value",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"child",
")",
";",
"}",
"$",
"rootElement",
"->",
"appendChild",
"(",
"$",
"element",
")",
";",
"}",
"return",
"$",
"rootElement",
";",
"}"
] | @param array $array
@param DOMElement $rootElement
@param string $charset
@param boolean $removeNumbersFromKeys
@return DOMElement | [
"@param",
"array",
"$array",
"@param",
"DOMElement",
"$rootElement",
"@param",
"string",
"$charset",
"@param",
"boolean",
"$removeNumbersFromKeys"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/PropelXMLParser.php#L99-L126 |
propelorm/Propel | runtime/lib/parser/PropelXMLParser.php | PropelXMLParser.toArray | public function toArray($data)
{
$doc = new DomDocument('1.0', 'UTF-8');
$doc->loadXML($data);
$element = $doc->documentElement;
return $this->convertDOMElementToArray($element);
} | php | public function toArray($data)
{
$doc = new DomDocument('1.0', 'UTF-8');
$doc->loadXML($data);
$element = $doc->documentElement;
return $this->convertDOMElementToArray($element);
} | [
"public",
"function",
"toArray",
"(",
"$",
"data",
")",
"{",
"$",
"doc",
"=",
"new",
"DomDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"data",
")",
";",
"$",
"element",
"=",
"$",
"doc",
"->",
"documentElement",
";",
"return",
"$",
"this",
"->",
"convertDOMElementToArray",
"(",
"$",
"element",
")",
";",
"}"
] | Converts data from XML to an associative array.
@param string $data Source data to convert, as an XML string
@return array Converted data | [
"Converts",
"data",
"from",
"XML",
"to",
"an",
"associative",
"array",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/PropelXMLParser.php#L135-L142 |
propelorm/Propel | generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php | ArchivableBehaviorQueryBuilderModifier.queryMethods | public function queryMethods(QueryBuilder $builder)
{
$script = '';
$script .= $this->addArchive($builder);
if ($this->behavior->isArchiveOnUpdate()) {
$script .= $this->addSetArchiveOnUpdate($builder);
$script .= $this->addUpdateWithoutArchive($builder);
}
if ($this->behavior->isArchiveOnDelete()) {
$script .= $this->addSetArchiveOnDelete($builder);
$script .= $this->addDeleteWithoutArchive($builder);
}
return $script;
} | php | public function queryMethods(QueryBuilder $builder)
{
$script = '';
$script .= $this->addArchive($builder);
if ($this->behavior->isArchiveOnUpdate()) {
$script .= $this->addSetArchiveOnUpdate($builder);
$script .= $this->addUpdateWithoutArchive($builder);
}
if ($this->behavior->isArchiveOnDelete()) {
$script .= $this->addSetArchiveOnDelete($builder);
$script .= $this->addDeleteWithoutArchive($builder);
}
return $script;
} | [
"public",
"function",
"queryMethods",
"(",
"QueryBuilder",
"$",
"builder",
")",
"{",
"$",
"script",
"=",
"''",
";",
"$",
"script",
".=",
"$",
"this",
"->",
"addArchive",
"(",
"$",
"builder",
")",
";",
"if",
"(",
"$",
"this",
"->",
"behavior",
"->",
"isArchiveOnUpdate",
"(",
")",
")",
"{",
"$",
"script",
".=",
"$",
"this",
"->",
"addSetArchiveOnUpdate",
"(",
"$",
"builder",
")",
";",
"$",
"script",
".=",
"$",
"this",
"->",
"addUpdateWithoutArchive",
"(",
"$",
"builder",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"behavior",
"->",
"isArchiveOnDelete",
"(",
")",
")",
"{",
"$",
"script",
".=",
"$",
"this",
"->",
"addSetArchiveOnDelete",
"(",
"$",
"builder",
")",
";",
"$",
"script",
".=",
"$",
"this",
"->",
"addDeleteWithoutArchive",
"(",
"$",
"builder",
")",
";",
"}",
"return",
"$",
"script",
";",
"}"
] | @param QueryBuilder $builder
@return string the PHP code to be added to the builder | [
"@param",
"QueryBuilder",
"$builder"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/archivable/ArchivableBehaviorQueryBuilderModifier.php#L94-L108 |
propelorm/Propel | generator/lib/task/PropelSQLTask.php | PropelSQLTask.createSqlDbMap | protected function createSqlDbMap()
{
if ($this->getSqlDbMap() === null) {
return;
}
// Produce the sql -> database map
$sqldbmap = new Properties();
// Check to see if the sqldbmap has already been created.
if ($this->getSqlDbMap()->exists()) {
$sqldbmap->load($this->getSqlDbMap());
}
if ($this->packageObjectModel) {
// in this case we'll get the sql file name from the package attribute
$dataModels = $this->packageDataModels();
foreach ($dataModels as $package => $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$name = ($package ? $package . '.' : '') . 'schema.xml';
$sqlFile = $this->getMappedFile($name);
$sqldbmap->setProperty($sqlFile->getName(), $database->getName());
}
}
} else {
// the traditional way is to map the schema.xml filenames
$dmMap = $this->getDataModelDbMap();
foreach (array_keys($dmMap) as $dataModelName) {
$sqlFile = $this->getMappedFile($dataModelName);
if ($this->getDatabase() === null) {
$databaseName = $dmMap[$dataModelName];
} else {
$databaseName = $this->getDatabase();
}
$sqldbmap->setProperty($sqlFile->getName(), $databaseName);
}
}
try {
$sqldbmap->store($this->getSqlDbMap(), "Sqlfile -> Database map");
} catch (IOException $e) {
throw new IOException("Unable to store properties: " . $e->getMessage());
}
} | php | protected function createSqlDbMap()
{
if ($this->getSqlDbMap() === null) {
return;
}
// Produce the sql -> database map
$sqldbmap = new Properties();
// Check to see if the sqldbmap has already been created.
if ($this->getSqlDbMap()->exists()) {
$sqldbmap->load($this->getSqlDbMap());
}
if ($this->packageObjectModel) {
// in this case we'll get the sql file name from the package attribute
$dataModels = $this->packageDataModels();
foreach ($dataModels as $package => $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$name = ($package ? $package . '.' : '') . 'schema.xml';
$sqlFile = $this->getMappedFile($name);
$sqldbmap->setProperty($sqlFile->getName(), $database->getName());
}
}
} else {
// the traditional way is to map the schema.xml filenames
$dmMap = $this->getDataModelDbMap();
foreach (array_keys($dmMap) as $dataModelName) {
$sqlFile = $this->getMappedFile($dataModelName);
if ($this->getDatabase() === null) {
$databaseName = $dmMap[$dataModelName];
} else {
$databaseName = $this->getDatabase();
}
$sqldbmap->setProperty($sqlFile->getName(), $databaseName);
}
}
try {
$sqldbmap->store($this->getSqlDbMap(), "Sqlfile -> Database map");
} catch (IOException $e) {
throw new IOException("Unable to store properties: " . $e->getMessage());
}
} | [
"protected",
"function",
"createSqlDbMap",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getSqlDbMap",
"(",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"// Produce the sql -> database map",
"$",
"sqldbmap",
"=",
"new",
"Properties",
"(",
")",
";",
"// Check to see if the sqldbmap has already been created.",
"if",
"(",
"$",
"this",
"->",
"getSqlDbMap",
"(",
")",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"sqldbmap",
"->",
"load",
"(",
"$",
"this",
"->",
"getSqlDbMap",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"packageObjectModel",
")",
"{",
"// in this case we'll get the sql file name from the package attribute",
"$",
"dataModels",
"=",
"$",
"this",
"->",
"packageDataModels",
"(",
")",
";",
"foreach",
"(",
"$",
"dataModels",
"as",
"$",
"package",
"=>",
"$",
"dataModel",
")",
"{",
"foreach",
"(",
"$",
"dataModel",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"database",
")",
"{",
"$",
"name",
"=",
"(",
"$",
"package",
"?",
"$",
"package",
".",
"'.'",
":",
"''",
")",
".",
"'schema.xml'",
";",
"$",
"sqlFile",
"=",
"$",
"this",
"->",
"getMappedFile",
"(",
"$",
"name",
")",
";",
"$",
"sqldbmap",
"->",
"setProperty",
"(",
"$",
"sqlFile",
"->",
"getName",
"(",
")",
",",
"$",
"database",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// the traditional way is to map the schema.xml filenames",
"$",
"dmMap",
"=",
"$",
"this",
"->",
"getDataModelDbMap",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"dmMap",
")",
"as",
"$",
"dataModelName",
")",
"{",
"$",
"sqlFile",
"=",
"$",
"this",
"->",
"getMappedFile",
"(",
"$",
"dataModelName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getDatabase",
"(",
")",
"===",
"null",
")",
"{",
"$",
"databaseName",
"=",
"$",
"dmMap",
"[",
"$",
"dataModelName",
"]",
";",
"}",
"else",
"{",
"$",
"databaseName",
"=",
"$",
"this",
"->",
"getDatabase",
"(",
")",
";",
"}",
"$",
"sqldbmap",
"->",
"setProperty",
"(",
"$",
"sqlFile",
"->",
"getName",
"(",
")",
",",
"$",
"databaseName",
")",
";",
"}",
"}",
"try",
"{",
"$",
"sqldbmap",
"->",
"store",
"(",
"$",
"this",
"->",
"getSqlDbMap",
"(",
")",
",",
"\"Sqlfile -> Database map\"",
")",
";",
"}",
"catch",
"(",
"IOException",
"$",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unable to store properties: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Create the sql -> database map.
@throws IOException - if unable to store properties | [
"Create",
"the",
"sql",
"-",
">",
"database",
"map",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLTask.php#L81-L124 |
propelorm/Propel | generator/lib/task/PropelSQLTask.php | PropelSQLTask.getWarnings | public function getWarnings(Database $database, PropelPLatformInterface $platform)
{
foreach ($database->getTablesForSql() as $table) {
foreach ($table->getForeignKeys() as $fk) {
if ($platform instanceof MssqlPlatform && $fk->hasOnUpdate() && $fk->getOnUpdate() == ForeignKey::SETNULL) {
// there may be others that also won't work
// we have to skip this because it's unsupported.
$this->log(sprintf(
'Ignoring the "ON UPDATE SET NULL" option for "%s" fk on "%s" table (unsupported by MSSQL).',
$fk->getLocalColumnNames(),
$table->getName()
), Project::MSG_WARN);
}
if ($platform instanceof MssqlPlatform && $fk->hasOnDelete() && $fk->getOnDelete() == ForeignKey::SETNULL) {
// there may be others that also won't work
// we have to skip this because it's unsupported.
$this->log(sprintf(
'Ignoring the "ON DELETE SET NULL" option for "%s" fk on "%s" table (unsupported by MSSQL).',
$fk->getLocalColumnNames(),
$table->getName()
), Project::MSG_WARN);
}
if ($platform instanceof OraclePlatform && $fk->hasOnUpdate()) {
// there may be others that also won't work
// we have to skip this because it's unsupported.
$this->log(sprintf(
'Ignoring the "ON UPDATE" option for "%s" fk on "%s" table (unsupported by current Oracle adapter).',
$fk->getLocalColumnNames(),
$table->getName()
), Project::MSG_WARN);
}
}
}
} | php | public function getWarnings(Database $database, PropelPLatformInterface $platform)
{
foreach ($database->getTablesForSql() as $table) {
foreach ($table->getForeignKeys() as $fk) {
if ($platform instanceof MssqlPlatform && $fk->hasOnUpdate() && $fk->getOnUpdate() == ForeignKey::SETNULL) {
// there may be others that also won't work
// we have to skip this because it's unsupported.
$this->log(sprintf(
'Ignoring the "ON UPDATE SET NULL" option for "%s" fk on "%s" table (unsupported by MSSQL).',
$fk->getLocalColumnNames(),
$table->getName()
), Project::MSG_WARN);
}
if ($platform instanceof MssqlPlatform && $fk->hasOnDelete() && $fk->getOnDelete() == ForeignKey::SETNULL) {
// there may be others that also won't work
// we have to skip this because it's unsupported.
$this->log(sprintf(
'Ignoring the "ON DELETE SET NULL" option for "%s" fk on "%s" table (unsupported by MSSQL).',
$fk->getLocalColumnNames(),
$table->getName()
), Project::MSG_WARN);
}
if ($platform instanceof OraclePlatform && $fk->hasOnUpdate()) {
// there may be others that also won't work
// we have to skip this because it's unsupported.
$this->log(sprintf(
'Ignoring the "ON UPDATE" option for "%s" fk on "%s" table (unsupported by current Oracle adapter).',
$fk->getLocalColumnNames(),
$table->getName()
), Project::MSG_WARN);
}
}
}
} | [
"public",
"function",
"getWarnings",
"(",
"Database",
"$",
"database",
",",
"PropelPLatformInterface",
"$",
"platform",
")",
"{",
"foreach",
"(",
"$",
"database",
"->",
"getTablesForSql",
"(",
")",
"as",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"getForeignKeys",
"(",
")",
"as",
"$",
"fk",
")",
"{",
"if",
"(",
"$",
"platform",
"instanceof",
"MssqlPlatform",
"&&",
"$",
"fk",
"->",
"hasOnUpdate",
"(",
")",
"&&",
"$",
"fk",
"->",
"getOnUpdate",
"(",
")",
"==",
"ForeignKey",
"::",
"SETNULL",
")",
"{",
"// there may be others that also won't work",
"// we have to skip this because it's unsupported.",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Ignoring the \"ON UPDATE SET NULL\" option for \"%s\" fk on \"%s\" table (unsupported by MSSQL).'",
",",
"$",
"fk",
"->",
"getLocalColumnNames",
"(",
")",
",",
"$",
"table",
"->",
"getName",
"(",
")",
")",
",",
"Project",
"::",
"MSG_WARN",
")",
";",
"}",
"if",
"(",
"$",
"platform",
"instanceof",
"MssqlPlatform",
"&&",
"$",
"fk",
"->",
"hasOnDelete",
"(",
")",
"&&",
"$",
"fk",
"->",
"getOnDelete",
"(",
")",
"==",
"ForeignKey",
"::",
"SETNULL",
")",
"{",
"// there may be others that also won't work",
"// we have to skip this because it's unsupported.",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Ignoring the \"ON DELETE SET NULL\" option for \"%s\" fk on \"%s\" table (unsupported by MSSQL).'",
",",
"$",
"fk",
"->",
"getLocalColumnNames",
"(",
")",
",",
"$",
"table",
"->",
"getName",
"(",
")",
")",
",",
"Project",
"::",
"MSG_WARN",
")",
";",
"}",
"if",
"(",
"$",
"platform",
"instanceof",
"OraclePlatform",
"&&",
"$",
"fk",
"->",
"hasOnUpdate",
"(",
")",
")",
"{",
"// there may be others that also won't work",
"// we have to skip this because it's unsupported.",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Ignoring the \"ON UPDATE\" option for \"%s\" fk on \"%s\" table (unsupported by current Oracle adapter).'",
",",
"$",
"fk",
"->",
"getLocalColumnNames",
"(",
")",
",",
"$",
"table",
"->",
"getName",
"(",
")",
")",
",",
"Project",
"::",
"MSG_WARN",
")",
";",
"}",
"}",
"}",
"}"
] | main() | [
"main",
"()"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLTask.php#L182-L218 |
propelorm/Propel | generator/lib/task/PropelSQLTask.php | PropelSQLTask.packageDataModels | protected function packageDataModels()
{
static $packagedDataModels;
if (is_null($packagedDataModels)) {
$dataModels = $this->getDataModels();
$dataModel = array_shift($dataModels);
$packagedDataModels = array();
$platform = $this->getGeneratorConfig()->getConfiguredPlatform();
foreach ($dataModel->getDatabases() as $db) {
foreach ($db->getTables() as $table) {
$package = $table->getPackage();
if (!isset($packagedDataModels[$package])) {
$dbClone = $this->cloneDatabase($db);
$dbClone->setPackage($package);
$ad = new AppData($platform);
$ad->setGeneratorConfig($this->getGeneratorConfig());
$ad->setName($dataModel->getName());
$ad->addDatabase($dbClone);
$packagedDataModels[$package] = $ad;
}
$packagedDataModels[$package]->getDatabase($db->getName())->addTable($table);
}
}
}
return $packagedDataModels;
} | php | protected function packageDataModels()
{
static $packagedDataModels;
if (is_null($packagedDataModels)) {
$dataModels = $this->getDataModels();
$dataModel = array_shift($dataModels);
$packagedDataModels = array();
$platform = $this->getGeneratorConfig()->getConfiguredPlatform();
foreach ($dataModel->getDatabases() as $db) {
foreach ($db->getTables() as $table) {
$package = $table->getPackage();
if (!isset($packagedDataModels[$package])) {
$dbClone = $this->cloneDatabase($db);
$dbClone->setPackage($package);
$ad = new AppData($platform);
$ad->setGeneratorConfig($this->getGeneratorConfig());
$ad->setName($dataModel->getName());
$ad->addDatabase($dbClone);
$packagedDataModels[$package] = $ad;
}
$packagedDataModels[$package]->getDatabase($db->getName())->addTable($table);
}
}
}
return $packagedDataModels;
} | [
"protected",
"function",
"packageDataModels",
"(",
")",
"{",
"static",
"$",
"packagedDataModels",
";",
"if",
"(",
"is_null",
"(",
"$",
"packagedDataModels",
")",
")",
"{",
"$",
"dataModels",
"=",
"$",
"this",
"->",
"getDataModels",
"(",
")",
";",
"$",
"dataModel",
"=",
"array_shift",
"(",
"$",
"dataModels",
")",
";",
"$",
"packagedDataModels",
"=",
"array",
"(",
")",
";",
"$",
"platform",
"=",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
"->",
"getConfiguredPlatform",
"(",
")",
";",
"foreach",
"(",
"$",
"dataModel",
"->",
"getDatabases",
"(",
")",
"as",
"$",
"db",
")",
"{",
"foreach",
"(",
"$",
"db",
"->",
"getTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"$",
"package",
"=",
"$",
"table",
"->",
"getPackage",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"packagedDataModels",
"[",
"$",
"package",
"]",
")",
")",
"{",
"$",
"dbClone",
"=",
"$",
"this",
"->",
"cloneDatabase",
"(",
"$",
"db",
")",
";",
"$",
"dbClone",
"->",
"setPackage",
"(",
"$",
"package",
")",
";",
"$",
"ad",
"=",
"new",
"AppData",
"(",
"$",
"platform",
")",
";",
"$",
"ad",
"->",
"setGeneratorConfig",
"(",
"$",
"this",
"->",
"getGeneratorConfig",
"(",
")",
")",
";",
"$",
"ad",
"->",
"setName",
"(",
"$",
"dataModel",
"->",
"getName",
"(",
")",
")",
";",
"$",
"ad",
"->",
"addDatabase",
"(",
"$",
"dbClone",
")",
";",
"$",
"packagedDataModels",
"[",
"$",
"package",
"]",
"=",
"$",
"ad",
";",
"}",
"$",
"packagedDataModels",
"[",
"$",
"package",
"]",
"->",
"getDatabase",
"(",
"$",
"db",
"->",
"getName",
"(",
")",
")",
"->",
"addTable",
"(",
"$",
"table",
")",
";",
"}",
"}",
"}",
"return",
"$",
"packagedDataModels",
";",
"}"
] | Packages the datamodels to one datamodel per package
This applies only when the the packageObjectModel option is set. We need to
re-package the datamodels to allow the database package attribute to control
which tables go into which SQL file.
@return array The packaged datamodels | [
"Packages",
"the",
"datamodels",
"to",
"one",
"datamodel",
"per",
"package"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelSQLTask.php#L229-L259 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.normalizeFKey | public function normalizeFKey($attrib)
{
if ($attrib === null || strtoupper($attrib) == "NONE") {
$attrib = self::NONE;
}
$attrib = strtoupper($attrib);
if ($attrib == "SETNULL") {
$attrib = self::SETNULL;
}
return $attrib;
} | php | public function normalizeFKey($attrib)
{
if ($attrib === null || strtoupper($attrib) == "NONE") {
$attrib = self::NONE;
}
$attrib = strtoupper($attrib);
if ($attrib == "SETNULL") {
$attrib = self::SETNULL;
}
return $attrib;
} | [
"public",
"function",
"normalizeFKey",
"(",
"$",
"attrib",
")",
"{",
"if",
"(",
"$",
"attrib",
"===",
"null",
"||",
"strtoupper",
"(",
"$",
"attrib",
")",
"==",
"\"NONE\"",
")",
"{",
"$",
"attrib",
"=",
"self",
"::",
"NONE",
";",
"}",
"$",
"attrib",
"=",
"strtoupper",
"(",
"$",
"attrib",
")",
";",
"if",
"(",
"$",
"attrib",
"==",
"\"SETNULL\"",
")",
"{",
"$",
"attrib",
"=",
"self",
"::",
"SETNULL",
";",
"}",
"return",
"$",
"attrib",
";",
"}"
] | normalizes the input of onDelete, onUpdate attributes | [
"normalizes",
"the",
"input",
"of",
"onDelete",
"onUpdate",
"attributes"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L112-L123 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.hasOnUpdate | public function hasOnUpdate()
{
$database = $this->getTable()->getDatabase();
if($database instanceof Database &&
$this->onUpdate === $database->getPlatform()->getDefaultFKOnUpdateBehavior()) {
return false;
}
return ($this->onUpdate !== self::NONE);
} | php | public function hasOnUpdate()
{
$database = $this->getTable()->getDatabase();
if($database instanceof Database &&
$this->onUpdate === $database->getPlatform()->getDefaultFKOnUpdateBehavior()) {
return false;
}
return ($this->onUpdate !== self::NONE);
} | [
"public",
"function",
"hasOnUpdate",
"(",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
";",
"if",
"(",
"$",
"database",
"instanceof",
"Database",
"&&",
"$",
"this",
"->",
"onUpdate",
"===",
"$",
"database",
"->",
"getPlatform",
"(",
")",
"->",
"getDefaultFKOnUpdateBehavior",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"onUpdate",
"!==",
"self",
"::",
"NONE",
")",
";",
"}"
] | returns whether or not the onUpdate attribute is set | [
"returns",
"whether",
"or",
"not",
"the",
"onUpdate",
"attribute",
"is",
"set"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L128-L137 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.hasOnDelete | public function hasOnDelete()
{
$database = $this->getTable()->getDatabase();
if($database instanceof Database &&
$this->onDelete === $database->getPlatform()->getDefaultFKOnDeleteBehavior()) {
return false;
}
return ($this->onDelete !== self::NONE);
} | php | public function hasOnDelete()
{
$database = $this->getTable()->getDatabase();
if($database instanceof Database &&
$this->onDelete === $database->getPlatform()->getDefaultFKOnDeleteBehavior()) {
return false;
}
return ($this->onDelete !== self::NONE);
} | [
"public",
"function",
"hasOnDelete",
"(",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
";",
"if",
"(",
"$",
"database",
"instanceof",
"Database",
"&&",
"$",
"this",
"->",
"onDelete",
"===",
"$",
"database",
"->",
"getPlatform",
"(",
")",
"->",
"getDefaultFKOnDeleteBehavior",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"onDelete",
"!==",
"self",
"::",
"NONE",
")",
";",
"}"
] | returns whether or not the onDelete attribute is set | [
"returns",
"whether",
"or",
"not",
"the",
"onDelete",
"attribute",
"is",
"set"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L142-L151 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getForeignTableName | public function getForeignTableName()
{
if ($this->foreignSchemaName && $this->getTable()->getDatabase()->getPlatform()->supportsSchemas()) {
return $this->foreignSchemaName . '.' . $this->foreignTableCommonName;
} else {
return $this->foreignTableCommonName;
}
} | php | public function getForeignTableName()
{
if ($this->foreignSchemaName && $this->getTable()->getDatabase()->getPlatform()->supportsSchemas()) {
return $this->foreignSchemaName . '.' . $this->foreignTableCommonName;
} else {
return $this->foreignTableCommonName;
}
} | [
"public",
"function",
"getForeignTableName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"foreignSchemaName",
"&&",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getDatabase",
"(",
")",
"->",
"getPlatform",
"(",
")",
"->",
"supportsSchemas",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"foreignSchemaName",
".",
"'.'",
".",
"$",
"this",
"->",
"foreignTableCommonName",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"foreignTableCommonName",
";",
"}",
"}"
] | Get the foreignTableName of the FK
@return string foreign table qualified name | [
"Get",
"the",
"foreignTableName",
"of",
"the",
"FK"
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L270-L277 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.addReference | public function addReference($p1, $p2 = null)
{
if (is_array($p1)) {
$this->addReference(@$p1["local"], @$p1["foreign"]);
} else {
if ($p1 instanceof Column) {
$p1 = $p1->getName();
}
if ($p2 instanceof Column) {
$p2 = $p2->getName();
}
$this->localColumns[] = $p1;
$this->foreignColumns[] = $p2;
}
} | php | public function addReference($p1, $p2 = null)
{
if (is_array($p1)) {
$this->addReference(@$p1["local"], @$p1["foreign"]);
} else {
if ($p1 instanceof Column) {
$p1 = $p1->getName();
}
if ($p2 instanceof Column) {
$p2 = $p2->getName();
}
$this->localColumns[] = $p1;
$this->foreignColumns[] = $p2;
}
} | [
"public",
"function",
"addReference",
"(",
"$",
"p1",
",",
"$",
"p2",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"p1",
")",
")",
"{",
"$",
"this",
"->",
"addReference",
"(",
"@",
"$",
"p1",
"[",
"\"local\"",
"]",
",",
"@",
"$",
"p1",
"[",
"\"foreign\"",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"p1",
"instanceof",
"Column",
")",
"{",
"$",
"p1",
"=",
"$",
"p1",
"->",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"$",
"p2",
"instanceof",
"Column",
")",
"{",
"$",
"p2",
"=",
"$",
"p2",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"this",
"->",
"localColumns",
"[",
"]",
"=",
"$",
"p1",
";",
"$",
"this",
"->",
"foreignColumns",
"[",
"]",
"=",
"$",
"p2",
";",
"}",
"}"
] | Adds a new reference entry to the foreign key. | [
"Adds",
"a",
"new",
"reference",
"entry",
"to",
"the",
"foreign",
"key",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L358-L372 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getLocalColumnObjects | public function getLocalColumnObjects()
{
$columns = array();
$localTable = $this->getTable();
foreach ($this->localColumns as $columnName) {
$columns[] = $localTable->getColumn($columnName);
}
return $columns;
} | php | public function getLocalColumnObjects()
{
$columns = array();
$localTable = $this->getTable();
foreach ($this->localColumns as $columnName) {
$columns[] = $localTable->getColumn($columnName);
}
return $columns;
} | [
"public",
"function",
"getLocalColumnObjects",
"(",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"$",
"localTable",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"localColumns",
"as",
"$",
"columnName",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"localTable",
"->",
"getColumn",
"(",
"$",
"columnName",
")",
";",
"}",
"return",
"$",
"columns",
";",
"}"
] | Return an array of local column objects.
@return array Column[] | [
"Return",
"an",
"array",
"of",
"local",
"column",
"objects",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L418-L427 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getLocalForeignMapping | public function getLocalForeignMapping()
{
$h = array();
for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
$h[$this->localColumns[$i]] = $this->foreignColumns[$i];
}
return $h;
} | php | public function getLocalForeignMapping()
{
$h = array();
for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
$h[$this->localColumns[$i]] = $this->foreignColumns[$i];
}
return $h;
} | [
"public",
"function",
"getLocalForeignMapping",
"(",
")",
"{",
"$",
"h",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"localColumns",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"h",
"[",
"$",
"this",
"->",
"localColumns",
"[",
"$",
"i",
"]",
"]",
"=",
"$",
"this",
"->",
"foreignColumns",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"h",
";",
"}"
] | Utility method to get local column to foreign column
mapping for this foreign key. | [
"Utility",
"method",
"to",
"get",
"local",
"column",
"to",
"foreign",
"column",
"mapping",
"for",
"this",
"foreign",
"key",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L453-L461 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getForeignLocalMapping | public function getForeignLocalMapping()
{
$h = array();
for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
$h[$this->foreignColumns[$i]] = $this->localColumns[$i];
}
return $h;
} | php | public function getForeignLocalMapping()
{
$h = array();
for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
$h[$this->foreignColumns[$i]] = $this->localColumns[$i];
}
return $h;
} | [
"public",
"function",
"getForeignLocalMapping",
"(",
")",
"{",
"$",
"h",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"localColumns",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"h",
"[",
"$",
"this",
"->",
"foreignColumns",
"[",
"$",
"i",
"]",
"]",
"=",
"$",
"this",
"->",
"localColumns",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"h",
";",
"}"
] | Utility method to get local column to foreign column
mapping for this foreign key. | [
"Utility",
"method",
"to",
"get",
"local",
"column",
"to",
"foreign",
"column",
"mapping",
"for",
"this",
"foreign",
"key",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L467-L475 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getColumnObjectsMapping | public function getColumnObjectsMapping()
{
$mapping = array();
$localTable = $this->getTable();
$foreignTable = $this->getForeignTable();
for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
$mapping[]= array(
'local' => $localTable->getColumn($this->localColumns[$i]),
'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]),
);
}
return $mapping;
} | php | public function getColumnObjectsMapping()
{
$mapping = array();
$localTable = $this->getTable();
$foreignTable = $this->getForeignTable();
for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
$mapping[]= array(
'local' => $localTable->getColumn($this->localColumns[$i]),
'foreign' => $foreignTable->getColumn($this->foreignColumns[$i]),
);
}
return $mapping;
} | [
"public",
"function",
"getColumnObjectsMapping",
"(",
")",
"{",
"$",
"mapping",
"=",
"array",
"(",
")",
";",
"$",
"localTable",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"foreignTable",
"=",
"$",
"this",
"->",
"getForeignTable",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"localColumns",
")",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"mapping",
"[",
"]",
"=",
"array",
"(",
"'local'",
"=>",
"$",
"localTable",
"->",
"getColumn",
"(",
"$",
"this",
"->",
"localColumns",
"[",
"$",
"i",
"]",
")",
",",
"'foreign'",
"=>",
"$",
"foreignTable",
"->",
"getColumn",
"(",
"$",
"this",
"->",
"foreignColumns",
"[",
"$",
"i",
"]",
")",
",",
")",
";",
"}",
"return",
"$",
"mapping",
";",
"}"
] | Utility method to get local and foreign column objects
mapping for this foreign key. | [
"Utility",
"method",
"to",
"get",
"local",
"and",
"foreign",
"column",
"objects",
"mapping",
"for",
"this",
"foreign",
"key",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L481-L494 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getMappedForeignColumn | public function getMappedForeignColumn($local)
{
$m = $this->getLocalForeignMapping();
if (isset($m[$local])) {
return $m[$local];
}
return null;
} | php | public function getMappedForeignColumn($local)
{
$m = $this->getLocalForeignMapping();
if (isset($m[$local])) {
return $m[$local];
}
return null;
} | [
"public",
"function",
"getMappedForeignColumn",
"(",
"$",
"local",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"getLocalForeignMapping",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"m",
"[",
"$",
"local",
"]",
")",
")",
"{",
"return",
"$",
"m",
"[",
"$",
"local",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get the foreign column mapped to specified local column.
@return string Column name. | [
"Get",
"the",
"foreign",
"column",
"mapped",
"to",
"specified",
"local",
"column",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L501-L509 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.getMappedLocalColumn | public function getMappedLocalColumn($foreign)
{
$m = $this->getForeignLocalMapping();
if (isset($m[$foreign])) {
return $m[$foreign];
}
return null;
} | php | public function getMappedLocalColumn($foreign)
{
$m = $this->getForeignLocalMapping();
if (isset($m[$foreign])) {
return $m[$foreign];
}
return null;
} | [
"public",
"function",
"getMappedLocalColumn",
"(",
"$",
"foreign",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"getForeignLocalMapping",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"m",
"[",
"$",
"foreign",
"]",
")",
")",
"{",
"return",
"$",
"m",
"[",
"$",
"foreign",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get the local column mapped to specified foreign column.
@return string Column name. | [
"Get",
"the",
"local",
"column",
"mapped",
"to",
"specified",
"foreign",
"column",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L516-L524 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.isLocalColumnsRequired | public function isLocalColumnsRequired()
{
foreach ($this->getLocalColumns() as $columnName) {
if (!$this->getTable()->getColumn($columnName)->isNotNull()) {
return false;
}
}
return true;
} | php | public function isLocalColumnsRequired()
{
foreach ($this->getLocalColumns() as $columnName) {
if (!$this->getTable()->getColumn($columnName)->isNotNull()) {
return false;
}
}
return true;
} | [
"public",
"function",
"isLocalColumnsRequired",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getLocalColumns",
"(",
")",
"as",
"$",
"columnName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"getColumn",
"(",
"$",
"columnName",
")",
"->",
"isNotNull",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Whether this foreign key uses a required column, or a list of required columns.
@return boolean | [
"Whether",
"this",
"foreign",
"key",
"uses",
"a",
"required",
"column",
"or",
"a",
"list",
"of",
"required",
"columns",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L577-L586 |
propelorm/Propel | generator/lib/model/ForeignKey.php | ForeignKey.isForeignPrimaryKey | public function isForeignPrimaryKey()
{
$lfmap = $this->getLocalForeignMapping();
$foreignTable = $this->getForeignTable();
$foreignPKCols = array();
foreach ($foreignTable->getPrimaryKey() as $fPKCol) {
$foreignPKCols[] = $fPKCol->getName();
}
$foreignCols = array();
foreach ($this->getLocalColumns() as $colName) {
$foreignCols[] = $foreignTable->getColumn($lfmap[$colName])->getName();
}
return ((count($foreignPKCols) === count($foreignCols)) && !array_diff($foreignPKCols, $foreignCols));
} | php | public function isForeignPrimaryKey()
{
$lfmap = $this->getLocalForeignMapping();
$foreignTable = $this->getForeignTable();
$foreignPKCols = array();
foreach ($foreignTable->getPrimaryKey() as $fPKCol) {
$foreignPKCols[] = $fPKCol->getName();
}
$foreignCols = array();
foreach ($this->getLocalColumns() as $colName) {
$foreignCols[] = $foreignTable->getColumn($lfmap[$colName])->getName();
}
return ((count($foreignPKCols) === count($foreignCols)) && !array_diff($foreignPKCols, $foreignCols));
} | [
"public",
"function",
"isForeignPrimaryKey",
"(",
")",
"{",
"$",
"lfmap",
"=",
"$",
"this",
"->",
"getLocalForeignMapping",
"(",
")",
";",
"$",
"foreignTable",
"=",
"$",
"this",
"->",
"getForeignTable",
"(",
")",
";",
"$",
"foreignPKCols",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"foreignTable",
"->",
"getPrimaryKey",
"(",
")",
"as",
"$",
"fPKCol",
")",
"{",
"$",
"foreignPKCols",
"[",
"]",
"=",
"$",
"fPKCol",
"->",
"getName",
"(",
")",
";",
"}",
"$",
"foreignCols",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocalColumns",
"(",
")",
"as",
"$",
"colName",
")",
"{",
"$",
"foreignCols",
"[",
"]",
"=",
"$",
"foreignTable",
"->",
"getColumn",
"(",
"$",
"lfmap",
"[",
"$",
"colName",
"]",
")",
"->",
"getName",
"(",
")",
";",
"}",
"return",
"(",
"(",
"count",
"(",
"$",
"foreignPKCols",
")",
"===",
"count",
"(",
"$",
"foreignCols",
")",
")",
"&&",
"!",
"array_diff",
"(",
"$",
"foreignPKCols",
",",
"$",
"foreignCols",
")",
")",
";",
"}"
] | Whether this foreign key is also the primary key of the foreign table.
@return boolean Returns true if all columns inside this foreign key are primary keys of the foreign table | [
"Whether",
"this",
"foreign",
"key",
"is",
"also",
"the",
"primary",
"key",
"of",
"the",
"foreign",
"table",
"."
] | train | https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ForeignKey.php#L593-L609 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.