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/collection/PropelObjectCollection.php
PropelObjectCollection.populateRelation
public function populateRelation($relation, $criteria = null, $con = null) { if (!Propel::isInstancePoolingEnabled()) { throw new PropelException('populateRelation() needs instance pooling to be enabled prior to populating the collection'); } $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); if ($this->isEmpty()) { // save a useless query and return an empty collection $coll = new PropelObjectCollection(); $coll->setModel($relationMap->getRightTable()->getClassname()); return $coll; } $symRelationMap = $relationMap->getSymmetricalRelation(); $query = PropelQuery::from($relationMap->getRightTable()->getClassname()); if (null !== $criteria) { $query->mergeWith($criteria); } // query the db for the related objects $filterMethod = 'filterBy' . $symRelationMap->getName(); $relatedObjects = $query ->$filterMethod($this) ->find($con); if ($relationMap->getType() == RelationMap::ONE_TO_MANY) { // initialize the embedded collections of the main objects $relationName = $relationMap->getName(); foreach ($this as $mainObj) { $mainObj->initRelation($relationName); } // associate the related objects to the main objects $getMethod = 'get' . $symRelationMap->getName(); $addMethod = 'add' . $relationName; foreach ($relatedObjects as $object) { $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query $mainObj->$addMethod($object); } $relatedObjects->clearIterator(); } elseif ($relationMap->getType() == RelationMap::MANY_TO_ONE) { // nothing to do; the instance pool will catch all calls to getRelatedObject() // and return the object in memory } else { throw new PropelException('populateRelation() does not support this relation type'); } return $relatedObjects; }
php
public function populateRelation($relation, $criteria = null, $con = null) { if (!Propel::isInstancePoolingEnabled()) { throw new PropelException('populateRelation() needs instance pooling to be enabled prior to populating the collection'); } $relationMap = $this->getFormatter()->getTableMap()->getRelation($relation); if ($this->isEmpty()) { // save a useless query and return an empty collection $coll = new PropelObjectCollection(); $coll->setModel($relationMap->getRightTable()->getClassname()); return $coll; } $symRelationMap = $relationMap->getSymmetricalRelation(); $query = PropelQuery::from($relationMap->getRightTable()->getClassname()); if (null !== $criteria) { $query->mergeWith($criteria); } // query the db for the related objects $filterMethod = 'filterBy' . $symRelationMap->getName(); $relatedObjects = $query ->$filterMethod($this) ->find($con); if ($relationMap->getType() == RelationMap::ONE_TO_MANY) { // initialize the embedded collections of the main objects $relationName = $relationMap->getName(); foreach ($this as $mainObj) { $mainObj->initRelation($relationName); } // associate the related objects to the main objects $getMethod = 'get' . $symRelationMap->getName(); $addMethod = 'add' . $relationName; foreach ($relatedObjects as $object) { $mainObj = $object->$getMethod(); // instance pool is used here to avoid a query $mainObj->$addMethod($object); } $relatedObjects->clearIterator(); } elseif ($relationMap->getType() == RelationMap::MANY_TO_ONE) { // nothing to do; the instance pool will catch all calls to getRelatedObject() // and return the object in memory } else { throw new PropelException('populateRelation() does not support this relation type'); } return $relatedObjects; }
[ "public", "function", "populateRelation", "(", "$", "relation", ",", "$", "criteria", "=", "null", ",", "$", "con", "=", "null", ")", "{", "if", "(", "!", "Propel", "::", "isInstancePoolingEnabled", "(", ")", ")", "{", "throw", "new", "PropelException", "(", "'populateRelation() needs instance pooling to be enabled prior to populating the collection'", ")", ";", "}", "$", "relationMap", "=", "$", "this", "->", "getFormatter", "(", ")", "->", "getTableMap", "(", ")", "->", "getRelation", "(", "$", "relation", ")", ";", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "// save a useless query and return an empty collection", "$", "coll", "=", "new", "PropelObjectCollection", "(", ")", ";", "$", "coll", "->", "setModel", "(", "$", "relationMap", "->", "getRightTable", "(", ")", "->", "getClassname", "(", ")", ")", ";", "return", "$", "coll", ";", "}", "$", "symRelationMap", "=", "$", "relationMap", "->", "getSymmetricalRelation", "(", ")", ";", "$", "query", "=", "PropelQuery", "::", "from", "(", "$", "relationMap", "->", "getRightTable", "(", ")", "->", "getClassname", "(", ")", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "// query the db for the related objects", "$", "filterMethod", "=", "'filterBy'", ".", "$", "symRelationMap", "->", "getName", "(", ")", ";", "$", "relatedObjects", "=", "$", "query", "->", "$", "filterMethod", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "$", "relationMap", "->", "getType", "(", ")", "==", "RelationMap", "::", "ONE_TO_MANY", ")", "{", "// initialize the embedded collections of the main objects", "$", "relationName", "=", "$", "relationMap", "->", "getName", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "mainObj", ")", "{", "$", "mainObj", "->", "initRelation", "(", "$", "relationName", ")", ";", "}", "// associate the related objects to the main objects", "$", "getMethod", "=", "'get'", ".", "$", "symRelationMap", "->", "getName", "(", ")", ";", "$", "addMethod", "=", "'add'", ".", "$", "relationName", ";", "foreach", "(", "$", "relatedObjects", "as", "$", "object", ")", "{", "$", "mainObj", "=", "$", "object", "->", "$", "getMethod", "(", ")", ";", "// instance pool is used here to avoid a query", "$", "mainObj", "->", "$", "addMethod", "(", "$", "object", ")", ";", "}", "$", "relatedObjects", "->", "clearIterator", "(", ")", ";", "}", "elseif", "(", "$", "relationMap", "->", "getType", "(", ")", "==", "RelationMap", "::", "MANY_TO_ONE", ")", "{", "// nothing to do; the instance pool will catch all calls to getRelatedObject()", "// and return the object in memory", "}", "else", "{", "throw", "new", "PropelException", "(", "'populateRelation() does not support this relation type'", ")", ";", "}", "return", "$", "relatedObjects", ";", "}" ]
Makes an additional query to populate the objects related to the collection objects by a certain relation @param string $relation Relation name (e.g. 'Book') @param Criteria $criteria Optional Criteria object to filter the related object collection @param PropelPDO $con Optional connection object @return PropelObjectCollection The list of related objects @throws PropelException
[ "Makes", "an", "additional", "query", "to", "populate", "the", "objects", "related", "to", "the", "collection", "objects", "by", "a", "certain", "relation" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelObjectCollection.php#L224-L270
propelorm/Propel
runtime/lib/collection/PropelObjectCollection.php
PropelObjectCollection.search
public function search($element) { if ($element instanceof BaseObject) { if (null !== $elt = $this->getIdenticalObject($element)) { $element = $elt; } } return parent::search($element); }
php
public function search($element) { if ($element instanceof BaseObject) { if (null !== $elt = $this->getIdenticalObject($element)) { $element = $elt; } } return parent::search($element); }
[ "public", "function", "search", "(", "$", "element", ")", "{", "if", "(", "$", "element", "instanceof", "BaseObject", ")", "{", "if", "(", "null", "!==", "$", "elt", "=", "$", "this", "->", "getIdenticalObject", "(", "$", "element", ")", ")", "{", "$", "element", "=", "$", "elt", ";", "}", "}", "return", "parent", "::", "search", "(", "$", "element", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelObjectCollection.php#L275-L284
propelorm/Propel
runtime/lib/collection/PropelObjectCollection.php
PropelObjectCollection.contains
public function contains($element) { if ($element instanceof BaseObject) { if (null !== $elt = $this->getIdenticalObject($element)) { $element = $elt; } } return parent::contains($element); }
php
public function contains($element) { if ($element instanceof BaseObject) { if (null !== $elt = $this->getIdenticalObject($element)) { $element = $elt; } } return parent::contains($element); }
[ "public", "function", "contains", "(", "$", "element", ")", "{", "if", "(", "$", "element", "instanceof", "BaseObject", ")", "{", "if", "(", "null", "!==", "$", "elt", "=", "$", "this", "->", "getIdenticalObject", "(", "$", "element", ")", ")", "{", "$", "element", "=", "$", "elt", ";", "}", "}", "return", "parent", "::", "contains", "(", "$", "element", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelObjectCollection.php#L289-L298
propelorm/Propel
generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php
ArchivableBehaviorObjectBuilderModifier.objectAttributes
public function objectAttributes(PHP5ObjectBuilder $builder) { if (!$this->behavior->hasArchiveClass()) { $builder->declareClassFromBuilder($builder->getNewStubQueryBuilder($this->behavior->getArchiveTable())); } $script = ''; if ($this->behavior->isArchiveOnInsert()) { $script .= "protected \$archiveOnInsert = true; "; } if ($this->behavior->isArchiveOnUpdate()) { $script .= "protected \$archiveOnUpdate = true; "; } if ($this->behavior->isArchiveOnDelete()) { $script .= "protected \$archiveOnDelete = true; "; } return $script; }
php
public function objectAttributes(PHP5ObjectBuilder $builder) { if (!$this->behavior->hasArchiveClass()) { $builder->declareClassFromBuilder($builder->getNewStubQueryBuilder($this->behavior->getArchiveTable())); } $script = ''; if ($this->behavior->isArchiveOnInsert()) { $script .= "protected \$archiveOnInsert = true; "; } if ($this->behavior->isArchiveOnUpdate()) { $script .= "protected \$archiveOnUpdate = true; "; } if ($this->behavior->isArchiveOnDelete()) { $script .= "protected \$archiveOnDelete = true; "; } return $script; }
[ "public", "function", "objectAttributes", "(", "PHP5ObjectBuilder", "$", "builder", ")", "{", "if", "(", "!", "$", "this", "->", "behavior", "->", "hasArchiveClass", "(", ")", ")", "{", "$", "builder", "->", "declareClassFromBuilder", "(", "$", "builder", "->", "getNewStubQueryBuilder", "(", "$", "this", "->", "behavior", "->", "getArchiveTable", "(", ")", ")", ")", ";", "}", "$", "script", "=", "''", ";", "if", "(", "$", "this", "->", "behavior", "->", "isArchiveOnInsert", "(", ")", ")", "{", "$", "script", ".=", "\"protected \\$archiveOnInsert = true;\n\"", ";", "}", "if", "(", "$", "this", "->", "behavior", "->", "isArchiveOnUpdate", "(", ")", ")", "{", "$", "script", ".=", "\"protected \\$archiveOnUpdate = true;\n\"", ";", "}", "if", "(", "$", "this", "->", "behavior", "->", "isArchiveOnDelete", "(", ")", ")", "{", "$", "script", ".=", "\"protected \\$archiveOnDelete = true;\n\"", ";", "}", "return", "$", "script", ";", "}" ]
Add object attributes to the built class. @param PHP5ObjectBuilder $builder @return string The PHP code to be added to the builder.
[ "Add", "object", "attributes", "to", "the", "built", "class", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php#L39-L60
propelorm/Propel
generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php
ArchivableBehaviorObjectBuilderModifier.preDelete
public function preDelete($builder) { if ($this->behavior->isArchiveOnDelete()) { return $this->behavior->renderTemplate('objectPreDelete', array( 'queryClassname' => $builder->getStubQueryBuilder()->getClassname(), 'isAddHooks' => $builder->getGeneratorConfig()->getBuildProperty('addHooks'), )); } }
php
public function preDelete($builder) { if ($this->behavior->isArchiveOnDelete()) { return $this->behavior->renderTemplate('objectPreDelete', array( 'queryClassname' => $builder->getStubQueryBuilder()->getClassname(), 'isAddHooks' => $builder->getGeneratorConfig()->getBuildProperty('addHooks'), )); } }
[ "public", "function", "preDelete", "(", "$", "builder", ")", "{", "if", "(", "$", "this", "->", "behavior", "->", "isArchiveOnDelete", "(", ")", ")", "{", "return", "$", "this", "->", "behavior", "->", "renderTemplate", "(", "'objectPreDelete'", ",", "array", "(", "'queryClassname'", "=>", "$", "builder", "->", "getStubQueryBuilder", "(", ")", "->", "getClassname", "(", ")", ",", "'isAddHooks'", "=>", "$", "builder", "->", "getGeneratorConfig", "(", ")", "->", "getBuildProperty", "(", "'addHooks'", ")", ",", ")", ")", ";", "}", "}" ]
Using preDelete rather than postDelete to allow user to retrieve related records and archive them before cascade deletion. The actual deletion is made by the query object, so the AR class must tell the query class to enable or disable archiveOnDelete. @return string the PHP code to be added to the builder
[ "Using", "preDelete", "rather", "than", "postDelete", "to", "allow", "user", "to", "retrieve", "related", "records", "and", "archive", "them", "before", "cascade", "deletion", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php#L111-L119
propelorm/Propel
generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php
ArchivableBehaviorObjectBuilderModifier.addPopulateFromArchive
public function addPopulateFromArchive($builder) { return $this->behavior->renderTemplate('objectPopulateFromArchive', array( 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), 'usesAutoIncrement' => $this->table->hasAutoIncrementPrimaryKey(), 'fakeAutoIncrementParameter' => $this->fakeAutoIncrementPrimaryKeyForConcreteInheritance(), 'objectClassname' => $this->builder->getObjectClassname(), 'columns' => $this->table->getColumns(), )); }
php
public function addPopulateFromArchive($builder) { return $this->behavior->renderTemplate('objectPopulateFromArchive', array( 'archiveTablePhpName' => $this->behavior->getArchiveTablePhpName($builder), 'usesAutoIncrement' => $this->table->hasAutoIncrementPrimaryKey(), 'fakeAutoIncrementParameter' => $this->fakeAutoIncrementPrimaryKeyForConcreteInheritance(), 'objectClassname' => $this->builder->getObjectClassname(), 'columns' => $this->table->getColumns(), )); }
[ "public", "function", "addPopulateFromArchive", "(", "$", "builder", ")", "{", "return", "$", "this", "->", "behavior", "->", "renderTemplate", "(", "'objectPopulateFromArchive'", ",", "array", "(", "'archiveTablePhpName'", "=>", "$", "this", "->", "behavior", "->", "getArchiveTablePhpName", "(", "$", "builder", ")", ",", "'usesAutoIncrement'", "=>", "$", "this", "->", "table", "->", "hasAutoIncrementPrimaryKey", "(", ")", ",", "'fakeAutoIncrementParameter'", "=>", "$", "this", "->", "fakeAutoIncrementPrimaryKeyForConcreteInheritance", "(", ")", ",", "'objectClassname'", "=>", "$", "this", "->", "builder", "->", "getObjectClassname", "(", ")", ",", "'columns'", "=>", "$", "this", "->", "table", "->", "getColumns", "(", ")", ",", ")", ")", ";", "}" ]
Generates a method to populate the current AR object based on an archive object. This method is necessary because the archive's copyInto() may include the archived_at column and therefore cannot be used. Besides, the way autoincremented PKs are handled should be explicit. @return string the PHP code to be added to the builder
[ "Generates", "a", "method", "to", "populate", "the", "current", "AR", "object", "based", "on", "an", "archive", "object", ".", "This", "method", "is", "necessary", "because", "the", "archive", "s", "copyInto", "()", "may", "include", "the", "archived_at", "column", "and", "therefore", "cannot", "be", "used", ".", "Besides", "the", "way", "autoincremented", "PKs", "are", "handled", "should", "be", "explicit", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php#L191-L200
propelorm/Propel
generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php
ArchivableBehaviorObjectBuilderModifier.fakeAutoIncrementPrimaryKeyForConcreteInheritance
public function fakeAutoIncrementPrimaryKeyForConcreteInheritance() { if ($this->table->hasBehavior('concrete_inheritance')) { $concrete_inheritance_behavior = $this->table->getBehavior('concrete_inheritance'); $database = $this->table->getDatabase(); $tableName = $database->getTablePrefix() . $concrete_inheritance_behavior->getParameter('extends'); if ($database->getPlatform()->supportsSchemas() && $concrete_inheritance_behavior->getParameter('schema')) { $tableName = $concrete_inheritance_behavior->getParameter('schema') . '.' . $tableName; } if (($parent_table = $database->getTable($tableName))) { return $parent_table->hasBehavior('archivable') && $parent_table->hasAutoIncrementPrimaryKey(); } } return false; }
php
public function fakeAutoIncrementPrimaryKeyForConcreteInheritance() { if ($this->table->hasBehavior('concrete_inheritance')) { $concrete_inheritance_behavior = $this->table->getBehavior('concrete_inheritance'); $database = $this->table->getDatabase(); $tableName = $database->getTablePrefix() . $concrete_inheritance_behavior->getParameter('extends'); if ($database->getPlatform()->supportsSchemas() && $concrete_inheritance_behavior->getParameter('schema')) { $tableName = $concrete_inheritance_behavior->getParameter('schema') . '.' . $tableName; } if (($parent_table = $database->getTable($tableName))) { return $parent_table->hasBehavior('archivable') && $parent_table->hasAutoIncrementPrimaryKey(); } } return false; }
[ "public", "function", "fakeAutoIncrementPrimaryKeyForConcreteInheritance", "(", ")", "{", "if", "(", "$", "this", "->", "table", "->", "hasBehavior", "(", "'concrete_inheritance'", ")", ")", "{", "$", "concrete_inheritance_behavior", "=", "$", "this", "->", "table", "->", "getBehavior", "(", "'concrete_inheritance'", ")", ";", "$", "database", "=", "$", "this", "->", "table", "->", "getDatabase", "(", ")", ";", "$", "tableName", "=", "$", "database", "->", "getTablePrefix", "(", ")", ".", "$", "concrete_inheritance_behavior", "->", "getParameter", "(", "'extends'", ")", ";", "if", "(", "$", "database", "->", "getPlatform", "(", ")", "->", "supportsSchemas", "(", ")", "&&", "$", "concrete_inheritance_behavior", "->", "getParameter", "(", "'schema'", ")", ")", "{", "$", "tableName", "=", "$", "concrete_inheritance_behavior", "->", "getParameter", "(", "'schema'", ")", ".", "'.'", ".", "$", "tableName", ";", "}", "if", "(", "(", "$", "parent_table", "=", "$", "database", "->", "getTable", "(", "$", "tableName", ")", ")", ")", "{", "return", "$", "parent_table", "->", "hasBehavior", "(", "'archivable'", ")", "&&", "$", "parent_table", "->", "hasAutoIncrementPrimaryKey", "(", ")", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the current table uses concrete_inheritance, and if it's parent has an auto-increment primary key. In this case, we need to define the populateFromArchive() method with the second parameter, in order to comply with php strict standards. The parameter is not used (PKs are inserted regardless if it is set to true or false). @return boolean
[ "Checks", "if", "the", "current", "table", "uses", "concrete_inheritance", "and", "if", "it", "s", "parent", "has", "an", "auto", "-", "increment", "primary", "key", ".", "In", "this", "case", "we", "need", "to", "define", "the", "populateFromArchive", "()", "method", "with", "the", "second", "parameter", "in", "order", "to", "comply", "with", "php", "strict", "standards", ".", "The", "parameter", "is", "not", "used", "(", "PKs", "are", "inserted", "regardless", "if", "it", "is", "set", "to", "true", "or", "false", ")", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/archivable/ArchivableBehaviorObjectBuilderModifier.php#L211-L229
propelorm/Propel
runtime/lib/parser/yaml/sfYamlParser.php
sfYamlParser.parseValue
protected function parseValue($value) { if ('*' === substr($value, 0, 1)) { if (false !== $pos = strpos($value, '#')) { $value = substr($value, 1, $pos - 2); } else { $value = substr($value, 1); } if (!array_key_exists($value, $this->refs)) { throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine)); } return $this->refs[$value]; } if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); } else { return sfYamlInline::load($value); } }
php
protected function parseValue($value) { if ('*' === substr($value, 0, 1)) { if (false !== $pos = strpos($value, '#')) { $value = substr($value, 1, $pos - 2); } else { $value = substr($value, 1); } if (!array_key_exists($value, $this->refs)) { throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine)); } return $this->refs[$value]; } if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); } else { return sfYamlInline::load($value); } }
[ "protected", "function", "parseValue", "(", "$", "value", ")", "{", "if", "(", "'*'", "===", "substr", "(", "$", "value", ",", "0", ",", "1", ")", ")", "{", "if", "(", "false", "!==", "$", "pos", "=", "strpos", "(", "$", "value", ",", "'#'", ")", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ",", "$", "pos", "-", "2", ")", ";", "}", "else", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "value", ",", "$", "this", "->", "refs", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Reference \"%s\" does not exist (%s).'", ",", "$", "value", ",", "$", "this", "->", "currentLine", ")", ")", ";", "}", "return", "$", "this", "->", "refs", "[", "$", "value", "]", ";", "}", "if", "(", "preg_match", "(", "'/^(?P<separator>\\||>)(?P<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?P<comments> +#.*)?$/'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "modifiers", "=", "isset", "(", "$", "matches", "[", "'modifiers'", "]", ")", "?", "$", "matches", "[", "'modifiers'", "]", ":", "''", ";", "return", "$", "this", "->", "parseFoldedScalar", "(", "$", "matches", "[", "'separator'", "]", ",", "preg_replace", "(", "'#\\d+#'", ",", "''", ",", "$", "modifiers", ")", ",", "intval", "(", "abs", "(", "$", "modifiers", ")", ")", ")", ";", "}", "else", "{", "return", "sfYamlInline", "::", "load", "(", "$", "value", ")", ";", "}", "}" ]
Parses a YAML value. @param string $value A YAML value @return mixed A PHP value
[ "Parses", "a", "YAML", "value", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlParser.php#L311-L334
propelorm/Propel
runtime/lib/parser/yaml/sfYamlParser.php
sfYamlParser.parseFoldedScalar
protected function parseFoldedScalar($separator, $indicator = '', $indentation = 0) { $separator = '|' == $separator ? "\n" : ' '; $text = ''; $notEOF = $this->moveToNextLine(); while ($notEOF && $this->isCurrentLineBlank()) { $text .= "\n"; $notEOF = $this->moveToNextLine(); } if (!$notEOF) { return ''; } if (!preg_match('#^(?P<indent>'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P<text>.*)$#u', $this->currentLine, $matches)) { $this->moveToPreviousLine(); return ''; } $textIndent = $matches['indent']; $previousIndent = 0; $text .= $matches['text'].$separator; while ($this->currentLineNb + 1 < count($this->lines)) { $this->moveToNextLine(); if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#u', $this->currentLine, $matches)) { if (' ' == $separator && $previousIndent != $matches['indent']) { $text = substr($text, 0, -1)."\n"; } $previousIndent = $matches['indent']; $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator); } elseif (preg_match('#^(?P<text> *)$#', $this->currentLine, $matches)) { $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n"; } else { $this->moveToPreviousLine(); break; } } if (' ' == $separator) { // replace last separator by a newline $text = preg_replace('/ (\n*)$/', "\n$1", $text); } switch ($indicator) { case '': $text = preg_replace('#\n+$#s', "\n", $text); break; case '+': break; case '-': $text = preg_replace('#\n+$#s', '', $text); break; } return $text; }
php
protected function parseFoldedScalar($separator, $indicator = '', $indentation = 0) { $separator = '|' == $separator ? "\n" : ' '; $text = ''; $notEOF = $this->moveToNextLine(); while ($notEOF && $this->isCurrentLineBlank()) { $text .= "\n"; $notEOF = $this->moveToNextLine(); } if (!$notEOF) { return ''; } if (!preg_match('#^(?P<indent>'.($indentation ? str_repeat(' ', $indentation) : ' +').')(?P<text>.*)$#u', $this->currentLine, $matches)) { $this->moveToPreviousLine(); return ''; } $textIndent = $matches['indent']; $previousIndent = 0; $text .= $matches['text'].$separator; while ($this->currentLineNb + 1 < count($this->lines)) { $this->moveToNextLine(); if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#u', $this->currentLine, $matches)) { if (' ' == $separator && $previousIndent != $matches['indent']) { $text = substr($text, 0, -1)."\n"; } $previousIndent = $matches['indent']; $text .= str_repeat(' ', $diff = strlen($matches['indent']) - strlen($textIndent)).$matches['text'].($diff ? "\n" : $separator); } elseif (preg_match('#^(?P<text> *)$#', $this->currentLine, $matches)) { $text .= preg_replace('#^ {1,'.strlen($textIndent).'}#', '', $matches['text'])."\n"; } else { $this->moveToPreviousLine(); break; } } if (' ' == $separator) { // replace last separator by a newline $text = preg_replace('/ (\n*)$/', "\n$1", $text); } switch ($indicator) { case '': $text = preg_replace('#\n+$#s', "\n", $text); break; case '+': break; case '-': $text = preg_replace('#\n+$#s', '', $text); break; } return $text; }
[ "protected", "function", "parseFoldedScalar", "(", "$", "separator", ",", "$", "indicator", "=", "''", ",", "$", "indentation", "=", "0", ")", "{", "$", "separator", "=", "'|'", "==", "$", "separator", "?", "\"\\n\"", ":", "' '", ";", "$", "text", "=", "''", ";", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ";", "while", "(", "$", "notEOF", "&&", "$", "this", "->", "isCurrentLineBlank", "(", ")", ")", "{", "$", "text", ".=", "\"\\n\"", ";", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ";", "}", "if", "(", "!", "$", "notEOF", ")", "{", "return", "''", ";", "}", "if", "(", "!", "preg_match", "(", "'#^(?P<indent>'", ".", "(", "$", "indentation", "?", "str_repeat", "(", "' '", ",", "$", "indentation", ")", ":", "' +'", ")", ".", "')(?P<text>.*)$#u'", ",", "$", "this", "->", "currentLine", ",", "$", "matches", ")", ")", "{", "$", "this", "->", "moveToPreviousLine", "(", ")", ";", "return", "''", ";", "}", "$", "textIndent", "=", "$", "matches", "[", "'indent'", "]", ";", "$", "previousIndent", "=", "0", ";", "$", "text", ".=", "$", "matches", "[", "'text'", "]", ".", "$", "separator", ";", "while", "(", "$", "this", "->", "currentLineNb", "+", "1", "<", "count", "(", "$", "this", "->", "lines", ")", ")", "{", "$", "this", "->", "moveToNextLine", "(", ")", ";", "if", "(", "preg_match", "(", "'#^(?P<indent> {'", ".", "strlen", "(", "$", "textIndent", ")", ".", "',})(?P<text>.+)$#u'", ",", "$", "this", "->", "currentLine", ",", "$", "matches", ")", ")", "{", "if", "(", "' '", "==", "$", "separator", "&&", "$", "previousIndent", "!=", "$", "matches", "[", "'indent'", "]", ")", "{", "$", "text", "=", "substr", "(", "$", "text", ",", "0", ",", "-", "1", ")", ".", "\"\\n\"", ";", "}", "$", "previousIndent", "=", "$", "matches", "[", "'indent'", "]", ";", "$", "text", ".=", "str_repeat", "(", "' '", ",", "$", "diff", "=", "strlen", "(", "$", "matches", "[", "'indent'", "]", ")", "-", "strlen", "(", "$", "textIndent", ")", ")", ".", "$", "matches", "[", "'text'", "]", ".", "(", "$", "diff", "?", "\"\\n\"", ":", "$", "separator", ")", ";", "}", "elseif", "(", "preg_match", "(", "'#^(?P<text> *)$#'", ",", "$", "this", "->", "currentLine", ",", "$", "matches", ")", ")", "{", "$", "text", ".=", "preg_replace", "(", "'#^ {1,'", ".", "strlen", "(", "$", "textIndent", ")", ".", "'}#'", ",", "''", ",", "$", "matches", "[", "'text'", "]", ")", ".", "\"\\n\"", ";", "}", "else", "{", "$", "this", "->", "moveToPreviousLine", "(", ")", ";", "break", ";", "}", "}", "if", "(", "' '", "==", "$", "separator", ")", "{", "// replace last separator by a newline", "$", "text", "=", "preg_replace", "(", "'/ (\\n*)$/'", ",", "\"\\n$1\"", ",", "$", "text", ")", ";", "}", "switch", "(", "$", "indicator", ")", "{", "case", "''", ":", "$", "text", "=", "preg_replace", "(", "'#\\n+$#s'", ",", "\"\\n\"", ",", "$", "text", ")", ";", "break", ";", "case", "'+'", ":", "break", ";", "case", "'-'", ":", "$", "text", "=", "preg_replace", "(", "'#\\n+$#s'", ",", "''", ",", "$", "text", ")", ";", "break", ";", "}", "return", "$", "text", ";", "}" ]
Parses a folded scalar. @param string $separator The separator that was used to begin this folded scalar (| or >) @param string $indicator The indicator that was used to begin this folded scalar (+ or -) @param integer $indentation The indentation that was used to begin this folded scalar @return string The text value
[ "Parses", "a", "folded", "scalar", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlParser.php#L345-L408
propelorm/Propel
runtime/lib/parser/yaml/sfYamlParser.php
sfYamlParser.isNextLineIndented
protected function isNextLineIndented() { $currentIndentation = $this->getCurrentLineIndentation(); $notEOF = $this->moveToNextLine(); while ($notEOF && $this->isCurrentLineEmpty()) { $notEOF = $this->moveToNextLine(); } if (false === $notEOF) { return false; } $ret = false; if ($this->getCurrentLineIndentation() <= $currentIndentation) { $ret = true; } $this->moveToPreviousLine(); return $ret; }
php
protected function isNextLineIndented() { $currentIndentation = $this->getCurrentLineIndentation(); $notEOF = $this->moveToNextLine(); while ($notEOF && $this->isCurrentLineEmpty()) { $notEOF = $this->moveToNextLine(); } if (false === $notEOF) { return false; } $ret = false; if ($this->getCurrentLineIndentation() <= $currentIndentation) { $ret = true; } $this->moveToPreviousLine(); return $ret; }
[ "protected", "function", "isNextLineIndented", "(", ")", "{", "$", "currentIndentation", "=", "$", "this", "->", "getCurrentLineIndentation", "(", ")", ";", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ";", "while", "(", "$", "notEOF", "&&", "$", "this", "->", "isCurrentLineEmpty", "(", ")", ")", "{", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ";", "}", "if", "(", "false", "===", "$", "notEOF", ")", "{", "return", "false", ";", "}", "$", "ret", "=", "false", ";", "if", "(", "$", "this", "->", "getCurrentLineIndentation", "(", ")", "<=", "$", "currentIndentation", ")", "{", "$", "ret", "=", "true", ";", "}", "$", "this", "->", "moveToPreviousLine", "(", ")", ";", "return", "$", "ret", ";", "}" ]
Returns true if the next line is indented. @return Boolean Returns true if the next line is indented, false otherwise
[ "Returns", "true", "if", "the", "next", "line", "is", "indented", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/parser/yaml/sfYamlParser.php#L415-L436
propelorm/Propel
generator/lib/model/VendorInfo.php
VendorInfo.getMergedVendorInfo
public function getMergedVendorInfo(VendorInfo $merge) { $newParams = array_merge($this->getParameters(), $merge->getParameters()); $newInfo = new VendorInfo($this->getType()); $newInfo->setParameters($newParams); return $newInfo; }
php
public function getMergedVendorInfo(VendorInfo $merge) { $newParams = array_merge($this->getParameters(), $merge->getParameters()); $newInfo = new VendorInfo($this->getType()); $newInfo->setParameters($newParams); return $newInfo; }
[ "public", "function", "getMergedVendorInfo", "(", "VendorInfo", "$", "merge", ")", "{", "$", "newParams", "=", "array_merge", "(", "$", "this", "->", "getParameters", "(", ")", ",", "$", "merge", "->", "getParameters", "(", ")", ")", ";", "$", "newInfo", "=", "new", "VendorInfo", "(", "$", "this", "->", "getType", "(", ")", ")", ";", "$", "newInfo", "->", "setParameters", "(", "$", "newParams", ")", ";", "return", "$", "newInfo", ";", "}" ]
Gets a new merged VendorInfo object. @param VendorInfo $info @return VendorInfo new object with merged parameters
[ "Gets", "a", "new", "merged", "VendorInfo", "object", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/VendorInfo.php#L165-L172
propelorm/Propel
runtime/lib/adapter/DBPostgres.php
DBPostgres.doExplainPlan
public function doExplainPlan(PropelPDO $con, $query) { if ($query instanceof ModelCriteria) { $params = array(); $dbMap = Propel::getDatabaseMap($query->getDbName()); $sql = BasePeer::createSelectSql($query, $params); } else { $sql = $query; } $stmt = $con->prepare($this->getExplainPlanQuery($sql)); if ($query instanceof ModelCriteria) { $this->bindValues($stmt, $params, $dbMap); } $stmt->execute(); return $stmt; }
php
public function doExplainPlan(PropelPDO $con, $query) { if ($query instanceof ModelCriteria) { $params = array(); $dbMap = Propel::getDatabaseMap($query->getDbName()); $sql = BasePeer::createSelectSql($query, $params); } else { $sql = $query; } $stmt = $con->prepare($this->getExplainPlanQuery($sql)); if ($query instanceof ModelCriteria) { $this->bindValues($stmt, $params, $dbMap); } $stmt->execute(); return $stmt; }
[ "public", "function", "doExplainPlan", "(", "PropelPDO", "$", "con", ",", "$", "query", ")", "{", "if", "(", "$", "query", "instanceof", "ModelCriteria", ")", "{", "$", "params", "=", "array", "(", ")", ";", "$", "dbMap", "=", "Propel", "::", "getDatabaseMap", "(", "$", "query", "->", "getDbName", "(", ")", ")", ";", "$", "sql", "=", "BasePeer", "::", "createSelectSql", "(", "$", "query", ",", "$", "params", ")", ";", "}", "else", "{", "$", "sql", "=", "$", "query", ";", "}", "$", "stmt", "=", "$", "con", "->", "prepare", "(", "$", "this", "->", "getExplainPlanQuery", "(", "$", "sql", ")", ")", ";", "if", "(", "$", "query", "instanceof", "ModelCriteria", ")", "{", "$", "this", "->", "bindValues", "(", "$", "stmt", ",", "$", "params", ",", "$", "dbMap", ")", ";", "}", "$", "stmt", "->", "execute", "(", ")", ";", "return", "$", "stmt", ";", "}" ]
Do Explain Plan for query object or query string @param PropelPDO $con propel connection @param ModelCriteria|string $query query the criteria or the query string @throws PropelException @return PDOStatement A PDO statement executed using the connection, ready to be fetched
[ "Do", "Explain", "Plan", "for", "query", "object", "or", "query", "string" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBPostgres.php#L220-L239
propelorm/Propel
generator/lib/model/diff/PropelTableComparator.php
PropelTableComparator.compareColumns
public function compareColumns($caseInsensitive = false) { $fromTableColumns = $this->getFromTable()->getColumns(); $toTableColumns = $this->getToTable()->getColumns(); $columnDifferences = 0; // check for new columns in $toTable foreach ($toTableColumns as $column) { if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive)) { $this->tableDiff->addAddedColumn($column->getName(), $column); $columnDifferences++; } } // check for removed columns in $toTable foreach ($fromTableColumns as $column) { if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive)) { $this->tableDiff->addRemovedColumn($column->getName(), $column); $columnDifferences++; } } // check for column differences foreach ($fromTableColumns as $fromColumn) { if ($this->getToTable()->hasColumn($fromColumn->getName(), $caseInsensitive)) { $toColumn = $this->getToTable()->getColumn($fromColumn->getName(), $caseInsensitive); $columnDiff = PropelColumnComparator::computeDiff($fromColumn, $toColumn); if ($columnDiff) { $this->tableDiff->addModifiedColumn($fromColumn->getName(), $columnDiff); $columnDifferences++; } } } // check for column renamings foreach ($this->tableDiff->getAddedColumns() as $addedColumnName => $addedColumn) { foreach ($this->tableDiff->getRemovedColumns() as $removedColumnName => $removedColumn) { if (!PropelColumnComparator::computeDiff($addedColumn, $removedColumn)) { // no difference except the name, that's probably a renaming $this->tableDiff->addRenamedColumn($removedColumn, $addedColumn); $this->tableDiff->removeAddedColumn($addedColumnName); $this->tableDiff->removeRemovedColumn($removedColumnName); $columnDifferences--; // skip to the next added column break; } } } return $columnDifferences; }
php
public function compareColumns($caseInsensitive = false) { $fromTableColumns = $this->getFromTable()->getColumns(); $toTableColumns = $this->getToTable()->getColumns(); $columnDifferences = 0; // check for new columns in $toTable foreach ($toTableColumns as $column) { if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive)) { $this->tableDiff->addAddedColumn($column->getName(), $column); $columnDifferences++; } } // check for removed columns in $toTable foreach ($fromTableColumns as $column) { if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive)) { $this->tableDiff->addRemovedColumn($column->getName(), $column); $columnDifferences++; } } // check for column differences foreach ($fromTableColumns as $fromColumn) { if ($this->getToTable()->hasColumn($fromColumn->getName(), $caseInsensitive)) { $toColumn = $this->getToTable()->getColumn($fromColumn->getName(), $caseInsensitive); $columnDiff = PropelColumnComparator::computeDiff($fromColumn, $toColumn); if ($columnDiff) { $this->tableDiff->addModifiedColumn($fromColumn->getName(), $columnDiff); $columnDifferences++; } } } // check for column renamings foreach ($this->tableDiff->getAddedColumns() as $addedColumnName => $addedColumn) { foreach ($this->tableDiff->getRemovedColumns() as $removedColumnName => $removedColumn) { if (!PropelColumnComparator::computeDiff($addedColumn, $removedColumn)) { // no difference except the name, that's probably a renaming $this->tableDiff->addRenamedColumn($removedColumn, $addedColumn); $this->tableDiff->removeAddedColumn($addedColumnName); $this->tableDiff->removeRemovedColumn($removedColumnName); $columnDifferences--; // skip to the next added column break; } } } return $columnDifferences; }
[ "public", "function", "compareColumns", "(", "$", "caseInsensitive", "=", "false", ")", "{", "$", "fromTableColumns", "=", "$", "this", "->", "getFromTable", "(", ")", "->", "getColumns", "(", ")", ";", "$", "toTableColumns", "=", "$", "this", "->", "getToTable", "(", ")", "->", "getColumns", "(", ")", ";", "$", "columnDifferences", "=", "0", ";", "// check for new columns in $toTable", "foreach", "(", "$", "toTableColumns", "as", "$", "column", ")", "{", "if", "(", "!", "$", "this", "->", "getFromTable", "(", ")", "->", "hasColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", ")", "{", "$", "this", "->", "tableDiff", "->", "addAddedColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "column", ")", ";", "$", "columnDifferences", "++", ";", "}", "}", "// check for removed columns in $toTable", "foreach", "(", "$", "fromTableColumns", "as", "$", "column", ")", "{", "if", "(", "!", "$", "this", "->", "getToTable", "(", ")", "->", "hasColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", ")", "{", "$", "this", "->", "tableDiff", "->", "addRemovedColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "column", ")", ";", "$", "columnDifferences", "++", ";", "}", "}", "// check for column differences", "foreach", "(", "$", "fromTableColumns", "as", "$", "fromColumn", ")", "{", "if", "(", "$", "this", "->", "getToTable", "(", ")", "->", "hasColumn", "(", "$", "fromColumn", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", ")", "{", "$", "toColumn", "=", "$", "this", "->", "getToTable", "(", ")", "->", "getColumn", "(", "$", "fromColumn", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", ";", "$", "columnDiff", "=", "PropelColumnComparator", "::", "computeDiff", "(", "$", "fromColumn", ",", "$", "toColumn", ")", ";", "if", "(", "$", "columnDiff", ")", "{", "$", "this", "->", "tableDiff", "->", "addModifiedColumn", "(", "$", "fromColumn", "->", "getName", "(", ")", ",", "$", "columnDiff", ")", ";", "$", "columnDifferences", "++", ";", "}", "}", "}", "// check for column renamings", "foreach", "(", "$", "this", "->", "tableDiff", "->", "getAddedColumns", "(", ")", "as", "$", "addedColumnName", "=>", "$", "addedColumn", ")", "{", "foreach", "(", "$", "this", "->", "tableDiff", "->", "getRemovedColumns", "(", ")", "as", "$", "removedColumnName", "=>", "$", "removedColumn", ")", "{", "if", "(", "!", "PropelColumnComparator", "::", "computeDiff", "(", "$", "addedColumn", ",", "$", "removedColumn", ")", ")", "{", "// no difference except the name, that's probably a renaming", "$", "this", "->", "tableDiff", "->", "addRenamedColumn", "(", "$", "removedColumn", ",", "$", "addedColumn", ")", ";", "$", "this", "->", "tableDiff", "->", "removeAddedColumn", "(", "$", "addedColumnName", ")", ";", "$", "this", "->", "tableDiff", "->", "removeRemovedColumn", "(", "$", "removedColumnName", ")", ";", "$", "columnDifferences", "--", ";", "// skip to the next added column", "break", ";", "}", "}", "}", "return", "$", "columnDifferences", ";", "}" ]
Compare the columns of the fromTable and the toTable, and modifies the inner tableDiff if necessary. Returns the number of differences. @param boolean $caseInsensitive Whether the comparison is case insensitive. False by default. @return integer The number of column differences
[ "Compare", "the", "columns", "of", "the", "fromTable", "and", "the", "toTable", "and", "modifies", "the", "inner", "tableDiff", "if", "necessary", ".", "Returns", "the", "number", "of", "differences", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelTableComparator.php#L113-L163
propelorm/Propel
generator/lib/model/diff/PropelTableComparator.php
PropelTableComparator.comparePrimaryKeys
public function comparePrimaryKeys($caseInsensitive = false) { $pkDifferences = 0; $fromTablePk = $this->getFromTable()->getPrimaryKey(); $toTablePk = $this->getToTable()->getPrimaryKey(); // check for new pk columns in $toTable foreach ($toTablePk as $column) { if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive) || !$this->getFromTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { $this->tableDiff->addAddedPkColumn($column->getName(), $column); $pkDifferences++; } } // check for removed pk columns in $toTable foreach ($fromTablePk as $column) { if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive) || !$this->getToTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { $this->tableDiff->addRemovedPkColumn($column->getName(), $column); $pkDifferences++; } } // check for column renamings foreach ($this->tableDiff->getAddedPkColumns() as $addedColumnName => $addedColumn) { foreach ($this->tableDiff->getRemovedPkColumns() as $removedColumnName => $removedColumn) { if (!PropelColumnComparator::computeDiff($addedColumn, $removedColumn)) { // no difference except the name, that's probably a renaming $this->tableDiff->addRenamedPkColumn($removedColumn, $addedColumn); $this->tableDiff->removeAddedPkColumn($addedColumnName); $this->tableDiff->removeRemovedPkColumn($removedColumnName); $pkDifferences--; // skip to the next added column break; } } } return $pkDifferences; }
php
public function comparePrimaryKeys($caseInsensitive = false) { $pkDifferences = 0; $fromTablePk = $this->getFromTable()->getPrimaryKey(); $toTablePk = $this->getToTable()->getPrimaryKey(); // check for new pk columns in $toTable foreach ($toTablePk as $column) { if (!$this->getFromTable()->hasColumn($column->getName(), $caseInsensitive) || !$this->getFromTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { $this->tableDiff->addAddedPkColumn($column->getName(), $column); $pkDifferences++; } } // check for removed pk columns in $toTable foreach ($fromTablePk as $column) { if (!$this->getToTable()->hasColumn($column->getName(), $caseInsensitive) || !$this->getToTable()->getColumn($column->getName(), $caseInsensitive)->isPrimaryKey()) { $this->tableDiff->addRemovedPkColumn($column->getName(), $column); $pkDifferences++; } } // check for column renamings foreach ($this->tableDiff->getAddedPkColumns() as $addedColumnName => $addedColumn) { foreach ($this->tableDiff->getRemovedPkColumns() as $removedColumnName => $removedColumn) { if (!PropelColumnComparator::computeDiff($addedColumn, $removedColumn)) { // no difference except the name, that's probably a renaming $this->tableDiff->addRenamedPkColumn($removedColumn, $addedColumn); $this->tableDiff->removeAddedPkColumn($addedColumnName); $this->tableDiff->removeRemovedPkColumn($removedColumnName); $pkDifferences--; // skip to the next added column break; } } } return $pkDifferences; }
[ "public", "function", "comparePrimaryKeys", "(", "$", "caseInsensitive", "=", "false", ")", "{", "$", "pkDifferences", "=", "0", ";", "$", "fromTablePk", "=", "$", "this", "->", "getFromTable", "(", ")", "->", "getPrimaryKey", "(", ")", ";", "$", "toTablePk", "=", "$", "this", "->", "getToTable", "(", ")", "->", "getPrimaryKey", "(", ")", ";", "// check for new pk columns in $toTable", "foreach", "(", "$", "toTablePk", "as", "$", "column", ")", "{", "if", "(", "!", "$", "this", "->", "getFromTable", "(", ")", "->", "hasColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", "||", "!", "$", "this", "->", "getFromTable", "(", ")", "->", "getColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", "->", "isPrimaryKey", "(", ")", ")", "{", "$", "this", "->", "tableDiff", "->", "addAddedPkColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "column", ")", ";", "$", "pkDifferences", "++", ";", "}", "}", "// check for removed pk columns in $toTable", "foreach", "(", "$", "fromTablePk", "as", "$", "column", ")", "{", "if", "(", "!", "$", "this", "->", "getToTable", "(", ")", "->", "hasColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", "||", "!", "$", "this", "->", "getToTable", "(", ")", "->", "getColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "caseInsensitive", ")", "->", "isPrimaryKey", "(", ")", ")", "{", "$", "this", "->", "tableDiff", "->", "addRemovedPkColumn", "(", "$", "column", "->", "getName", "(", ")", ",", "$", "column", ")", ";", "$", "pkDifferences", "++", ";", "}", "}", "// check for column renamings", "foreach", "(", "$", "this", "->", "tableDiff", "->", "getAddedPkColumns", "(", ")", "as", "$", "addedColumnName", "=>", "$", "addedColumn", ")", "{", "foreach", "(", "$", "this", "->", "tableDiff", "->", "getRemovedPkColumns", "(", ")", "as", "$", "removedColumnName", "=>", "$", "removedColumn", ")", "{", "if", "(", "!", "PropelColumnComparator", "::", "computeDiff", "(", "$", "addedColumn", ",", "$", "removedColumn", ")", ")", "{", "// no difference except the name, that's probably a renaming", "$", "this", "->", "tableDiff", "->", "addRenamedPkColumn", "(", "$", "removedColumn", ",", "$", "addedColumn", ")", ";", "$", "this", "->", "tableDiff", "->", "removeAddedPkColumn", "(", "$", "addedColumnName", ")", ";", "$", "this", "->", "tableDiff", "->", "removeRemovedPkColumn", "(", "$", "removedColumnName", ")", ";", "$", "pkDifferences", "--", ";", "// skip to the next added column", "break", ";", "}", "}", "}", "return", "$", "pkDifferences", ";", "}" ]
Compare the primary keys of the fromTable and the toTable, and modifies the inner tableDiff if necessary. Returns the number of differences. @param boolean $caseInsensitive Whether the comparison is case insensitive. False by default. @return integer The number of primary key differences
[ "Compare", "the", "primary", "keys", "of", "the", "fromTable", "and", "the", "toTable", "and", "modifies", "the", "inner", "tableDiff", "if", "necessary", ".", "Returns", "the", "number", "of", "differences", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelTableComparator.php#L175-L213
propelorm/Propel
generator/lib/model/diff/PropelTableComparator.php
PropelTableComparator.compareIndices
public function compareIndices($caseInsensitive = false) { $indexDifferences = 0; $fromTableIndices = array_merge($this->getFromTable()->getIndices(), $this->getFromTable()->getUnices()); $toTableIndices = array_merge($this->getToTable()->getIndices(), $this->getToTable()->getUnices()); foreach ($toTableIndices as $toTableIndexPos => $toTableIndex) { foreach ($fromTableIndices as $fromTableIndexPos => $fromTableIndex) { if (PropelIndexComparator::computeDiff($fromTableIndex, $toTableIndex, $caseInsensitive) === false) { unset($fromTableIndices[$fromTableIndexPos]); unset($toTableIndices[$toTableIndexPos]); } else { $test = $caseInsensitive ? strtolower($fromTableIndex->getName()) == strtolower($toTableIndex->getName()) : $fromTableIndex->getName() == $toTableIndex->getName(); if ($test) { // same name, but different columns $this->tableDiff->addModifiedIndex($fromTableIndex->getName(), $fromTableIndex, $toTableIndex); unset($fromTableIndices[$fromTableIndexPos]); unset($toTableIndices[$toTableIndexPos]); $indexDifferences++; } } } } foreach ($fromTableIndices as $fromTableIndexPos => $fromTableIndex) { $this->tableDiff->addRemovedIndex($fromTableIndex->getName(), $fromTableIndex); $indexDifferences++; } foreach ($toTableIndices as $toTableIndexPos => $toTableIndex) { $this->tableDiff->addAddedIndex($toTableIndex->getName(), $toTableIndex); $indexDifferences++; } return $indexDifferences; }
php
public function compareIndices($caseInsensitive = false) { $indexDifferences = 0; $fromTableIndices = array_merge($this->getFromTable()->getIndices(), $this->getFromTable()->getUnices()); $toTableIndices = array_merge($this->getToTable()->getIndices(), $this->getToTable()->getUnices()); foreach ($toTableIndices as $toTableIndexPos => $toTableIndex) { foreach ($fromTableIndices as $fromTableIndexPos => $fromTableIndex) { if (PropelIndexComparator::computeDiff($fromTableIndex, $toTableIndex, $caseInsensitive) === false) { unset($fromTableIndices[$fromTableIndexPos]); unset($toTableIndices[$toTableIndexPos]); } else { $test = $caseInsensitive ? strtolower($fromTableIndex->getName()) == strtolower($toTableIndex->getName()) : $fromTableIndex->getName() == $toTableIndex->getName(); if ($test) { // same name, but different columns $this->tableDiff->addModifiedIndex($fromTableIndex->getName(), $fromTableIndex, $toTableIndex); unset($fromTableIndices[$fromTableIndexPos]); unset($toTableIndices[$toTableIndexPos]); $indexDifferences++; } } } } foreach ($fromTableIndices as $fromTableIndexPos => $fromTableIndex) { $this->tableDiff->addRemovedIndex($fromTableIndex->getName(), $fromTableIndex); $indexDifferences++; } foreach ($toTableIndices as $toTableIndexPos => $toTableIndex) { $this->tableDiff->addAddedIndex($toTableIndex->getName(), $toTableIndex); $indexDifferences++; } return $indexDifferences; }
[ "public", "function", "compareIndices", "(", "$", "caseInsensitive", "=", "false", ")", "{", "$", "indexDifferences", "=", "0", ";", "$", "fromTableIndices", "=", "array_merge", "(", "$", "this", "->", "getFromTable", "(", ")", "->", "getIndices", "(", ")", ",", "$", "this", "->", "getFromTable", "(", ")", "->", "getUnices", "(", ")", ")", ";", "$", "toTableIndices", "=", "array_merge", "(", "$", "this", "->", "getToTable", "(", ")", "->", "getIndices", "(", ")", ",", "$", "this", "->", "getToTable", "(", ")", "->", "getUnices", "(", ")", ")", ";", "foreach", "(", "$", "toTableIndices", "as", "$", "toTableIndexPos", "=>", "$", "toTableIndex", ")", "{", "foreach", "(", "$", "fromTableIndices", "as", "$", "fromTableIndexPos", "=>", "$", "fromTableIndex", ")", "{", "if", "(", "PropelIndexComparator", "::", "computeDiff", "(", "$", "fromTableIndex", ",", "$", "toTableIndex", ",", "$", "caseInsensitive", ")", "===", "false", ")", "{", "unset", "(", "$", "fromTableIndices", "[", "$", "fromTableIndexPos", "]", ")", ";", "unset", "(", "$", "toTableIndices", "[", "$", "toTableIndexPos", "]", ")", ";", "}", "else", "{", "$", "test", "=", "$", "caseInsensitive", "?", "strtolower", "(", "$", "fromTableIndex", "->", "getName", "(", ")", ")", "==", "strtolower", "(", "$", "toTableIndex", "->", "getName", "(", ")", ")", ":", "$", "fromTableIndex", "->", "getName", "(", ")", "==", "$", "toTableIndex", "->", "getName", "(", ")", ";", "if", "(", "$", "test", ")", "{", "// same name, but different columns", "$", "this", "->", "tableDiff", "->", "addModifiedIndex", "(", "$", "fromTableIndex", "->", "getName", "(", ")", ",", "$", "fromTableIndex", ",", "$", "toTableIndex", ")", ";", "unset", "(", "$", "fromTableIndices", "[", "$", "fromTableIndexPos", "]", ")", ";", "unset", "(", "$", "toTableIndices", "[", "$", "toTableIndexPos", "]", ")", ";", "$", "indexDifferences", "++", ";", "}", "}", "}", "}", "foreach", "(", "$", "fromTableIndices", "as", "$", "fromTableIndexPos", "=>", "$", "fromTableIndex", ")", "{", "$", "this", "->", "tableDiff", "->", "addRemovedIndex", "(", "$", "fromTableIndex", "->", "getName", "(", ")", ",", "$", "fromTableIndex", ")", ";", "$", "indexDifferences", "++", ";", "}", "foreach", "(", "$", "toTableIndices", "as", "$", "toTableIndexPos", "=>", "$", "toTableIndex", ")", "{", "$", "this", "->", "tableDiff", "->", "addAddedIndex", "(", "$", "toTableIndex", "->", "getName", "(", ")", ",", "$", "toTableIndex", ")", ";", "$", "indexDifferences", "++", ";", "}", "return", "$", "indexDifferences", ";", "}" ]
Compare the indices and unique indices of the fromTable and the toTable, and modifies the inner tableDiff if necessary. Returns the number of differences. @param boolean $caseInsensitive Whether the comparison is case insensitive. False by default. @return integer The number of index differences
[ "Compare", "the", "indices", "and", "unique", "indices", "of", "the", "fromTable", "and", "the", "toTable", "and", "modifies", "the", "inner", "tableDiff", "if", "necessary", ".", "Returns", "the", "number", "of", "differences", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelTableComparator.php#L225-L262
propelorm/Propel
generator/lib/model/diff/PropelTableComparator.php
PropelTableComparator.compareForeignKeys
public function compareForeignKeys($caseInsensitive = false) { $fkDifferences = 0; $fromTableFks = $this->getFromTable()->getForeignKeys(); $toTableFks = $this->getToTable()->getForeignKeys(); foreach ($fromTableFks as $fromTableFkPos => $fromTableFk) { foreach ($toTableFks as $toTableFkPos => $toTableFk) { if (PropelForeignKeyComparator::computeDiff($fromTableFk, $toTableFk, $caseInsensitive) === false) { unset($fromTableFks[$fromTableFkPos]); unset($toTableFks[$toTableFkPos]); } else { $test = $caseInsensitive ? strtolower($fromTableFk->getName()) == strtolower($toTableFk->getName()) : $fromTableFk->getName() == $toTableFk->getName(); if ($test) { // same name, but different columns $this->tableDiff->addModifiedFk($fromTableFk->getName(), $fromTableFk, $toTableFk); unset($fromTableFks[$fromTableFkPos]); unset($toTableFks[$toTableFkPos]); $fkDifferences++; } } } } foreach ($fromTableFks as $fromTableFkPos => $fromTableFk) { if (!$fromTableFk->isSkipSql() && !in_array($fromTableFk, $toTableFks)) { $this->tableDiff->addRemovedFk($fromTableFk->getName(), $fromTableFk); $fkDifferences++; } } foreach ($toTableFks as $toTableFkPos => $toTableFk) { if (!$toTableFk->isSkipSql() && !in_array($toTableFk, $fromTableFks)) { $this->tableDiff->addAddedFk($toTableFk->getName(), $toTableFk); $fkDifferences++; } } return $fkDifferences; }
php
public function compareForeignKeys($caseInsensitive = false) { $fkDifferences = 0; $fromTableFks = $this->getFromTable()->getForeignKeys(); $toTableFks = $this->getToTable()->getForeignKeys(); foreach ($fromTableFks as $fromTableFkPos => $fromTableFk) { foreach ($toTableFks as $toTableFkPos => $toTableFk) { if (PropelForeignKeyComparator::computeDiff($fromTableFk, $toTableFk, $caseInsensitive) === false) { unset($fromTableFks[$fromTableFkPos]); unset($toTableFks[$toTableFkPos]); } else { $test = $caseInsensitive ? strtolower($fromTableFk->getName()) == strtolower($toTableFk->getName()) : $fromTableFk->getName() == $toTableFk->getName(); if ($test) { // same name, but different columns $this->tableDiff->addModifiedFk($fromTableFk->getName(), $fromTableFk, $toTableFk); unset($fromTableFks[$fromTableFkPos]); unset($toTableFks[$toTableFkPos]); $fkDifferences++; } } } } foreach ($fromTableFks as $fromTableFkPos => $fromTableFk) { if (!$fromTableFk->isSkipSql() && !in_array($fromTableFk, $toTableFks)) { $this->tableDiff->addRemovedFk($fromTableFk->getName(), $fromTableFk); $fkDifferences++; } } foreach ($toTableFks as $toTableFkPos => $toTableFk) { if (!$toTableFk->isSkipSql() && !in_array($toTableFk, $fromTableFks)) { $this->tableDiff->addAddedFk($toTableFk->getName(), $toTableFk); $fkDifferences++; } } return $fkDifferences; }
[ "public", "function", "compareForeignKeys", "(", "$", "caseInsensitive", "=", "false", ")", "{", "$", "fkDifferences", "=", "0", ";", "$", "fromTableFks", "=", "$", "this", "->", "getFromTable", "(", ")", "->", "getForeignKeys", "(", ")", ";", "$", "toTableFks", "=", "$", "this", "->", "getToTable", "(", ")", "->", "getForeignKeys", "(", ")", ";", "foreach", "(", "$", "fromTableFks", "as", "$", "fromTableFkPos", "=>", "$", "fromTableFk", ")", "{", "foreach", "(", "$", "toTableFks", "as", "$", "toTableFkPos", "=>", "$", "toTableFk", ")", "{", "if", "(", "PropelForeignKeyComparator", "::", "computeDiff", "(", "$", "fromTableFk", ",", "$", "toTableFk", ",", "$", "caseInsensitive", ")", "===", "false", ")", "{", "unset", "(", "$", "fromTableFks", "[", "$", "fromTableFkPos", "]", ")", ";", "unset", "(", "$", "toTableFks", "[", "$", "toTableFkPos", "]", ")", ";", "}", "else", "{", "$", "test", "=", "$", "caseInsensitive", "?", "strtolower", "(", "$", "fromTableFk", "->", "getName", "(", ")", ")", "==", "strtolower", "(", "$", "toTableFk", "->", "getName", "(", ")", ")", ":", "$", "fromTableFk", "->", "getName", "(", ")", "==", "$", "toTableFk", "->", "getName", "(", ")", ";", "if", "(", "$", "test", ")", "{", "// same name, but different columns", "$", "this", "->", "tableDiff", "->", "addModifiedFk", "(", "$", "fromTableFk", "->", "getName", "(", ")", ",", "$", "fromTableFk", ",", "$", "toTableFk", ")", ";", "unset", "(", "$", "fromTableFks", "[", "$", "fromTableFkPos", "]", ")", ";", "unset", "(", "$", "toTableFks", "[", "$", "toTableFkPos", "]", ")", ";", "$", "fkDifferences", "++", ";", "}", "}", "}", "}", "foreach", "(", "$", "fromTableFks", "as", "$", "fromTableFkPos", "=>", "$", "fromTableFk", ")", "{", "if", "(", "!", "$", "fromTableFk", "->", "isSkipSql", "(", ")", "&&", "!", "in_array", "(", "$", "fromTableFk", ",", "$", "toTableFks", ")", ")", "{", "$", "this", "->", "tableDiff", "->", "addRemovedFk", "(", "$", "fromTableFk", "->", "getName", "(", ")", ",", "$", "fromTableFk", ")", ";", "$", "fkDifferences", "++", ";", "}", "}", "foreach", "(", "$", "toTableFks", "as", "$", "toTableFkPos", "=>", "$", "toTableFk", ")", "{", "if", "(", "!", "$", "toTableFk", "->", "isSkipSql", "(", ")", "&&", "!", "in_array", "(", "$", "toTableFk", ",", "$", "fromTableFks", ")", ")", "{", "$", "this", "->", "tableDiff", "->", "addAddedFk", "(", "$", "toTableFk", "->", "getName", "(", ")", ",", "$", "toTableFk", ")", ";", "$", "fkDifferences", "++", ";", "}", "}", "return", "$", "fkDifferences", ";", "}" ]
Compare the foreign keys of the fromTable and the toTable, and modifies the inner tableDiff if necessary. Returns the number of differences. @param boolean $caseInsensitive Whether the comparison is case insensitive. False by default. @return integer The number of foreign key differences
[ "Compare", "the", "foreign", "keys", "of", "the", "fromTable", "and", "the", "toTable", "and", "modifies", "the", "inner", "tableDiff", "if", "necessary", ".", "Returns", "the", "number", "of", "differences", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelTableComparator.php#L274-L315
propelorm/Propel
generator/lib/builder/util/XmlToDataSQL.php
XmlToDataSQL.transform
public function transform(PhingFile $xmlFile, Writer $out) { $this->sqlWriter = $out; // Reset some vars just in case this is being run multiple times. $this->currTableName = $this->currBuilder = null; $this->builderClazz = $this->generatorConfig->getBuilderClassname('datasql'); try { $fr = new FileReader($xmlFile); } catch (Exception $e) { throw new BuildException("XML File not found: " . $xmlFile->getAbsolutePath()); } $br = new BufferedReader($fr); $this->parser = new ExpatParser($br); $this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0); $this->parser->setHandler($this); try { $this->parser->parse(); } catch (Exception $e) { print $e->getMessage() . "\n"; $br->close(); } $br->close(); }
php
public function transform(PhingFile $xmlFile, Writer $out) { $this->sqlWriter = $out; // Reset some vars just in case this is being run multiple times. $this->currTableName = $this->currBuilder = null; $this->builderClazz = $this->generatorConfig->getBuilderClassname('datasql'); try { $fr = new FileReader($xmlFile); } catch (Exception $e) { throw new BuildException("XML File not found: " . $xmlFile->getAbsolutePath()); } $br = new BufferedReader($fr); $this->parser = new ExpatParser($br); $this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0); $this->parser->setHandler($this); try { $this->parser->parse(); } catch (Exception $e) { print $e->getMessage() . "\n"; $br->close(); } $br->close(); }
[ "public", "function", "transform", "(", "PhingFile", "$", "xmlFile", ",", "Writer", "$", "out", ")", "{", "$", "this", "->", "sqlWriter", "=", "$", "out", ";", "// Reset some vars just in case this is being run multiple times.", "$", "this", "->", "currTableName", "=", "$", "this", "->", "currBuilder", "=", "null", ";", "$", "this", "->", "builderClazz", "=", "$", "this", "->", "generatorConfig", "->", "getBuilderClassname", "(", "'datasql'", ")", ";", "try", "{", "$", "fr", "=", "new", "FileReader", "(", "$", "xmlFile", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "BuildException", "(", "\"XML File not found: \"", ".", "$", "xmlFile", "->", "getAbsolutePath", "(", ")", ")", ";", "}", "$", "br", "=", "new", "BufferedReader", "(", "$", "fr", ")", ";", "$", "this", "->", "parser", "=", "new", "ExpatParser", "(", "$", "br", ")", ";", "$", "this", "->", "parser", "->", "parserSetOption", "(", "XML_OPTION_CASE_FOLDING", ",", "0", ")", ";", "$", "this", "->", "parser", "->", "setHandler", "(", "$", "this", ")", ";", "try", "{", "$", "this", "->", "parser", "->", "parse", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "print", "$", "e", "->", "getMessage", "(", ")", ".", "\"\\n\"", ";", "$", "br", "->", "close", "(", ")", ";", "}", "$", "br", "->", "close", "(", ")", ";", "}" ]
Transform the data dump input file into SQL and writes it to the output stream. @param PhingFile $xmlFile @param Writer $out @throws BuildException
[ "Transform", "the", "data", "dump", "input", "file", "into", "SQL", "and", "writes", "it", "to", "the", "output", "stream", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/util/XmlToDataSQL.php#L114-L142
propelorm/Propel
generator/lib/builder/util/XmlToDataSQL.php
XmlToDataSQL.startElement
public function startElement($name, $attributes) { try { if ($name == "dataset") { // Clear any start/end DLL call_user_func(array($this->builderClazz, 'reset')); $this->sqlWriter->write(call_user_func(array($this->builderClazz, 'getDatabaseStartSql'))); } else { // we're processing a row of data // where tag name is phpName e.g. <BookReader .... /> $table = $this->database->getTableByPhpName($name); $columnValues = array(); foreach ($attributes as $name => $value) { $col = $table->getColumnByPhpName($name); $columnValues[] = new ColumnValue($col, iconv('utf-8', $this->encoding, $value)); } $data = new DataRow($table, $columnValues); if ($this->currTableName !== $table->getName()) { // new table encountered if ($this->currBuilder !== null) { $this->sqlWriter->write($this->currBuilder->getTableEndSql()); } $this->currTableName = $table->getName(); $this->currBuilder = $this->generatorConfig->getConfiguredBuilder($table, 'datasql'); $this->sqlWriter->write($this->currBuilder->getTableStartSql()); } // Write the SQL $this->sqlWriter->write($this->currBuilder->buildRowSql($data)); } } catch (Exception $e) { // Exceptions have traditionally not bubbled up nicely from the expat parser, // so we also print the stack trace here. print $e; throw $e; } }
php
public function startElement($name, $attributes) { try { if ($name == "dataset") { // Clear any start/end DLL call_user_func(array($this->builderClazz, 'reset')); $this->sqlWriter->write(call_user_func(array($this->builderClazz, 'getDatabaseStartSql'))); } else { // we're processing a row of data // where tag name is phpName e.g. <BookReader .... /> $table = $this->database->getTableByPhpName($name); $columnValues = array(); foreach ($attributes as $name => $value) { $col = $table->getColumnByPhpName($name); $columnValues[] = new ColumnValue($col, iconv('utf-8', $this->encoding, $value)); } $data = new DataRow($table, $columnValues); if ($this->currTableName !== $table->getName()) { // new table encountered if ($this->currBuilder !== null) { $this->sqlWriter->write($this->currBuilder->getTableEndSql()); } $this->currTableName = $table->getName(); $this->currBuilder = $this->generatorConfig->getConfiguredBuilder($table, 'datasql'); $this->sqlWriter->write($this->currBuilder->getTableStartSql()); } // Write the SQL $this->sqlWriter->write($this->currBuilder->buildRowSql($data)); } } catch (Exception $e) { // Exceptions have traditionally not bubbled up nicely from the expat parser, // so we also print the stack trace here. print $e; throw $e; } }
[ "public", "function", "startElement", "(", "$", "name", ",", "$", "attributes", ")", "{", "try", "{", "if", "(", "$", "name", "==", "\"dataset\"", ")", "{", "// Clear any start/end DLL", "call_user_func", "(", "array", "(", "$", "this", "->", "builderClazz", ",", "'reset'", ")", ")", ";", "$", "this", "->", "sqlWriter", "->", "write", "(", "call_user_func", "(", "array", "(", "$", "this", "->", "builderClazz", ",", "'getDatabaseStartSql'", ")", ")", ")", ";", "}", "else", "{", "// we're processing a row of data", "// where tag name is phpName e.g. <BookReader .... />", "$", "table", "=", "$", "this", "->", "database", "->", "getTableByPhpName", "(", "$", "name", ")", ";", "$", "columnValues", "=", "array", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "col", "=", "$", "table", "->", "getColumnByPhpName", "(", "$", "name", ")", ";", "$", "columnValues", "[", "]", "=", "new", "ColumnValue", "(", "$", "col", ",", "iconv", "(", "'utf-8'", ",", "$", "this", "->", "encoding", ",", "$", "value", ")", ")", ";", "}", "$", "data", "=", "new", "DataRow", "(", "$", "table", ",", "$", "columnValues", ")", ";", "if", "(", "$", "this", "->", "currTableName", "!==", "$", "table", "->", "getName", "(", ")", ")", "{", "// new table encountered", "if", "(", "$", "this", "->", "currBuilder", "!==", "null", ")", "{", "$", "this", "->", "sqlWriter", "->", "write", "(", "$", "this", "->", "currBuilder", "->", "getTableEndSql", "(", ")", ")", ";", "}", "$", "this", "->", "currTableName", "=", "$", "table", "->", "getName", "(", ")", ";", "$", "this", "->", "currBuilder", "=", "$", "this", "->", "generatorConfig", "->", "getConfiguredBuilder", "(", "$", "table", ",", "'datasql'", ")", ";", "$", "this", "->", "sqlWriter", "->", "write", "(", "$", "this", "->", "currBuilder", "->", "getTableStartSql", "(", ")", ")", ";", "}", "// Write the SQL", "$", "this", "->", "sqlWriter", "->", "write", "(", "$", "this", "->", "currBuilder", "->", "buildRowSql", "(", "$", "data", ")", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// Exceptions have traditionally not bubbled up nicely from the expat parser,", "// so we also print the stack trace here.", "print", "$", "e", ";", "throw", "$", "e", ";", "}", "}" ]
Handles opening elements of the xml file.
[ "Handles", "opening", "elements", "of", "the", "xml", "file", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/util/XmlToDataSQL.php#L147-L191
propelorm/Propel
generator/lib/builder/util/XmlToDataSQL.php
XmlToDataSQL.endElement
public function endElement($name) { if (self::DEBUG) { print("endElement(" . $name . ") called\n"); } if ($name == "dataset") { if ($this->currBuilder !== null) { $this->sqlWriter->write($this->currBuilder->getTableEndSql()); } $this->sqlWriter->write(call_user_func(array($this->builderClazz, 'getDatabaseEndSql'))); } }
php
public function endElement($name) { if (self::DEBUG) { print("endElement(" . $name . ") called\n"); } if ($name == "dataset") { if ($this->currBuilder !== null) { $this->sqlWriter->write($this->currBuilder->getTableEndSql()); } $this->sqlWriter->write(call_user_func(array($this->builderClazz, 'getDatabaseEndSql'))); } }
[ "public", "function", "endElement", "(", "$", "name", ")", "{", "if", "(", "self", "::", "DEBUG", ")", "{", "print", "(", "\"endElement(\"", ".", "$", "name", ".", "\") called\\n\"", ")", ";", "}", "if", "(", "$", "name", "==", "\"dataset\"", ")", "{", "if", "(", "$", "this", "->", "currBuilder", "!==", "null", ")", "{", "$", "this", "->", "sqlWriter", "->", "write", "(", "$", "this", "->", "currBuilder", "->", "getTableEndSql", "(", ")", ")", ";", "}", "$", "this", "->", "sqlWriter", "->", "write", "(", "call_user_func", "(", "array", "(", "$", "this", "->", "builderClazz", ",", "'getDatabaseEndSql'", ")", ")", ")", ";", "}", "}" ]
Handles closing elements of the xml file. @param $name The local name (without prefix), or the empty string if Namespace processing is not being performed.
[ "Handles", "closing", "elements", "of", "the", "xml", "file", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/util/XmlToDataSQL.php#L200-L211
propelorm/Propel
generator/lib/model/diff/PropelTableDiff.php
PropelTableDiff.addModifiedIndex
public function addModifiedIndex($indexName, Index $fromIndex, Index $toIndex) { $this->modifiedIndices[$indexName] = array($fromIndex, $toIndex); }
php
public function addModifiedIndex($indexName, Index $fromIndex, Index $toIndex) { $this->modifiedIndices[$indexName] = array($fromIndex, $toIndex); }
[ "public", "function", "addModifiedIndex", "(", "$", "indexName", ",", "Index", "$", "fromIndex", ",", "Index", "$", "toIndex", ")", "{", "$", "this", "->", "modifiedIndices", "[", "$", "indexName", "]", "=", "array", "(", "$", "fromIndex", ",", "$", "toIndex", ")", ";", "}" ]
Add a modified Index @param string $indexName @param Index $fromIndex @param Index $toIndex
[ "Add", "a", "modified", "Index" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelTableDiff.php#L453-L456
propelorm/Propel
generator/lib/model/diff/PropelTableDiff.php
PropelTableDiff.getReverseDiff
public function getReverseDiff() { $diff = new self(); // tables $diff->setFromTable($this->getToTable()); $diff->setToTable($this->getFromTable()); // columns $diff->setAddedColumns($this->getRemovedColumns()); $diff->setRemovedColumns($this->getAddedColumns()); $renamedColumns = array(); foreach ($this->getRenamedColumns() as $columnRenaming) { $renamedColumns[] = array_reverse($columnRenaming); } $diff->setRenamedColumns($renamedColumns); $columnDiffs = array(); foreach ($this->getModifiedColumns() as $name => $columnDiff) { $columnDiffs[$name] = $columnDiff->getReverseDiff(); } $diff->setModifiedColumns($columnDiffs); // pks $diff->setAddedPkColumns($this->getRemovedPkColumns()); $diff->setRemovedPkColumns($this->getAddedPkColumns()); $renamedPkColumns = array(); foreach ($this->getRenamedPkColumns() as $columnRenaming) { $renamedPkColumns[] = array_reverse($columnRenaming); } $diff->setRenamedPkColumns($renamedPkColumns); // indices $diff->setAddedIndices($this->getRemovedIndices()); $diff->setRemovedIndices($this->getAddedIndices()); $indexDiffs = array(); foreach ($this->getModifiedIndices() as $name => $indexDiff) { $indexDiffs[$name] = array_reverse($indexDiff); } $diff->setModifiedIndices($indexDiffs); // fks $diff->setAddedFks($this->getRemovedFks()); $diff->setRemovedFks($this->getAddedFks()); $fkDiffs = array(); foreach ($this->getModifiedFks() as $name => $fkDiff) { $fkDiffs[$name] = array_reverse($fkDiff); } $diff->setModifiedFks($fkDiffs); return $diff; }
php
public function getReverseDiff() { $diff = new self(); // tables $diff->setFromTable($this->getToTable()); $diff->setToTable($this->getFromTable()); // columns $diff->setAddedColumns($this->getRemovedColumns()); $diff->setRemovedColumns($this->getAddedColumns()); $renamedColumns = array(); foreach ($this->getRenamedColumns() as $columnRenaming) { $renamedColumns[] = array_reverse($columnRenaming); } $diff->setRenamedColumns($renamedColumns); $columnDiffs = array(); foreach ($this->getModifiedColumns() as $name => $columnDiff) { $columnDiffs[$name] = $columnDiff->getReverseDiff(); } $diff->setModifiedColumns($columnDiffs); // pks $diff->setAddedPkColumns($this->getRemovedPkColumns()); $diff->setRemovedPkColumns($this->getAddedPkColumns()); $renamedPkColumns = array(); foreach ($this->getRenamedPkColumns() as $columnRenaming) { $renamedPkColumns[] = array_reverse($columnRenaming); } $diff->setRenamedPkColumns($renamedPkColumns); // indices $diff->setAddedIndices($this->getRemovedIndices()); $diff->setRemovedIndices($this->getAddedIndices()); $indexDiffs = array(); foreach ($this->getModifiedIndices() as $name => $indexDiff) { $indexDiffs[$name] = array_reverse($indexDiff); } $diff->setModifiedIndices($indexDiffs); // fks $diff->setAddedFks($this->getRemovedFks()); $diff->setRemovedFks($this->getAddedFks()); $fkDiffs = array(); foreach ($this->getModifiedFks() as $name => $fkDiff) { $fkDiffs[$name] = array_reverse($fkDiff); } $diff->setModifiedFks($fkDiffs); return $diff; }
[ "public", "function", "getReverseDiff", "(", ")", "{", "$", "diff", "=", "new", "self", "(", ")", ";", "// tables", "$", "diff", "->", "setFromTable", "(", "$", "this", "->", "getToTable", "(", ")", ")", ";", "$", "diff", "->", "setToTable", "(", "$", "this", "->", "getFromTable", "(", ")", ")", ";", "// columns", "$", "diff", "->", "setAddedColumns", "(", "$", "this", "->", "getRemovedColumns", "(", ")", ")", ";", "$", "diff", "->", "setRemovedColumns", "(", "$", "this", "->", "getAddedColumns", "(", ")", ")", ";", "$", "renamedColumns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRenamedColumns", "(", ")", "as", "$", "columnRenaming", ")", "{", "$", "renamedColumns", "[", "]", "=", "array_reverse", "(", "$", "columnRenaming", ")", ";", "}", "$", "diff", "->", "setRenamedColumns", "(", "$", "renamedColumns", ")", ";", "$", "columnDiffs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getModifiedColumns", "(", ")", "as", "$", "name", "=>", "$", "columnDiff", ")", "{", "$", "columnDiffs", "[", "$", "name", "]", "=", "$", "columnDiff", "->", "getReverseDiff", "(", ")", ";", "}", "$", "diff", "->", "setModifiedColumns", "(", "$", "columnDiffs", ")", ";", "// pks", "$", "diff", "->", "setAddedPkColumns", "(", "$", "this", "->", "getRemovedPkColumns", "(", ")", ")", ";", "$", "diff", "->", "setRemovedPkColumns", "(", "$", "this", "->", "getAddedPkColumns", "(", ")", ")", ";", "$", "renamedPkColumns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRenamedPkColumns", "(", ")", "as", "$", "columnRenaming", ")", "{", "$", "renamedPkColumns", "[", "]", "=", "array_reverse", "(", "$", "columnRenaming", ")", ";", "}", "$", "diff", "->", "setRenamedPkColumns", "(", "$", "renamedPkColumns", ")", ";", "// indices", "$", "diff", "->", "setAddedIndices", "(", "$", "this", "->", "getRemovedIndices", "(", ")", ")", ";", "$", "diff", "->", "setRemovedIndices", "(", "$", "this", "->", "getAddedIndices", "(", ")", ")", ";", "$", "indexDiffs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getModifiedIndices", "(", ")", "as", "$", "name", "=>", "$", "indexDiff", ")", "{", "$", "indexDiffs", "[", "$", "name", "]", "=", "array_reverse", "(", "$", "indexDiff", ")", ";", "}", "$", "diff", "->", "setModifiedIndices", "(", "$", "indexDiffs", ")", ";", "// fks", "$", "diff", "->", "setAddedFks", "(", "$", "this", "->", "getRemovedFks", "(", ")", ")", ";", "$", "diff", "->", "setRemovedFks", "(", "$", "this", "->", "getAddedFks", "(", ")", ")", ";", "$", "fkDiffs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getModifiedFks", "(", ")", "as", "$", "name", "=>", "$", "fkDiff", ")", "{", "$", "fkDiffs", "[", "$", "name", "]", "=", "array_reverse", "(", "$", "fkDiff", ")", ";", "}", "$", "diff", "->", "setModifiedFks", "(", "$", "fkDiffs", ")", ";", "return", "$", "diff", ";", "}" ]
Get the reverse diff for this diff @return PropelTableDiff
[ "Get", "the", "reverse", "diff", "for", "this", "diff" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/diff/PropelTableDiff.php#L587-L637
propelorm/Propel
runtime/lib/util/PropelAutoloader.php
PropelAutoloader.register
public static function register() { ini_set('unserialize_callback_func', 'spl_autoload_call'); if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); } }
php
public static function register() { ini_set('unserialize_callback_func', 'spl_autoload_call'); if (false === spl_autoload_register(array(self::getInstance(), 'autoload'))) { throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); } }
[ "public", "static", "function", "register", "(", ")", "{", "ini_set", "(", "'unserialize_callback_func'", ",", "'spl_autoload_call'", ")", ";", "if", "(", "false", "===", "spl_autoload_register", "(", "array", "(", "self", "::", "getInstance", "(", ")", ",", "'autoload'", ")", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Unable to register %s::autoload as an autoloading method.'", ",", "get_class", "(", "self", "::", "getInstance", "(", ")", ")", ")", ")", ";", "}", "}" ]
Register PropelAutoloader in spl autoloader. @return void @throws Exception
[ "Register", "PropelAutoloader", "in", "spl", "autoloader", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelAutoloader.php#L48-L55
propelorm/Propel
runtime/lib/util/PropelAutoloader.php
PropelAutoloader.autoload
public function autoload($class) { if (isset($this->classes[$class])) { require $this->classes[$class]; return true; } // fallback for classes defined with leading backslash if (strpos($class, '\\') === 0) { $class = substr($class, 1); return $this->autoload($class); } return false; }
php
public function autoload($class) { if (isset($this->classes[$class])) { require $this->classes[$class]; return true; } // fallback for classes defined with leading backslash if (strpos($class, '\\') === 0) { $class = substr($class, 1); return $this->autoload($class); } return false; }
[ "public", "function", "autoload", "(", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "classes", "[", "$", "class", "]", ")", ")", "{", "require", "$", "this", "->", "classes", "[", "$", "class", "]", ";", "return", "true", ";", "}", "// fallback for classes defined with leading backslash", "if", "(", "strpos", "(", "$", "class", ",", "'\\\\'", ")", "===", "0", ")", "{", "$", "class", "=", "substr", "(", "$", "class", ",", "1", ")", ";", "return", "$", "this", "->", "autoload", "(", "$", "class", ")", ";", "}", "return", "false", ";", "}" ]
Handles autoloading of classes that have been registered in this instance @param string $class A class name. @return boolean Returns true if the class has been loaded
[ "Handles", "autoloading", "of", "classes", "that", "have", "been", "registered", "in", "this", "instance" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/util/PropelAutoloader.php#L107-L122
propelorm/Propel
generator/lib/model/ScopedElement.php
ScopedElement.setupObject
protected function setupObject() { $this->setPackage($this->getAttribute("package", $this->pkg)); $this->setSchema($this->getAttribute("schema", $this->schema)); $this->setNamespace($this->getAttribute("namespace", $this->namespace)); }
php
protected function setupObject() { $this->setPackage($this->getAttribute("package", $this->pkg)); $this->setSchema($this->getAttribute("schema", $this->schema)); $this->setNamespace($this->getAttribute("namespace", $this->namespace)); }
[ "protected", "function", "setupObject", "(", ")", "{", "$", "this", "->", "setPackage", "(", "$", "this", "->", "getAttribute", "(", "\"package\"", ",", "$", "this", "->", "pkg", ")", ")", ";", "$", "this", "->", "setSchema", "(", "$", "this", "->", "getAttribute", "(", "\"schema\"", ",", "$", "this", "->", "schema", ")", ")", ";", "$", "this", "->", "setNamespace", "(", "$", "this", "->", "getAttribute", "(", "\"namespace\"", ",", "$", "this", "->", "namespace", ")", ")", ";", "}" ]
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/ScopedElement.php#L61-L66
propelorm/Propel
generator/lib/model/ScopedElement.php
ScopedElement.setNamespace
public function setNamespace($v) { if ($v == $this->namespace) { return; } $this->namespace = $v; if ($v && (!$this->pkg || $this->pkgOverridden) && $this->getBuildProperty('namespaceAutoPackage')) { $this->pkg = str_replace('\\', '.', $v); $this->pkgOverridden = true; } }
php
public function setNamespace($v) { if ($v == $this->namespace) { return; } $this->namespace = $v; if ($v && (!$this->pkg || $this->pkgOverridden) && $this->getBuildProperty('namespaceAutoPackage')) { $this->pkg = str_replace('\\', '.', $v); $this->pkgOverridden = true; } }
[ "public", "function", "setNamespace", "(", "$", "v", ")", "{", "if", "(", "$", "v", "==", "$", "this", "->", "namespace", ")", "{", "return", ";", "}", "$", "this", "->", "namespace", "=", "$", "v", ";", "if", "(", "$", "v", "&&", "(", "!", "$", "this", "->", "pkg", "||", "$", "this", "->", "pkgOverridden", ")", "&&", "$", "this", "->", "getBuildProperty", "(", "'namespaceAutoPackage'", ")", ")", "{", "$", "this", "->", "pkg", "=", "str_replace", "(", "'\\\\'", ",", "'.'", ",", "$", "v", ")", ";", "$", "this", "->", "pkgOverridden", "=", "true", ";", "}", "}" ]
Set the value of the namespace. @param $v Value to assign to namespace.
[ "Set", "the", "value", "of", "the", "namespace", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ScopedElement.php#L83-L93
propelorm/Propel
generator/lib/model/ScopedElement.php
ScopedElement.setPackage
public function setPackage($v) { if ($v == $this->pkg) { return; } $this->pkg = $v; $this->pkgOverridden = false; }
php
public function setPackage($v) { if ($v == $this->pkg) { return; } $this->pkg = $v; $this->pkgOverridden = false; }
[ "public", "function", "setPackage", "(", "$", "v", ")", "{", "if", "(", "$", "v", "==", "$", "this", "->", "pkg", ")", "{", "return", ";", "}", "$", "this", "->", "pkg", "=", "$", "v", ";", "$", "this", "->", "pkgOverridden", "=", "false", ";", "}" ]
Set the value of package. @param $v Value to assign to package.
[ "Set", "the", "value", "of", "package", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ScopedElement.php#L110-L117
propelorm/Propel
generator/lib/model/ScopedElement.php
ScopedElement.setSchema
public function setSchema($v) { if ($v == $this->schema) { return; } $this->schema = $v; if ($v && !$this->pkg && $this->getBuildProperty('schemaAutoPackage')) { $this->pkg = $v; $this->pkgOverridden = true; } if ($v && !$this->namespace && $this->getBuildProperty('schemaAutoNamespace')) { $this->namespace = $v; } }
php
public function setSchema($v) { if ($v == $this->schema) { return; } $this->schema = $v; if ($v && !$this->pkg && $this->getBuildProperty('schemaAutoPackage')) { $this->pkg = $v; $this->pkgOverridden = true; } if ($v && !$this->namespace && $this->getBuildProperty('schemaAutoNamespace')) { $this->namespace = $v; } }
[ "public", "function", "setSchema", "(", "$", "v", ")", "{", "if", "(", "$", "v", "==", "$", "this", "->", "schema", ")", "{", "return", ";", "}", "$", "this", "->", "schema", "=", "$", "v", ";", "if", "(", "$", "v", "&&", "!", "$", "this", "->", "pkg", "&&", "$", "this", "->", "getBuildProperty", "(", "'schemaAutoPackage'", ")", ")", "{", "$", "this", "->", "pkg", "=", "$", "v", ";", "$", "this", "->", "pkgOverridden", "=", "true", ";", "}", "if", "(", "$", "v", "&&", "!", "$", "this", "->", "namespace", "&&", "$", "this", "->", "getBuildProperty", "(", "'schemaAutoNamespace'", ")", ")", "{", "$", "this", "->", "namespace", "=", "$", "v", ";", "}", "}" ]
Set the value of schema. @param $v Value to assign to schema.
[ "Set", "the", "value", "of", "schema", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/ScopedElement.php#L134-L147
propelorm/Propel
generator/lib/util/PropelDotGenerator.php
PropelDotGenerator.create
public static function create(Database $database) { $dotSyntax = ''; // table nodes foreach ($database->getTables() as $table) { $columnsSyntax = ''; foreach ($table->getColumns() as $column) { $attributes = ''; if (count($column->getForeignKeys()) > 0) { $attributes .= ' [FK]'; } if ($column->isPrimaryKey()) { $attributes .= ' [PK]'; } $columnsSyntax .= sprintf('%s (%s)%s\l', $column->getName(), $column->getType(), $attributes); } $nodeSyntax = sprintf('"%s" [label="{<table>%s|<cols>%s}", shape=record];', $table->getName(), $table->getName(), $columnsSyntax); $dotSyntax .= "$nodeSyntax\n"; } // relation nodes foreach ($database->getTables() as $table) { foreach ($table->getColumns() as $column) { foreach ($column->getForeignKeys() as $fk) { $relationSyntax = sprintf('"%s":cols -> "%s":table [label="%s=%s"];', $table->getName(), $fk->getForeignTableName(), $column->getName(), implode(',', $fk->getForeignColumns())); $dotSyntax .= "$relationSyntax\n"; } } } return sprintf("digraph G {\n%s}\n", $dotSyntax); }
php
public static function create(Database $database) { $dotSyntax = ''; // table nodes foreach ($database->getTables() as $table) { $columnsSyntax = ''; foreach ($table->getColumns() as $column) { $attributes = ''; if (count($column->getForeignKeys()) > 0) { $attributes .= ' [FK]'; } if ($column->isPrimaryKey()) { $attributes .= ' [PK]'; } $columnsSyntax .= sprintf('%s (%s)%s\l', $column->getName(), $column->getType(), $attributes); } $nodeSyntax = sprintf('"%s" [label="{<table>%s|<cols>%s}", shape=record];', $table->getName(), $table->getName(), $columnsSyntax); $dotSyntax .= "$nodeSyntax\n"; } // relation nodes foreach ($database->getTables() as $table) { foreach ($table->getColumns() as $column) { foreach ($column->getForeignKeys() as $fk) { $relationSyntax = sprintf('"%s":cols -> "%s":table [label="%s=%s"];', $table->getName(), $fk->getForeignTableName(), $column->getName(), implode(',', $fk->getForeignColumns())); $dotSyntax .= "$relationSyntax\n"; } } } return sprintf("digraph G {\n%s}\n", $dotSyntax); }
[ "public", "static", "function", "create", "(", "Database", "$", "database", ")", "{", "$", "dotSyntax", "=", "''", ";", "// table nodes", "foreach", "(", "$", "database", "->", "getTables", "(", ")", "as", "$", "table", ")", "{", "$", "columnsSyntax", "=", "''", ";", "foreach", "(", "$", "table", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "$", "attributes", "=", "''", ";", "if", "(", "count", "(", "$", "column", "->", "getForeignKeys", "(", ")", ")", ">", "0", ")", "{", "$", "attributes", ".=", "' [FK]'", ";", "}", "if", "(", "$", "column", "->", "isPrimaryKey", "(", ")", ")", "{", "$", "attributes", ".=", "' [PK]'", ";", "}", "$", "columnsSyntax", ".=", "sprintf", "(", "'%s (%s)%s\\l'", ",", "$", "column", "->", "getName", "(", ")", ",", "$", "column", "->", "getType", "(", ")", ",", "$", "attributes", ")", ";", "}", "$", "nodeSyntax", "=", "sprintf", "(", "'\"%s\" [label=\"{<table>%s|<cols>%s}\", shape=record];'", ",", "$", "table", "->", "getName", "(", ")", ",", "$", "table", "->", "getName", "(", ")", ",", "$", "columnsSyntax", ")", ";", "$", "dotSyntax", ".=", "\"$nodeSyntax\\n\"", ";", "}", "// relation nodes", "foreach", "(", "$", "database", "->", "getTables", "(", ")", "as", "$", "table", ")", "{", "foreach", "(", "$", "table", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "foreach", "(", "$", "column", "->", "getForeignKeys", "(", ")", "as", "$", "fk", ")", "{", "$", "relationSyntax", "=", "sprintf", "(", "'\"%s\":cols -> \"%s\":table [label=\"%s=%s\"];'", ",", "$", "table", "->", "getName", "(", ")", ",", "$", "fk", "->", "getForeignTableName", "(", ")", ",", "$", "column", "->", "getName", "(", ")", ",", "implode", "(", "','", ",", "$", "fk", "->", "getForeignColumns", "(", ")", ")", ")", ";", "$", "dotSyntax", ".=", "\"$relationSyntax\\n\"", ";", "}", "}", "}", "return", "sprintf", "(", "\"digraph G {\\n%s}\\n\"", ",", "$", "dotSyntax", ")", ";", "}" ]
Create the DOT syntax for a given databases. @param $database Database @return string The DOT syntax created.
[ "Create", "the", "DOT", "syntax", "for", "a", "given", "databases", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/util/PropelDotGenerator.php#L28-L64
propelorm/Propel
runtime/lib/validator/TypeValidator.php
TypeValidator.isValid
public function isValid(ValidatorMap $map, $value) { switch ($map->getValue()) { case 'array': return is_array($value); break; case 'bool': case 'boolean': return is_bool($value); break; case 'float': return is_float($value); break; case 'int': case 'integer': return is_int($value); break; case 'numeric': return is_numeric($value); break; case 'object': return is_object($value); break; case 'resource': return is_resource($value); break; case 'scalar': return is_scalar($value); break; case 'string': return is_string($value); break; case 'function': return function_exists($value); break; default: throw new PropelException('Unknown type ' . $map->getValue()); break; } }
php
public function isValid(ValidatorMap $map, $value) { switch ($map->getValue()) { case 'array': return is_array($value); break; case 'bool': case 'boolean': return is_bool($value); break; case 'float': return is_float($value); break; case 'int': case 'integer': return is_int($value); break; case 'numeric': return is_numeric($value); break; case 'object': return is_object($value); break; case 'resource': return is_resource($value); break; case 'scalar': return is_scalar($value); break; case 'string': return is_string($value); break; case 'function': return function_exists($value); break; default: throw new PropelException('Unknown type ' . $map->getValue()); break; } }
[ "public", "function", "isValid", "(", "ValidatorMap", "$", "map", ",", "$", "value", ")", "{", "switch", "(", "$", "map", "->", "getValue", "(", ")", ")", "{", "case", "'array'", ":", "return", "is_array", "(", "$", "value", ")", ";", "break", ";", "case", "'bool'", ":", "case", "'boolean'", ":", "return", "is_bool", "(", "$", "value", ")", ";", "break", ";", "case", "'float'", ":", "return", "is_float", "(", "$", "value", ")", ";", "break", ";", "case", "'int'", ":", "case", "'integer'", ":", "return", "is_int", "(", "$", "value", ")", ";", "break", ";", "case", "'numeric'", ":", "return", "is_numeric", "(", "$", "value", ")", ";", "break", ";", "case", "'object'", ":", "return", "is_object", "(", "$", "value", ")", ";", "break", ";", "case", "'resource'", ":", "return", "is_resource", "(", "$", "value", ")", ";", "break", ";", "case", "'scalar'", ":", "return", "is_scalar", "(", "$", "value", ")", ";", "break", ";", "case", "'string'", ":", "return", "is_string", "(", "$", "value", ")", ";", "break", ";", "case", "'function'", ":", "return", "function_exists", "(", "$", "value", ")", ";", "break", ";", "default", ":", "throw", "new", "PropelException", "(", "'Unknown type '", ".", "$", "map", "->", "getValue", "(", ")", ")", ";", "break", ";", "}", "}" ]
@see BasicValidator::isValid() @param ValidatorMap $map @param mixed $value @return boolean @throws PropelException
[ "@see", "BasicValidator", "::", "isValid", "()" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/validator/TypeValidator.php#L38-L77
propelorm/Propel
runtime/lib/Propel.php
Propel.initialize
public static function initialize() { if (self::$configuration === null) { throw new PropelException("Propel cannot be initialized without a valid configuration. Please check the log files for further details."); } self::configureLogging(); // check whether the generated model has the same version as the runtime, see gh-#577 // we need to check for existance first, because tasks which rely on the runtime.xml conf will not provide a generator_version if (isset(self::$configuration['generator_version']) && self::$configuration['generator_version'] != self::VERSION) { $warning = "Version mismatch: The generated model was build using propel '" . self::$configuration['generator_version'] . "' while the current runtime is at version '" . self::VERSION . "'"; if (self::$logger) { self::$logger->warning($warning); } else { trigger_error($warning, E_USER_WARNING); } } // reset the connection map (this should enable runtime changes of connection params) self::$connectionMap = array(); if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) { PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']); PropelAutoloader::getInstance()->register(); } self::$isInit = true; }
php
public static function initialize() { if (self::$configuration === null) { throw new PropelException("Propel cannot be initialized without a valid configuration. Please check the log files for further details."); } self::configureLogging(); // check whether the generated model has the same version as the runtime, see gh-#577 // we need to check for existance first, because tasks which rely on the runtime.xml conf will not provide a generator_version if (isset(self::$configuration['generator_version']) && self::$configuration['generator_version'] != self::VERSION) { $warning = "Version mismatch: The generated model was build using propel '" . self::$configuration['generator_version'] . "' while the current runtime is at version '" . self::VERSION . "'"; if (self::$logger) { self::$logger->warning($warning); } else { trigger_error($warning, E_USER_WARNING); } } // reset the connection map (this should enable runtime changes of connection params) self::$connectionMap = array(); if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) { PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']); PropelAutoloader::getInstance()->register(); } self::$isInit = true; }
[ "public", "static", "function", "initialize", "(", ")", "{", "if", "(", "self", "::", "$", "configuration", "===", "null", ")", "{", "throw", "new", "PropelException", "(", "\"Propel cannot be initialized without a valid configuration. Please check the log files for further details.\"", ")", ";", "}", "self", "::", "configureLogging", "(", ")", ";", "// check whether the generated model has the same version as the runtime, see gh-#577", "// we need to check for existance first, because tasks which rely on the runtime.xml conf will not provide a generator_version", "if", "(", "isset", "(", "self", "::", "$", "configuration", "[", "'generator_version'", "]", ")", "&&", "self", "::", "$", "configuration", "[", "'generator_version'", "]", "!=", "self", "::", "VERSION", ")", "{", "$", "warning", "=", "\"Version mismatch: The generated model was build using propel '\"", ".", "self", "::", "$", "configuration", "[", "'generator_version'", "]", ".", "\"' while the current runtime is at version '\"", ".", "self", "::", "VERSION", ".", "\"'\"", ";", "if", "(", "self", "::", "$", "logger", ")", "{", "self", "::", "$", "logger", "->", "warning", "(", "$", "warning", ")", ";", "}", "else", "{", "trigger_error", "(", "$", "warning", ",", "E_USER_WARNING", ")", ";", "}", "}", "// reset the connection map (this should enable runtime changes of connection params)", "self", "::", "$", "connectionMap", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "configuration", "[", "'classmap'", "]", ")", "&&", "is_array", "(", "self", "::", "$", "configuration", "[", "'classmap'", "]", ")", ")", "{", "PropelAutoloader", "::", "getInstance", "(", ")", "->", "addClassPaths", "(", "self", "::", "$", "configuration", "[", "'classmap'", "]", ")", ";", "PropelAutoloader", "::", "getInstance", "(", ")", "->", "register", "(", ")", ";", "}", "self", "::", "$", "isInit", "=", "true", ";", "}" ]
Initializes Propel @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Initializes", "Propel" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L262-L290
propelorm/Propel
runtime/lib/Propel.php
Propel.configure
public static function configure($configFile) { $configuration = include($configFile); if ($configuration === false) { throw new PropelException("Unable to open configuration file: " . var_export($configFile, true)); } self::setConfiguration($configuration); }
php
public static function configure($configFile) { $configuration = include($configFile); if ($configuration === false) { throw new PropelException("Unable to open configuration file: " . var_export($configFile, true)); } self::setConfiguration($configuration); }
[ "public", "static", "function", "configure", "(", "$", "configFile", ")", "{", "$", "configuration", "=", "include", "(", "$", "configFile", ")", ";", "if", "(", "$", "configuration", "===", "false", ")", "{", "throw", "new", "PropelException", "(", "\"Unable to open configuration file: \"", ".", "var_export", "(", "$", "configFile", ",", "true", ")", ")", ";", "}", "self", "::", "setConfiguration", "(", "$", "configuration", ")", ";", "}" ]
Configure Propel a PHP (array) config file. @param string Path (absolute or relative to include_path) to config file. @throws PropelException If configuration file cannot be opened. (E_WARNING probably will also be raised by PHP)
[ "Configure", "Propel", "a", "PHP", "(", "array", ")", "config", "file", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L300-L307
propelorm/Propel
runtime/lib/Propel.php
Propel.configureLogging
protected static function configureLogging() { if (self::$logger === null) { if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) { include_once 'Log.php'; // PEAR Log class $c = self::$configuration['log']; $type = isset($c['type']) ? $c['type'] : 'file'; $name = isset($c['name']) ? $c['name'] : './propel.log'; $ident = isset($c['ident']) ? $c['ident'] : 'propel'; $conf = isset($c['conf']) ? $c['conf'] : array(); $level = isset($c['level']) ? $c['level'] : PEAR_LOG_DEBUG; self::$logger = Log::singleton($type, $name, $ident, $conf, $level); } // if isset() } }
php
protected static function configureLogging() { if (self::$logger === null) { if (isset(self::$configuration['log']) && is_array(self::$configuration['log']) && count(self::$configuration['log'])) { include_once 'Log.php'; // PEAR Log class $c = self::$configuration['log']; $type = isset($c['type']) ? $c['type'] : 'file'; $name = isset($c['name']) ? $c['name'] : './propel.log'; $ident = isset($c['ident']) ? $c['ident'] : 'propel'; $conf = isset($c['conf']) ? $c['conf'] : array(); $level = isset($c['level']) ? $c['level'] : PEAR_LOG_DEBUG; self::$logger = Log::singleton($type, $name, $ident, $conf, $level); } // if isset() } }
[ "protected", "static", "function", "configureLogging", "(", ")", "{", "if", "(", "self", "::", "$", "logger", "===", "null", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "configuration", "[", "'log'", "]", ")", "&&", "is_array", "(", "self", "::", "$", "configuration", "[", "'log'", "]", ")", "&&", "count", "(", "self", "::", "$", "configuration", "[", "'log'", "]", ")", ")", "{", "include_once", "'Log.php'", ";", "// PEAR Log class", "$", "c", "=", "self", "::", "$", "configuration", "[", "'log'", "]", ";", "$", "type", "=", "isset", "(", "$", "c", "[", "'type'", "]", ")", "?", "$", "c", "[", "'type'", "]", ":", "'file'", ";", "$", "name", "=", "isset", "(", "$", "c", "[", "'name'", "]", ")", "?", "$", "c", "[", "'name'", "]", ":", "'./propel.log'", ";", "$", "ident", "=", "isset", "(", "$", "c", "[", "'ident'", "]", ")", "?", "$", "c", "[", "'ident'", "]", ":", "'propel'", ";", "$", "conf", "=", "isset", "(", "$", "c", "[", "'conf'", "]", ")", "?", "$", "c", "[", "'conf'", "]", ":", "array", "(", ")", ";", "$", "level", "=", "isset", "(", "$", "c", "[", "'level'", "]", ")", "?", "$", "c", "[", "'level'", "]", ":", "PEAR_LOG_DEBUG", ";", "self", "::", "$", "logger", "=", "Log", "::", "singleton", "(", "$", "type", ",", "$", "name", ",", "$", "ident", ",", "$", "conf", ",", "$", "level", ")", ";", "}", "// if isset()", "}", "}" ]
Configure the logging system, if config is specified in the runtime configuration.
[ "Configure", "the", "logging", "system", "if", "config", "is", "specified", "in", "the", "runtime", "configuration", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L312-L326
propelorm/Propel
runtime/lib/Propel.php
Propel.setConfiguration
public static function setConfiguration($c) { if (is_array($c)) { if (isset($c['propel']) && is_array($c['propel'])) { $c = $c['propel']; } $c = new PropelConfiguration($c); } self::$configuration = $c; }
php
public static function setConfiguration($c) { if (is_array($c)) { if (isset($c['propel']) && is_array($c['propel'])) { $c = $c['propel']; } $c = new PropelConfiguration($c); } self::$configuration = $c; }
[ "public", "static", "function", "setConfiguration", "(", "$", "c", ")", "{", "if", "(", "is_array", "(", "$", "c", ")", ")", "{", "if", "(", "isset", "(", "$", "c", "[", "'propel'", "]", ")", "&&", "is_array", "(", "$", "c", "[", "'propel'", "]", ")", ")", "{", "$", "c", "=", "$", "c", "[", "'propel'", "]", ";", "}", "$", "c", "=", "new", "PropelConfiguration", "(", "$", "c", ")", ";", "}", "self", "::", "$", "configuration", "=", "$", "c", ";", "}" ]
Sets the configuration for Propel and all dependencies. @param mixed The Configuration (array or PropelConfiguration)
[ "Sets", "the", "configuration", "for", "Propel", "and", "all", "dependencies", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L357-L366
propelorm/Propel
runtime/lib/Propel.php
Propel.log
public static function log($message, $level = self::LOG_DEBUG) { if (self::hasLogger()) { $logger = self::logger(); switch ($level) { case self::LOG_EMERG: return $logger->log($message, $level); case self::LOG_ALERT: return $logger->alert($message); case self::LOG_CRIT: return $logger->crit($message); case self::LOG_ERR: return $logger->err($message); case self::LOG_WARNING: return $logger->warning($message); case self::LOG_NOTICE: return $logger->notice($message); case self::LOG_INFO: return $logger->info($message); default: return $logger->debug($message); } } return true; }
php
public static function log($message, $level = self::LOG_DEBUG) { if (self::hasLogger()) { $logger = self::logger(); switch ($level) { case self::LOG_EMERG: return $logger->log($message, $level); case self::LOG_ALERT: return $logger->alert($message); case self::LOG_CRIT: return $logger->crit($message); case self::LOG_ERR: return $logger->err($message); case self::LOG_WARNING: return $logger->warning($message); case self::LOG_NOTICE: return $logger->notice($message); case self::LOG_INFO: return $logger->info($message); default: return $logger->debug($message); } } return true; }
[ "public", "static", "function", "log", "(", "$", "message", ",", "$", "level", "=", "self", "::", "LOG_DEBUG", ")", "{", "if", "(", "self", "::", "hasLogger", "(", ")", ")", "{", "$", "logger", "=", "self", "::", "logger", "(", ")", ";", "switch", "(", "$", "level", ")", "{", "case", "self", "::", "LOG_EMERG", ":", "return", "$", "logger", "->", "log", "(", "$", "message", ",", "$", "level", ")", ";", "case", "self", "::", "LOG_ALERT", ":", "return", "$", "logger", "->", "alert", "(", "$", "message", ")", ";", "case", "self", "::", "LOG_CRIT", ":", "return", "$", "logger", "->", "crit", "(", "$", "message", ")", ";", "case", "self", "::", "LOG_ERR", ":", "return", "$", "logger", "->", "err", "(", "$", "message", ")", ";", "case", "self", "::", "LOG_WARNING", ":", "return", "$", "logger", "->", "warning", "(", "$", "message", ")", ";", "case", "self", "::", "LOG_NOTICE", ":", "return", "$", "logger", "->", "notice", "(", "$", "message", ")", ";", "case", "self", "::", "LOG_INFO", ":", "return", "$", "logger", "->", "info", "(", "$", "message", ")", ";", "default", ":", "return", "$", "logger", "->", "debug", "(", "$", "message", ")", ";", "}", "}", "return", "true", ";", "}" ]
Logs a message If a logger has been configured, the logger will be used, otherwrise the logging message will be discarded without any further action @param string The message that will be logged. @param string The logging level. @return bool True if the message was logged successfully or no logger was used.
[ "Logs", "a", "message", "If", "a", "logger", "has", "been", "configured", "the", "logger", "will", "be", "used", "otherwrise", "the", "logging", "message", "will", "be", "discarded", "without", "any", "further", "action" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L432-L457
propelorm/Propel
runtime/lib/Propel.php
Propel.getDatabaseMap
public static function getDatabaseMap($name = null) { if ($name === null) { $name = self::getDefaultDB(); if ($name === null) { throw new PropelException("DatabaseMap name is null!"); } } if (!isset(self::$dbMaps[$name])) { $clazz = self::$databaseMapClass; self::$dbMaps[$name] = new $clazz($name); } return self::$dbMaps[$name]; }
php
public static function getDatabaseMap($name = null) { if ($name === null) { $name = self::getDefaultDB(); if ($name === null) { throw new PropelException("DatabaseMap name is null!"); } } if (!isset(self::$dbMaps[$name])) { $clazz = self::$databaseMapClass; self::$dbMaps[$name] = new $clazz($name); } return self::$dbMaps[$name]; }
[ "public", "static", "function", "getDatabaseMap", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "self", "::", "getDefaultDB", "(", ")", ";", "if", "(", "$", "name", "===", "null", ")", "{", "throw", "new", "PropelException", "(", "\"DatabaseMap name is null!\"", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "dbMaps", "[", "$", "name", "]", ")", ")", "{", "$", "clazz", "=", "self", "::", "$", "databaseMapClass", ";", "self", "::", "$", "dbMaps", "[", "$", "name", "]", "=", "new", "$", "clazz", "(", "$", "name", ")", ";", "}", "return", "self", "::", "$", "dbMaps", "[", "$", "name", "]", ";", "}" ]
Returns the database map information. Name relates to the name of the connection pool to associate with the map. The database maps are "registered" by the generated map builder classes. @param string The name of the database corresponding to the DatabaseMap to retrieve. @return DatabaseMap The named <code>DatabaseMap</code>. @throws PropelException - if database map is null or propel was not initialized properly.
[ "Returns", "the", "database", "map", "information", ".", "Name", "relates", "to", "the", "name", "of", "the", "connection", "pool", "to", "associate", "with", "the", "map", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L471-L486
propelorm/Propel
runtime/lib/Propel.php
Propel.setDatabaseMap
public static function setDatabaseMap($name, DatabaseMap $map) { if ($name === null) { $name = self::getDefaultDB(); } self::$dbMaps[$name] = $map; }
php
public static function setDatabaseMap($name, DatabaseMap $map) { if ($name === null) { $name = self::getDefaultDB(); } self::$dbMaps[$name] = $map; }
[ "public", "static", "function", "setDatabaseMap", "(", "$", "name", ",", "DatabaseMap", "$", "map", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "self", "::", "getDefaultDB", "(", ")", ";", "}", "self", "::", "$", "dbMaps", "[", "$", "name", "]", "=", "$", "map", ";", "}" ]
Sets the database map object to use for specified datasource. @param string $name The datasource name. @param DatabaseMap $map The database map object to use for specified datasource.
[ "Sets", "the", "database", "map", "object", "to", "use", "for", "specified", "datasource", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L494-L500
propelorm/Propel
runtime/lib/Propel.php
Propel.setConnection
public static function setConnection($name, PropelPDO $con, $mode = Propel::CONNECTION_WRITE) { if ($name === null) { $name = self::getDefaultDB(); } if ($mode == Propel::CONNECTION_READ) { self::$connectionMap[$name]['slave'] = $con; } else { self::$connectionMap[$name]['master'] = $con; } }
php
public static function setConnection($name, PropelPDO $con, $mode = Propel::CONNECTION_WRITE) { if ($name === null) { $name = self::getDefaultDB(); } if ($mode == Propel::CONNECTION_READ) { self::$connectionMap[$name]['slave'] = $con; } else { self::$connectionMap[$name]['master'] = $con; } }
[ "public", "static", "function", "setConnection", "(", "$", "name", ",", "PropelPDO", "$", "con", ",", "$", "mode", "=", "Propel", "::", "CONNECTION_WRITE", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "self", "::", "getDefaultDB", "(", ")", ";", "}", "if", "(", "$", "mode", "==", "Propel", "::", "CONNECTION_READ", ")", "{", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'slave'", "]", "=", "$", "con", ";", "}", "else", "{", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'master'", "]", "=", "$", "con", ";", "}", "}" ]
Sets a Connection for specified datasource name. @param string $name The datasource name for the connection being set. @param PropelPDO $con The PDO connection. @param string $mode Whether this is a READ or WRITE connection (Propel::CONNECTION_READ, Propel::CONNECTION_WRITE)
[ "Sets", "a", "Connection", "for", "specified", "datasource", "name", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L529-L539
propelorm/Propel
runtime/lib/Propel.php
Propel.getConnection
public static function getConnection($name = null, $mode = Propel::CONNECTION_WRITE) { if ($name === null) { $name = self::getDefaultDB(); } // IF a WRITE-mode connection was requested // or Propel is configured to always use the master connection // THEN return the master connection. if ($mode != Propel::CONNECTION_READ || self::$forceMasterConnection) { return self::getMasterConnection($name); } else { return self::getSlaveConnection($name); } }
php
public static function getConnection($name = null, $mode = Propel::CONNECTION_WRITE) { if ($name === null) { $name = self::getDefaultDB(); } // IF a WRITE-mode connection was requested // or Propel is configured to always use the master connection // THEN return the master connection. if ($mode != Propel::CONNECTION_READ || self::$forceMasterConnection) { return self::getMasterConnection($name); } else { return self::getSlaveConnection($name); } }
[ "public", "static", "function", "getConnection", "(", "$", "name", "=", "null", ",", "$", "mode", "=", "Propel", "::", "CONNECTION_WRITE", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "self", "::", "getDefaultDB", "(", ")", ";", "}", "// IF a WRITE-mode connection was requested", "// or Propel is configured to always use the master connection", "// THEN return the master connection.", "if", "(", "$", "mode", "!=", "Propel", "::", "CONNECTION_READ", "||", "self", "::", "$", "forceMasterConnection", ")", "{", "return", "self", "::", "getMasterConnection", "(", "$", "name", ")", ";", "}", "else", "{", "return", "self", "::", "getSlaveConnection", "(", "$", "name", ")", ";", "}", "}" ]
Gets an already-opened PDO connection or opens a new one for passed-in db name. @param string $name The datasource name that is used to look up the DSN from the runtime configuration file. @param string $mode The connection mode (this applies to replication systems). @return PDO A database connection @throws PropelException - if connection cannot be configured or initialized.
[ "Gets", "an", "already", "-", "opened", "PDO", "connection", "or", "opens", "a", "new", "one", "for", "passed", "-", "in", "db", "name", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L551-L565
propelorm/Propel
runtime/lib/Propel.php
Propel.getMasterConnection
public static function getMasterConnection($name) { if (!isset(self::$connectionMap[$name]['master'])) { // load connection parameter for master connection $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null; if (empty($conparams)) { throw new PropelException('No connection information in your runtime configuration file for datasource [' . $name . ']'); } // initialize master connection $con = Propel::initConnection($conparams, $name); self::$connectionMap[$name]['master'] = $con; } return self::$connectionMap[$name]['master']; }
php
public static function getMasterConnection($name) { if (!isset(self::$connectionMap[$name]['master'])) { // load connection parameter for master connection $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null; if (empty($conparams)) { throw new PropelException('No connection information in your runtime configuration file for datasource [' . $name . ']'); } // initialize master connection $con = Propel::initConnection($conparams, $name); self::$connectionMap[$name]['master'] = $con; } return self::$connectionMap[$name]['master']; }
[ "public", "static", "function", "getMasterConnection", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'master'", "]", ")", ")", "{", "// load connection parameter for master connection", "$", "conparams", "=", "isset", "(", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "$", "name", "]", "[", "'connection'", "]", ")", "?", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "$", "name", "]", "[", "'connection'", "]", ":", "null", ";", "if", "(", "empty", "(", "$", "conparams", ")", ")", "{", "throw", "new", "PropelException", "(", "'No connection information in your runtime configuration file for datasource ['", ".", "$", "name", ".", "']'", ")", ";", "}", "// initialize master connection", "$", "con", "=", "Propel", "::", "initConnection", "(", "$", "conparams", ",", "$", "name", ")", ";", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'master'", "]", "=", "$", "con", ";", "}", "return", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'master'", "]", ";", "}" ]
Gets an already-opened write PDO connection or opens a new one for passed-in db name. @param string $name The datasource name that is used to look up the DSN from the runtime configuation file. Empty name not allowed. @return PDO A database connection @throws PropelException - if connection cannot be configured or initialized.
[ "Gets", "an", "already", "-", "opened", "write", "PDO", "connection", "or", "opens", "a", "new", "one", "for", "passed", "-", "in", "db", "name", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L577-L591
propelorm/Propel
runtime/lib/Propel.php
Propel.getSlaveConnection
public static function getSlaveConnection($name) { if (!isset(self::$connectionMap[$name]['slave'])) { $slaveconfigs = isset(self::$configuration['datasources'][$name]['slaves']) ? self::$configuration['datasources'][$name]['slaves'] : null; if (empty($slaveconfigs)) { // no slaves configured for this datasource // fallback to the master connection self::$connectionMap[$name]['slave'] = self::getMasterConnection($name); } else { // Initialize a new slave if (isset($slaveconfigs['connection']['dsn'])) { // only one slave connection configured $conparams = $slaveconfigs['connection']; } else { // more than one sleve connection configured // pickup a random one $randkey = array_rand($slaveconfigs['connection']); $conparams = $slaveconfigs['connection'][$randkey]; if (empty($conparams)) { throw new PropelException('No connection information in your runtime configuration file for SLAVE [' . $randkey . '] to datasource [' . $name . ']'); } } // initialize slave connection $con = Propel::initConnection($conparams, $name); self::$connectionMap[$name]['slave'] = $con; } } // if datasource slave not set return self::$connectionMap[$name]['slave']; }
php
public static function getSlaveConnection($name) { if (!isset(self::$connectionMap[$name]['slave'])) { $slaveconfigs = isset(self::$configuration['datasources'][$name]['slaves']) ? self::$configuration['datasources'][$name]['slaves'] : null; if (empty($slaveconfigs)) { // no slaves configured for this datasource // fallback to the master connection self::$connectionMap[$name]['slave'] = self::getMasterConnection($name); } else { // Initialize a new slave if (isset($slaveconfigs['connection']['dsn'])) { // only one slave connection configured $conparams = $slaveconfigs['connection']; } else { // more than one sleve connection configured // pickup a random one $randkey = array_rand($slaveconfigs['connection']); $conparams = $slaveconfigs['connection'][$randkey]; if (empty($conparams)) { throw new PropelException('No connection information in your runtime configuration file for SLAVE [' . $randkey . '] to datasource [' . $name . ']'); } } // initialize slave connection $con = Propel::initConnection($conparams, $name); self::$connectionMap[$name]['slave'] = $con; } } // if datasource slave not set return self::$connectionMap[$name]['slave']; }
[ "public", "static", "function", "getSlaveConnection", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'slave'", "]", ")", ")", "{", "$", "slaveconfigs", "=", "isset", "(", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "$", "name", "]", "[", "'slaves'", "]", ")", "?", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "$", "name", "]", "[", "'slaves'", "]", ":", "null", ";", "if", "(", "empty", "(", "$", "slaveconfigs", ")", ")", "{", "// no slaves configured for this datasource", "// fallback to the master connection", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'slave'", "]", "=", "self", "::", "getMasterConnection", "(", "$", "name", ")", ";", "}", "else", "{", "// Initialize a new slave", "if", "(", "isset", "(", "$", "slaveconfigs", "[", "'connection'", "]", "[", "'dsn'", "]", ")", ")", "{", "// only one slave connection configured", "$", "conparams", "=", "$", "slaveconfigs", "[", "'connection'", "]", ";", "}", "else", "{", "// more than one sleve connection configured", "// pickup a random one", "$", "randkey", "=", "array_rand", "(", "$", "slaveconfigs", "[", "'connection'", "]", ")", ";", "$", "conparams", "=", "$", "slaveconfigs", "[", "'connection'", "]", "[", "$", "randkey", "]", ";", "if", "(", "empty", "(", "$", "conparams", ")", ")", "{", "throw", "new", "PropelException", "(", "'No connection information in your runtime configuration file for SLAVE ['", ".", "$", "randkey", ".", "'] to datasource ['", ".", "$", "name", ".", "']'", ")", ";", "}", "}", "// initialize slave connection", "$", "con", "=", "Propel", "::", "initConnection", "(", "$", "conparams", ",", "$", "name", ")", ";", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'slave'", "]", "=", "$", "con", ";", "}", "}", "// if datasource slave not set", "return", "self", "::", "$", "connectionMap", "[", "$", "name", "]", "[", "'slave'", "]", ";", "}" ]
Gets an already-opened read PDO connection or opens a new one for passed-in db name. @param string $name The datasource name that is used to look up the DSN from the runtime configuation file. Empty name not allowed. @return PDO A database connection @throws PropelException - if connection cannot be configured or initialized.
[ "Gets", "an", "already", "-", "opened", "read", "PDO", "connection", "or", "opens", "a", "new", "one", "for", "passed", "-", "in", "db", "name", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L603-L635
propelorm/Propel
runtime/lib/Propel.php
Propel.initConnection
public static function initConnection($conparams, $name, $defaultClass = Propel::CLASS_PROPEL_PDO) { $adapter = isset($conparams['adapter']) ? DBAdapter::factory($conparams['adapter']) : self::getDB($name); if (null === $conparams['dsn']) { throw new PropelException('No dsn specified in your connection parameters for datasource [' . $name . ']'); } $conparams = $adapter->prepareParams($conparams); if (isset($conparams['classname']) && !empty($conparams['classname'])) { $classname = $conparams['classname']; if (!class_exists($classname)) { throw new PropelException('Unable to load specified PDO subclass: ' . $classname); } } else { $classname = $defaultClass; } $dsn = $conparams['dsn']; $user = isset($conparams['user']) ? $conparams['user'] : null; $password = isset($conparams['password']) ? $conparams['password'] : null; // load any driver options from the config file // driver options are those PDO settings that have to be passed during the connection construction $driver_options = array(); if (isset($conparams['options']) && is_array($conparams['options'])) { try { self::processDriverOptions($conparams['options'], $driver_options); } catch (PropelException $e) { throw new PropelException('Error processing driver options for datasource [' . $name . ']', $e); } } try { $con = new $classname($dsn, $user, $password, $driver_options); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $con->setAttribute(PropelPDO::PROPEL_ATTR_CONNECTION_NAME, $name); } catch (PDOException $e) { throw new PropelException("Unable to open PDO connection", $e); } // load any connection options from the config file // connection attributes are those PDO flags that have to be set on the initialized connection if (isset($conparams['attributes']) && is_array($conparams['attributes'])) { $attributes = array(); try { self::processDriverOptions($conparams['attributes'], $attributes); } catch (PropelException $e) { throw new PropelException('Error processing connection attributes for datasource [' . $name . ']', $e); } foreach ($attributes as $key => $value) { $con->setAttribute($key, $value); } } // initialize the connection using the settings provided in the config file. this could be a "SET NAMES <charset>" query for MySQL, for instance $adapter->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : array()); return $con; }
php
public static function initConnection($conparams, $name, $defaultClass = Propel::CLASS_PROPEL_PDO) { $adapter = isset($conparams['adapter']) ? DBAdapter::factory($conparams['adapter']) : self::getDB($name); if (null === $conparams['dsn']) { throw new PropelException('No dsn specified in your connection parameters for datasource [' . $name . ']'); } $conparams = $adapter->prepareParams($conparams); if (isset($conparams['classname']) && !empty($conparams['classname'])) { $classname = $conparams['classname']; if (!class_exists($classname)) { throw new PropelException('Unable to load specified PDO subclass: ' . $classname); } } else { $classname = $defaultClass; } $dsn = $conparams['dsn']; $user = isset($conparams['user']) ? $conparams['user'] : null; $password = isset($conparams['password']) ? $conparams['password'] : null; // load any driver options from the config file // driver options are those PDO settings that have to be passed during the connection construction $driver_options = array(); if (isset($conparams['options']) && is_array($conparams['options'])) { try { self::processDriverOptions($conparams['options'], $driver_options); } catch (PropelException $e) { throw new PropelException('Error processing driver options for datasource [' . $name . ']', $e); } } try { $con = new $classname($dsn, $user, $password, $driver_options); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $con->setAttribute(PropelPDO::PROPEL_ATTR_CONNECTION_NAME, $name); } catch (PDOException $e) { throw new PropelException("Unable to open PDO connection", $e); } // load any connection options from the config file // connection attributes are those PDO flags that have to be set on the initialized connection if (isset($conparams['attributes']) && is_array($conparams['attributes'])) { $attributes = array(); try { self::processDriverOptions($conparams['attributes'], $attributes); } catch (PropelException $e) { throw new PropelException('Error processing connection attributes for datasource [' . $name . ']', $e); } foreach ($attributes as $key => $value) { $con->setAttribute($key, $value); } } // initialize the connection using the settings provided in the config file. this could be a "SET NAMES <charset>" query for MySQL, for instance $adapter->initConnection($con, isset($conparams['settings']) && is_array($conparams['settings']) ? $conparams['settings'] : array()); return $con; }
[ "public", "static", "function", "initConnection", "(", "$", "conparams", ",", "$", "name", ",", "$", "defaultClass", "=", "Propel", "::", "CLASS_PROPEL_PDO", ")", "{", "$", "adapter", "=", "isset", "(", "$", "conparams", "[", "'adapter'", "]", ")", "?", "DBAdapter", "::", "factory", "(", "$", "conparams", "[", "'adapter'", "]", ")", ":", "self", "::", "getDB", "(", "$", "name", ")", ";", "if", "(", "null", "===", "$", "conparams", "[", "'dsn'", "]", ")", "{", "throw", "new", "PropelException", "(", "'No dsn specified in your connection parameters for datasource ['", ".", "$", "name", ".", "']'", ")", ";", "}", "$", "conparams", "=", "$", "adapter", "->", "prepareParams", "(", "$", "conparams", ")", ";", "if", "(", "isset", "(", "$", "conparams", "[", "'classname'", "]", ")", "&&", "!", "empty", "(", "$", "conparams", "[", "'classname'", "]", ")", ")", "{", "$", "classname", "=", "$", "conparams", "[", "'classname'", "]", ";", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "throw", "new", "PropelException", "(", "'Unable to load specified PDO subclass: '", ".", "$", "classname", ")", ";", "}", "}", "else", "{", "$", "classname", "=", "$", "defaultClass", ";", "}", "$", "dsn", "=", "$", "conparams", "[", "'dsn'", "]", ";", "$", "user", "=", "isset", "(", "$", "conparams", "[", "'user'", "]", ")", "?", "$", "conparams", "[", "'user'", "]", ":", "null", ";", "$", "password", "=", "isset", "(", "$", "conparams", "[", "'password'", "]", ")", "?", "$", "conparams", "[", "'password'", "]", ":", "null", ";", "// load any driver options from the config file", "// driver options are those PDO settings that have to be passed during the connection construction", "$", "driver_options", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "conparams", "[", "'options'", "]", ")", "&&", "is_array", "(", "$", "conparams", "[", "'options'", "]", ")", ")", "{", "try", "{", "self", "::", "processDriverOptions", "(", "$", "conparams", "[", "'options'", "]", ",", "$", "driver_options", ")", ";", "}", "catch", "(", "PropelException", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "'Error processing driver options for datasource ['", ".", "$", "name", ".", "']'", ",", "$", "e", ")", ";", "}", "}", "try", "{", "$", "con", "=", "new", "$", "classname", "(", "$", "dsn", ",", "$", "user", ",", "$", "password", ",", "$", "driver_options", ")", ";", "$", "con", "->", "setAttribute", "(", "PDO", "::", "ATTR_ERRMODE", ",", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "$", "con", "->", "setAttribute", "(", "PropelPDO", "::", "PROPEL_ATTR_CONNECTION_NAME", ",", "$", "name", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "\"Unable to open PDO connection\"", ",", "$", "e", ")", ";", "}", "// load any connection options from the config file", "// connection attributes are those PDO flags that have to be set on the initialized connection", "if", "(", "isset", "(", "$", "conparams", "[", "'attributes'", "]", ")", "&&", "is_array", "(", "$", "conparams", "[", "'attributes'", "]", ")", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "try", "{", "self", "::", "processDriverOptions", "(", "$", "conparams", "[", "'attributes'", "]", ",", "$", "attributes", ")", ";", "}", "catch", "(", "PropelException", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "'Error processing connection attributes for datasource ['", ".", "$", "name", ".", "']'", ",", "$", "e", ")", ";", "}", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "con", "->", "setAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "// initialize the connection using the settings provided in the config file. this could be a \"SET NAMES <charset>\" query for MySQL, for instance", "$", "adapter", "->", "initConnection", "(", "$", "con", ",", "isset", "(", "$", "conparams", "[", "'settings'", "]", ")", "&&", "is_array", "(", "$", "conparams", "[", "'settings'", "]", ")", "?", "$", "conparams", "[", "'settings'", "]", ":", "array", "(", ")", ")", ";", "return", "$", "con", ";", "}" ]
Opens a new PDO connection for passed-in db name. @param array $conparams Connection paramters. @param string $name Datasource name. @param string $defaultClass The PDO subclass to instantiate if there is no explicit classname specified in the connection params (default is Propel::CLASS_PROPEL_PDO) @return PDO A database connection of the given class (PDO, PropelPDO, SlavePDO or user-defined) @throws PropelException - if lower-level exception caught when trying to connect.
[ "Opens", "a", "new", "PDO", "connection", "for", "passed", "-", "in", "db", "name", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L649-L709
propelorm/Propel
runtime/lib/Propel.php
Propel.processDriverOptions
private static function processDriverOptions($source, &$write_to) { foreach ($source as $option => $optiondata) { if (is_string($option) && strpos($option, '::') !== false) { $key = $option; } elseif (is_string($option)) { $key = 'PropelPDO::' . $option; } if (!defined($key)) { throw new PropelException("Invalid PDO option/attribute name specified: " . $key); } $key = constant($key); $value = $optiondata['value']; if (is_string($value) && strpos($value, '::') !== false) { if (!defined($value)) { throw new PropelException("Invalid PDO option/attribute value specified: " . $value); } $value = constant($value); } $write_to[$key] = $value; } }
php
private static function processDriverOptions($source, &$write_to) { foreach ($source as $option => $optiondata) { if (is_string($option) && strpos($option, '::') !== false) { $key = $option; } elseif (is_string($option)) { $key = 'PropelPDO::' . $option; } if (!defined($key)) { throw new PropelException("Invalid PDO option/attribute name specified: " . $key); } $key = constant($key); $value = $optiondata['value']; if (is_string($value) && strpos($value, '::') !== false) { if (!defined($value)) { throw new PropelException("Invalid PDO option/attribute value specified: " . $value); } $value = constant($value); } $write_to[$key] = $value; } }
[ "private", "static", "function", "processDriverOptions", "(", "$", "source", ",", "&", "$", "write_to", ")", "{", "foreach", "(", "$", "source", "as", "$", "option", "=>", "$", "optiondata", ")", "{", "if", "(", "is_string", "(", "$", "option", ")", "&&", "strpos", "(", "$", "option", ",", "'::'", ")", "!==", "false", ")", "{", "$", "key", "=", "$", "option", ";", "}", "elseif", "(", "is_string", "(", "$", "option", ")", ")", "{", "$", "key", "=", "'PropelPDO::'", ".", "$", "option", ";", "}", "if", "(", "!", "defined", "(", "$", "key", ")", ")", "{", "throw", "new", "PropelException", "(", "\"Invalid PDO option/attribute name specified: \"", ".", "$", "key", ")", ";", "}", "$", "key", "=", "constant", "(", "$", "key", ")", ";", "$", "value", "=", "$", "optiondata", "[", "'value'", "]", ";", "if", "(", "is_string", "(", "$", "value", ")", "&&", "strpos", "(", "$", "value", ",", "'::'", ")", "!==", "false", ")", "{", "if", "(", "!", "defined", "(", "$", "value", ")", ")", "{", "throw", "new", "PropelException", "(", "\"Invalid PDO option/attribute value specified: \"", ".", "$", "value", ")", ";", "}", "$", "value", "=", "constant", "(", "$", "value", ")", ";", "}", "$", "write_to", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Internal function to handle driver options or conneciton attributes in PDO. Process the INI file flags to be passed to each connection. @param array Where to find the list of constant flags and their new setting. @param array Put the data into here @throws PropelException If invalid options were specified.
[ "Internal", "function", "to", "handle", "driver", "options", "or", "conneciton", "attributes", "in", "PDO", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L721-L744
propelorm/Propel
runtime/lib/Propel.php
Propel.getDB
public static function getDB($name = null) { if ($name === null) { $name = self::getDefaultDB(); } if (!isset(self::$adapterMap[$name])) { if (!isset(self::$configuration['datasources'][$name]['adapter'])) { throw new PropelException("Unable to find adapter for datasource [" . $name . "]."); } $db = DBAdapter::factory(self::$configuration['datasources'][$name]['adapter']); // register the adapter for this name self::$adapterMap[$name] = $db; } return self::$adapterMap[$name]; }
php
public static function getDB($name = null) { if ($name === null) { $name = self::getDefaultDB(); } if (!isset(self::$adapterMap[$name])) { if (!isset(self::$configuration['datasources'][$name]['adapter'])) { throw new PropelException("Unable to find adapter for datasource [" . $name . "]."); } $db = DBAdapter::factory(self::$configuration['datasources'][$name]['adapter']); // register the adapter for this name self::$adapterMap[$name] = $db; } return self::$adapterMap[$name]; }
[ "public", "static", "function", "getDB", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "self", "::", "getDefaultDB", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "adapterMap", "[", "$", "name", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "$", "name", "]", "[", "'adapter'", "]", ")", ")", "{", "throw", "new", "PropelException", "(", "\"Unable to find adapter for datasource [\"", ".", "$", "name", ".", "\"].\"", ")", ";", "}", "$", "db", "=", "DBAdapter", "::", "factory", "(", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "$", "name", "]", "[", "'adapter'", "]", ")", ";", "// register the adapter for this name", "self", "::", "$", "adapterMap", "[", "$", "name", "]", "=", "$", "db", ";", "}", "return", "self", "::", "$", "adapterMap", "[", "$", "name", "]", ";", "}" ]
Returns database adapter for a specific datasource. @param string The datasource name. @return DBAdapter The corresponding database adapter. @throws PropelException If unable to find DBdapter for specified db.
[ "Returns", "database", "adapter", "for", "a", "specific", "datasource", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L755-L771
propelorm/Propel
runtime/lib/Propel.php
Propel.setDB
public static function setDB($name, DBAdapter $adapter) { if ($name === null) { $name = self::getDefaultDB(); } self::$adapterMap[$name] = $adapter; }
php
public static function setDB($name, DBAdapter $adapter) { if ($name === null) { $name = self::getDefaultDB(); } self::$adapterMap[$name] = $adapter; }
[ "public", "static", "function", "setDB", "(", "$", "name", ",", "DBAdapter", "$", "adapter", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "$", "name", "=", "self", "::", "getDefaultDB", "(", ")", ";", "}", "self", "::", "$", "adapterMap", "[", "$", "name", "]", "=", "$", "adapter", ";", "}" ]
Sets a database adapter for specified datasource. @param string $name The datasource name. @param DBAdapter $adapter The DBAdapter implementation to use.
[ "Sets", "a", "database", "adapter", "for", "specified", "datasource", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L779-L785
propelorm/Propel
runtime/lib/Propel.php
Propel.getDefaultDB
public static function getDefaultDB() { if (self::$defaultDBName === null) { // Determine default database name. self::$defaultDBName = isset(self::$configuration['datasources']['default']) && is_scalar(self::$configuration['datasources']['default']) ? self::$configuration['datasources']['default'] : self::DEFAULT_NAME; } return self::$defaultDBName; }
php
public static function getDefaultDB() { if (self::$defaultDBName === null) { // Determine default database name. self::$defaultDBName = isset(self::$configuration['datasources']['default']) && is_scalar(self::$configuration['datasources']['default']) ? self::$configuration['datasources']['default'] : self::DEFAULT_NAME; } return self::$defaultDBName; }
[ "public", "static", "function", "getDefaultDB", "(", ")", "{", "if", "(", "self", "::", "$", "defaultDBName", "===", "null", ")", "{", "// Determine default database name.", "self", "::", "$", "defaultDBName", "=", "isset", "(", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "'default'", "]", ")", "&&", "is_scalar", "(", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "'default'", "]", ")", "?", "self", "::", "$", "configuration", "[", "'datasources'", "]", "[", "'default'", "]", ":", "self", "::", "DEFAULT_NAME", ";", "}", "return", "self", "::", "$", "defaultDBName", ";", "}" ]
Returns the name of the default database. @return string Name of the default DB
[ "Returns", "the", "name", "of", "the", "default", "database", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L792-L800
propelorm/Propel
runtime/lib/Propel.php
Propel.autoload
public static function autoload($className) { if (isset(self::$autoloadMap[$className])) { require self::$baseDir . self::$autoloadMap[$className]; return true; } return false; }
php
public static function autoload($className) { if (isset(self::$autoloadMap[$className])) { require self::$baseDir . self::$autoloadMap[$className]; return true; } return false; }
[ "public", "static", "function", "autoload", "(", "$", "className", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "autoloadMap", "[", "$", "className", "]", ")", ")", "{", "require", "self", "::", "$", "baseDir", ".", "self", "::", "$", "autoloadMap", "[", "$", "className", "]", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Autoload function for loading propel dependencies. @param string The class name needing loading. @return boolean TRUE if the class was loaded, false otherwise.
[ "Autoload", "function", "for", "loading", "propel", "dependencies", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L823-L832
propelorm/Propel
runtime/lib/Propel.php
Propel.importClass
public static function importClass($path) { // extract classname if (($pos = strrpos($path, '.')) === false) { $class = $path; } else { $class = substr($path, $pos + 1); } // check if class exists, using autoloader to attempt to load it. if (class_exists($class, $useAutoload = true)) { return $class; } // turn to filesystem path $path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php'; // include class $ret = include_once($path); if ($ret === false) { throw new PropelException("Unable to import class: " . $class . " from " . $path); } // return qualified name return $class; }
php
public static function importClass($path) { // extract classname if (($pos = strrpos($path, '.')) === false) { $class = $path; } else { $class = substr($path, $pos + 1); } // check if class exists, using autoloader to attempt to load it. if (class_exists($class, $useAutoload = true)) { return $class; } // turn to filesystem path $path = strtr($path, '.', DIRECTORY_SEPARATOR) . '.php'; // include class $ret = include_once($path); if ($ret === false) { throw new PropelException("Unable to import class: " . $class . " from " . $path); } // return qualified name return $class; }
[ "public", "static", "function", "importClass", "(", "$", "path", ")", "{", "// extract classname", "if", "(", "(", "$", "pos", "=", "strrpos", "(", "$", "path", ",", "'.'", ")", ")", "===", "false", ")", "{", "$", "class", "=", "$", "path", ";", "}", "else", "{", "$", "class", "=", "substr", "(", "$", "path", ",", "$", "pos", "+", "1", ")", ";", "}", "// check if class exists, using autoloader to attempt to load it.", "if", "(", "class_exists", "(", "$", "class", ",", "$", "useAutoload", "=", "true", ")", ")", "{", "return", "$", "class", ";", "}", "// turn to filesystem path", "$", "path", "=", "strtr", "(", "$", "path", ",", "'.'", ",", "DIRECTORY_SEPARATOR", ")", ".", "'.php'", ";", "// include class", "$", "ret", "=", "include_once", "(", "$", "path", ")", ";", "if", "(", "$", "ret", "===", "false", ")", "{", "throw", "new", "PropelException", "(", "\"Unable to import class: \"", ".", "$", "class", ".", "\" from \"", ".", "$", "path", ")", ";", "}", "// return qualified name", "return", "$", "class", ";", "}" ]
Include once a file specified in DOT notation and return unqualified classname. Typically, Propel uses autoload is used to load classes and expects that all classes referenced within Propel are included in Propel's autoload map. This method is only called when a specific non-Propel classname was specified -- for example, the classname of a validator in the schema.xml. This method will attempt to include that class via autoload and then relative to a location on the include_path. @param string $class dot-path to clas (e.g. path.to.my.ClassName). @return string unqualified classname @throws PropelException
[ "Include", "once", "a", "file", "specified", "in", "DOT", "notation", "and", "return", "unqualified", "classname", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/Propel.php#L859-L884
propelorm/Propel
generator/lib/task/PropelDataSQLTask.php
PropelDataSQLTask.getDatabase
private function getDatabase($name) { foreach ($this->getDataModels() as $dm) { foreach ($dm->getDatabases() as $db) { if ($db->getName() == $name) { return $db; } } } }
php
private function getDatabase($name) { foreach ($this->getDataModels() as $dm) { foreach ($dm->getDatabases() as $db) { if ($db->getName() == $name) { return $db; } } } }
[ "private", "function", "getDatabase", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "getDataModels", "(", ")", "as", "$", "dm", ")", "{", "foreach", "(", "$", "dm", "->", "getDatabases", "(", ")", "as", "$", "db", ")", "{", "if", "(", "$", "db", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "return", "$", "db", ";", "}", "}", "}", "}" ]
Search through all data models looking for matching database. @return Database or NULL if none found.
[ "Search", "through", "all", "data", "models", "looking", "for", "matching", "database", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelDataSQLTask.php#L119-L128
propelorm/Propel
generator/lib/task/PropelDataSQLTask.php
PropelDataSQLTask.main
public function main() { $this->validate(); $targetDatabase = $this->getTargetDatabase(); $platform = $this->getGeneratorConfig()->getConfiguredPlatform(); // Load the Data XML -> DB Name properties $map = new Properties(); try { $map->load($this->getDataDbMap()); } catch (IOException $ioe) { throw new BuildException("Cannot open and process the datadbmap!", $ioe); } // Parse each file in the data -> db map foreach ($map->keys() as $dataXMLFilename) { $dataXMLFile = new PhingFile($this->srcDir, $dataXMLFilename); // if file exists then proceed if ($dataXMLFile->exists()) { $dbname = $map->get($dataXMLFilename); $db = $this->getDatabase($dbname); if (!$db) { throw new BuildException("Cannot find instantiated Database for name '$dbname' from datadbmap file."); } $db->setPlatform($platform); $outFile = $this->getMappedFile($dataXMLFilename); $sqlWriter = new FileWriter($outFile); $this->log("Creating SQL from XML data dump file: " . $dataXMLFile->getAbsolutePath()); try { $dataXmlParser = new XmlToDataSQL($db, $this->getGeneratorConfig(), $this->dbEncoding); $dataXmlParser->transform($dataXMLFile, $sqlWriter); } catch (Exception $e) { throw new BuildException("Exception parsing data XML: " . $e->getMessage()); } // Place the generated SQL file(s) $p = new Properties(); if ($this->getSqlDbMap()->exists()) { $p->load($this->getSqlDbMap()); } $p->setProperty($outFile->getName(), $db->getName()); $p->store($this->getSqlDbMap(), "Sqlfile -> Database map"); } else { $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN); } } // foreach data xml file }
php
public function main() { $this->validate(); $targetDatabase = $this->getTargetDatabase(); $platform = $this->getGeneratorConfig()->getConfiguredPlatform(); // Load the Data XML -> DB Name properties $map = new Properties(); try { $map->load($this->getDataDbMap()); } catch (IOException $ioe) { throw new BuildException("Cannot open and process the datadbmap!", $ioe); } // Parse each file in the data -> db map foreach ($map->keys() as $dataXMLFilename) { $dataXMLFile = new PhingFile($this->srcDir, $dataXMLFilename); // if file exists then proceed if ($dataXMLFile->exists()) { $dbname = $map->get($dataXMLFilename); $db = $this->getDatabase($dbname); if (!$db) { throw new BuildException("Cannot find instantiated Database for name '$dbname' from datadbmap file."); } $db->setPlatform($platform); $outFile = $this->getMappedFile($dataXMLFilename); $sqlWriter = new FileWriter($outFile); $this->log("Creating SQL from XML data dump file: " . $dataXMLFile->getAbsolutePath()); try { $dataXmlParser = new XmlToDataSQL($db, $this->getGeneratorConfig(), $this->dbEncoding); $dataXmlParser->transform($dataXMLFile, $sqlWriter); } catch (Exception $e) { throw new BuildException("Exception parsing data XML: " . $e->getMessage()); } // Place the generated SQL file(s) $p = new Properties(); if ($this->getSqlDbMap()->exists()) { $p->load($this->getSqlDbMap()); } $p->setProperty($outFile->getName(), $db->getName()); $p->store($this->getSqlDbMap(), "Sqlfile -> Database map"); } else { $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN); } } // foreach data xml file }
[ "public", "function", "main", "(", ")", "{", "$", "this", "->", "validate", "(", ")", ";", "$", "targetDatabase", "=", "$", "this", "->", "getTargetDatabase", "(", ")", ";", "$", "platform", "=", "$", "this", "->", "getGeneratorConfig", "(", ")", "->", "getConfiguredPlatform", "(", ")", ";", "// Load the Data XML -> DB Name properties", "$", "map", "=", "new", "Properties", "(", ")", ";", "try", "{", "$", "map", "->", "load", "(", "$", "this", "->", "getDataDbMap", "(", ")", ")", ";", "}", "catch", "(", "IOException", "$", "ioe", ")", "{", "throw", "new", "BuildException", "(", "\"Cannot open and process the datadbmap!\"", ",", "$", "ioe", ")", ";", "}", "// Parse each file in the data -> db map", "foreach", "(", "$", "map", "->", "keys", "(", ")", "as", "$", "dataXMLFilename", ")", "{", "$", "dataXMLFile", "=", "new", "PhingFile", "(", "$", "this", "->", "srcDir", ",", "$", "dataXMLFilename", ")", ";", "// if file exists then proceed", "if", "(", "$", "dataXMLFile", "->", "exists", "(", ")", ")", "{", "$", "dbname", "=", "$", "map", "->", "get", "(", "$", "dataXMLFilename", ")", ";", "$", "db", "=", "$", "this", "->", "getDatabase", "(", "$", "dbname", ")", ";", "if", "(", "!", "$", "db", ")", "{", "throw", "new", "BuildException", "(", "\"Cannot find instantiated Database for name '$dbname' from datadbmap file.\"", ")", ";", "}", "$", "db", "->", "setPlatform", "(", "$", "platform", ")", ";", "$", "outFile", "=", "$", "this", "->", "getMappedFile", "(", "$", "dataXMLFilename", ")", ";", "$", "sqlWriter", "=", "new", "FileWriter", "(", "$", "outFile", ")", ";", "$", "this", "->", "log", "(", "\"Creating SQL from XML data dump file: \"", ".", "$", "dataXMLFile", "->", "getAbsolutePath", "(", ")", ")", ";", "try", "{", "$", "dataXmlParser", "=", "new", "XmlToDataSQL", "(", "$", "db", ",", "$", "this", "->", "getGeneratorConfig", "(", ")", ",", "$", "this", "->", "dbEncoding", ")", ";", "$", "dataXmlParser", "->", "transform", "(", "$", "dataXMLFile", ",", "$", "sqlWriter", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "BuildException", "(", "\"Exception parsing data XML: \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "// Place the generated SQL file(s)", "$", "p", "=", "new", "Properties", "(", ")", ";", "if", "(", "$", "this", "->", "getSqlDbMap", "(", ")", "->", "exists", "(", ")", ")", "{", "$", "p", "->", "load", "(", "$", "this", "->", "getSqlDbMap", "(", ")", ")", ";", "}", "$", "p", "->", "setProperty", "(", "$", "outFile", "->", "getName", "(", ")", ",", "$", "db", "->", "getName", "(", ")", ")", ";", "$", "p", "->", "store", "(", "$", "this", "->", "getSqlDbMap", "(", ")", ",", "\"Sqlfile -> Database map\"", ")", ";", "}", "else", "{", "$", "this", "->", "log", "(", "\"File '\"", ".", "$", "dataXMLFile", "->", "getAbsolutePath", "(", ")", ".", "\"' in datadbmap does not exist, so skipping it.\"", ",", "Project", "::", "MSG_WARN", ")", ";", "}", "}", "// foreach data xml file", "}" ]
Main method parses the XML files and creates SQL files. @return void @throws Exception If there is an error parsing the data xml. @throws BuildException
[ "Main", "method", "parses", "the", "XML", "files", "and", "creates", "SQL", "files", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelDataSQLTask.php#L137-L196
propelorm/Propel
generator/lib/behavior/SoftDeleteBehavior.php
SoftDeleteBehavior.modifyTable
public function modifyTable() { if (!$this->getTable()->containsColumn($this->getParameter('deleted_column'))) { $this->getTable()->addColumn(array( 'name' => $this->getParameter('deleted_column'), 'type' => 'TIMESTAMP' )); } }
php
public function modifyTable() { if (!$this->getTable()->containsColumn($this->getParameter('deleted_column'))) { $this->getTable()->addColumn(array( 'name' => $this->getParameter('deleted_column'), 'type' => 'TIMESTAMP' )); } }
[ "public", "function", "modifyTable", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getTable", "(", ")", "->", "containsColumn", "(", "$", "this", "->", "getParameter", "(", "'deleted_column'", ")", ")", ")", "{", "$", "this", "->", "getTable", "(", ")", "->", "addColumn", "(", "array", "(", "'name'", "=>", "$", "this", "->", "getParameter", "(", "'deleted_column'", ")", ",", "'type'", "=>", "'TIMESTAMP'", ")", ")", ";", "}", "}" ]
Add the deleted_column to the current table
[ "Add", "the", "deleted_column", "to", "the", "current", "table" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/SoftDeleteBehavior.php#L30-L38
propelorm/Propel
generator/lib/builder/om/PHP5ExtensionObjectBuilder.php
PHP5ExtensionObjectBuilder.addIncludes
protected function addIncludes(&$script) { switch ($this->getTable()->treeMode()) { case 'NestedSet': $requiredClassFilePath = $this->getNestedSetBuilder()->getClassFilePath(); break; case 'MaterializedPath': case 'AdjacencyList': default: $requiredClassFilePath = $this->getObjectBuilder()->getClassFilePath(); break; } $script .= " require '" . $requiredClassFilePath . "'; "; }
php
protected function addIncludes(&$script) { switch ($this->getTable()->treeMode()) { case 'NestedSet': $requiredClassFilePath = $this->getNestedSetBuilder()->getClassFilePath(); break; case 'MaterializedPath': case 'AdjacencyList': default: $requiredClassFilePath = $this->getObjectBuilder()->getClassFilePath(); break; } $script .= " require '" . $requiredClassFilePath . "'; "; }
[ "protected", "function", "addIncludes", "(", "&", "$", "script", ")", "{", "switch", "(", "$", "this", "->", "getTable", "(", ")", "->", "treeMode", "(", ")", ")", "{", "case", "'NestedSet'", ":", "$", "requiredClassFilePath", "=", "$", "this", "->", "getNestedSetBuilder", "(", ")", "->", "getClassFilePath", "(", ")", ";", "break", ";", "case", "'MaterializedPath'", ":", "case", "'AdjacencyList'", ":", "default", ":", "$", "requiredClassFilePath", "=", "$", "this", "->", "getObjectBuilder", "(", ")", "->", "getClassFilePath", "(", ")", ";", "break", ";", "}", "$", "script", ".=", "\"\nrequire '\"", ".", "$", "requiredClassFilePath", ".", "\"';\n\"", ";", "}" ]
Adds the include() statements for files that this class depends on or utilizes. @param string &$script The script will be modified in this method.
[ "Adds", "the", "include", "()", "statements", "for", "files", "that", "this", "class", "depends", "on", "or", "utilizes", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php#L40-L57
propelorm/Propel
generator/lib/builder/om/PHP5ExtensionObjectBuilder.php
PHP5ExtensionObjectBuilder.addClassOpen
protected function addClassOpen(&$script) { $table = $this->getTable(); $this->declareClassFromBuilder($this->getObjectBuilder()); $tableName = $table->getName(); $tableDesc = $table->getDescription(); switch ($table->treeMode()) { case 'NestedSet': $baseClassname = $this->getNestedSetBuilder()->getClassname(); break; case 'MaterializedPath': case "AdjacencyList": default: $baseClassname = $this->getObjectBuilder()->getClassname(); break; } if ($this->getBuildProperty('addClassLevelComment')) { $script .= " /** * Skeleton subclass for representing a row from the '$tableName' table. * * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { $now = strftime('%c'); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * * $now *"; } $script .= " * You should add additional methods to this class to meet the * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * * @package propel.generator." . $this->getPackage() . " */"; } $script .= " " . ($table->isAbstract() ? "abstract " : "") . "class " . $this->getClassname() . " extends $baseClassname {"; }
php
protected function addClassOpen(&$script) { $table = $this->getTable(); $this->declareClassFromBuilder($this->getObjectBuilder()); $tableName = $table->getName(); $tableDesc = $table->getDescription(); switch ($table->treeMode()) { case 'NestedSet': $baseClassname = $this->getNestedSetBuilder()->getClassname(); break; case 'MaterializedPath': case "AdjacencyList": default: $baseClassname = $this->getObjectBuilder()->getClassname(); break; } if ($this->getBuildProperty('addClassLevelComment')) { $script .= " /** * Skeleton subclass for representing a row from the '$tableName' table. * * $tableDesc *"; if ($this->getBuildProperty('addTimeStamp')) { $now = strftime('%c'); $script .= " * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on: * * $now *"; } $script .= " * You should add additional methods to this class to meet the * application requirements. This class will only be generated as * long as it does not already exist in the output directory. * * @package propel.generator." . $this->getPackage() . " */"; } $script .= " " . ($table->isAbstract() ? "abstract " : "") . "class " . $this->getClassname() . " extends $baseClassname {"; }
[ "protected", "function", "addClassOpen", "(", "&", "$", "script", ")", "{", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "$", "this", "->", "declareClassFromBuilder", "(", "$", "this", "->", "getObjectBuilder", "(", ")", ")", ";", "$", "tableName", "=", "$", "table", "->", "getName", "(", ")", ";", "$", "tableDesc", "=", "$", "table", "->", "getDescription", "(", ")", ";", "switch", "(", "$", "table", "->", "treeMode", "(", ")", ")", "{", "case", "'NestedSet'", ":", "$", "baseClassname", "=", "$", "this", "->", "getNestedSetBuilder", "(", ")", "->", "getClassname", "(", ")", ";", "break", ";", "case", "'MaterializedPath'", ":", "case", "\"AdjacencyList\"", ":", "default", ":", "$", "baseClassname", "=", "$", "this", "->", "getObjectBuilder", "(", ")", "->", "getClassname", "(", ")", ";", "break", ";", "}", "if", "(", "$", "this", "->", "getBuildProperty", "(", "'addClassLevelComment'", ")", ")", "{", "$", "script", ".=", "\"\n\n/**\n * Skeleton subclass for representing a row from the '$tableName' table.\n *\n * $tableDesc\n *\"", ";", "if", "(", "$", "this", "->", "getBuildProperty", "(", "'addTimeStamp'", ")", ")", "{", "$", "now", "=", "strftime", "(", "'%c'", ")", ";", "$", "script", ".=", "\"\n * This class was autogenerated by Propel \"", ".", "$", "this", "->", "getBuildProperty", "(", "'version'", ")", ".", "\" on:\n *\n * $now\n *\"", ";", "}", "$", "script", ".=", "\"\n * You should add additional methods to this class to meet the\n * application requirements. This class will only be generated as\n * long as it does not already exist in the output directory.\n *\n * @package propel.generator.\"", ".", "$", "this", "->", "getPackage", "(", ")", ".", "\"\n */\"", ";", "}", "$", "script", ".=", "\"\n\"", ".", "(", "$", "table", "->", "isAbstract", "(", ")", "?", "\"abstract \"", ":", "\"\"", ")", ".", "\"class \"", ".", "$", "this", "->", "getClassname", "(", ")", ".", "\" extends $baseClassname\n{\"", ";", "}" ]
Adds class phpdoc comment and opening of class. @param string &$script The script will be modified in this method.
[ "Adds", "class", "phpdoc", "comment", "and", "opening", "of", "class", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ExtensionObjectBuilder.php#L64-L111
propelorm/Propel
generator/lib/task/PropelGraphvizTask.php
PropelGraphvizTask.setOutputDirectory
public function setOutputDirectory(PhingFile $out) { if (!$out->exists()) { $out->mkdirs(); } $this->outDir = $out; }
php
public function setOutputDirectory(PhingFile $out) { if (!$out->exists()) { $out->mkdirs(); } $this->outDir = $out; }
[ "public", "function", "setOutputDirectory", "(", "PhingFile", "$", "out", ")", "{", "if", "(", "!", "$", "out", "->", "exists", "(", ")", ")", "{", "$", "out", "->", "mkdirs", "(", ")", ";", "}", "$", "this", "->", "outDir", "=", "$", "out", ";", "}" ]
Set the sqldbmap. @param PhingFile $out The db map.
[ "Set", "the", "sqldbmap", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelGraphvizTask.php#L48-L54
propelorm/Propel
generator/lib/task/PropelGraphvizTask.php
PropelGraphvizTask.writeDot
public function writeDot($dotSyntax, PhingFile $outputDir, $baseFilename) { $file = new PhingFile($outputDir, $baseFilename . '.schema.dot'); $this->log("Writing dot file to " . $file->getAbsolutePath()); file_put_contents($file->getAbsolutePath(), $dotSyntax); }
php
public function writeDot($dotSyntax, PhingFile $outputDir, $baseFilename) { $file = new PhingFile($outputDir, $baseFilename . '.schema.dot'); $this->log("Writing dot file to " . $file->getAbsolutePath()); file_put_contents($file->getAbsolutePath(), $dotSyntax); }
[ "public", "function", "writeDot", "(", "$", "dotSyntax", ",", "PhingFile", "$", "outputDir", ",", "$", "baseFilename", ")", "{", "$", "file", "=", "new", "PhingFile", "(", "$", "outputDir", ",", "$", "baseFilename", ".", "'.schema.dot'", ")", ";", "$", "this", "->", "log", "(", "\"Writing dot file to \"", ".", "$", "file", "->", "getAbsolutePath", "(", ")", ")", ";", "file_put_contents", "(", "$", "file", "->", "getAbsolutePath", "(", ")", ",", "$", "dotSyntax", ")", ";", "}" ]
probably insecure
[ "probably", "insecure" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/task/PropelGraphvizTask.php#L109-L114
propelorm/Propel
generator/lib/model/Inheritance.php
Inheritance.setupObject
protected function setupObject() { // Clean key from special characters not allowed in constant names $this->key = rtrim(preg_replace('/(\W|_)+/', '_', $this->getAttribute("key")), '_'); $this->className = $this->getAttribute("class"); $this->pkg = $this->getAttribute("package"); $this->ancestor = $this->getAttribute("extends"); }
php
protected function setupObject() { // Clean key from special characters not allowed in constant names $this->key = rtrim(preg_replace('/(\W|_)+/', '_', $this->getAttribute("key")), '_'); $this->className = $this->getAttribute("class"); $this->pkg = $this->getAttribute("package"); $this->ancestor = $this->getAttribute("extends"); }
[ "protected", "function", "setupObject", "(", ")", "{", "// Clean key from special characters not allowed in constant names", "$", "this", "->", "key", "=", "rtrim", "(", "preg_replace", "(", "'/(\\W|_)+/'", ",", "'_'", ",", "$", "this", "->", "getAttribute", "(", "\"key\"", ")", ")", ",", "'_'", ")", ";", "$", "this", "->", "className", "=", "$", "this", "->", "getAttribute", "(", "\"class\"", ")", ";", "$", "this", "->", "pkg", "=", "$", "this", "->", "getAttribute", "(", "\"package\"", ")", ";", "$", "this", "->", "ancestor", "=", "$", "this", "->", "getAttribute", "(", "\"extends\"", ")", ";", "}" ]
Sets up the Inheritance object based on the attributes that were passed to loadFromXML(). @see parent::loadFromXML()
[ "Sets", "up", "the", "Inheritance", "object", "based", "on", "the", "attributes", "that", "were", "passed", "to", "loadFromXML", "()", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/model/Inheritance.php#L35-L42
propelorm/Propel
runtime/lib/adapter/DBOracle.php
DBOracle.initConnection
public function initConnection(PDO $con, array $settings) { $con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); $con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'"); if (isset($settings['queries']) && is_array($settings['queries'])) { foreach ($settings['queries'] as $queries) { foreach ((array) $queries as $query) { $con->exec($query); } } } }
php
public function initConnection(PDO $con, array $settings) { $con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); $con->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'"); if (isset($settings['queries']) && is_array($settings['queries'])) { foreach ($settings['queries'] as $queries) { foreach ((array) $queries as $query) { $con->exec($query); } } } }
[ "public", "function", "initConnection", "(", "PDO", "$", "con", ",", "array", "$", "settings", ")", "{", "$", "con", "->", "exec", "(", "\"ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'\"", ")", ";", "$", "con", "->", "exec", "(", "\"ALTER SESSION SET NLS_TIMESTAMP_FORMAT='YYYY-MM-DD HH24:MI:SS'\"", ")", ";", "if", "(", "isset", "(", "$", "settings", "[", "'queries'", "]", ")", "&&", "is_array", "(", "$", "settings", "[", "'queries'", "]", ")", ")", "{", "foreach", "(", "$", "settings", "[", "'queries'", "]", "as", "$", "queries", ")", "{", "foreach", "(", "(", "array", ")", "$", "queries", "as", "$", "query", ")", "{", "$", "con", "->", "exec", "(", "$", "query", ")", ";", "}", "}", "}", "}" ]
This method is called after a connection was created to run necessary post-initialization queries or code. Removes the charset query and adds the date queries @see parent::initConnection() @param PDO $con @param array $settings A $PDO PDO connection instance
[ "This", "method", "is", "called", "after", "a", "connection", "was", "created", "to", "run", "necessary", "post", "-", "initialization", "queries", "or", "code", ".", "Removes", "the", "charset", "query", "and", "adds", "the", "date", "queries" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBOracle.php#L35-L46
propelorm/Propel
runtime/lib/adapter/DBOracle.php
DBOracle.applyLimit
public function applyLimit(&$sql, $offset, $limit, $criteria = null) { if (BasePeer::needsSelectAliases($criteria)) { $crit = clone $criteria; $selectSql = $this->createSelectSqlPart($crit, $params, true); $sql = $selectSql . substr($sql, strpos($sql, 'FROM') - 1); } $sql = 'SELECT B.* FROM (' . 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A ' . ') B WHERE '; if ($offset > 0) { $sql .= ' B.PROPEL_ROWNUM > ' . $offset; if ($limit > 0) { $sql .= ' AND B.PROPEL_ROWNUM <= ' . ($offset + $limit); } } else { $sql .= ' B.PROPEL_ROWNUM <= ' . $limit; } }
php
public function applyLimit(&$sql, $offset, $limit, $criteria = null) { if (BasePeer::needsSelectAliases($criteria)) { $crit = clone $criteria; $selectSql = $this->createSelectSqlPart($crit, $params, true); $sql = $selectSql . substr($sql, strpos($sql, 'FROM') - 1); } $sql = 'SELECT B.* FROM (' . 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A ' . ') B WHERE '; if ($offset > 0) { $sql .= ' B.PROPEL_ROWNUM > ' . $offset; if ($limit > 0) { $sql .= ' AND B.PROPEL_ROWNUM <= ' . ($offset + $limit); } } else { $sql .= ' B.PROPEL_ROWNUM <= ' . $limit; } }
[ "public", "function", "applyLimit", "(", "&", "$", "sql", ",", "$", "offset", ",", "$", "limit", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "BasePeer", "::", "needsSelectAliases", "(", "$", "criteria", ")", ")", "{", "$", "crit", "=", "clone", "$", "criteria", ";", "$", "selectSql", "=", "$", "this", "->", "createSelectSqlPart", "(", "$", "crit", ",", "$", "params", ",", "true", ")", ";", "$", "sql", "=", "$", "selectSql", ".", "substr", "(", "$", "sql", ",", "strpos", "(", "$", "sql", ",", "'FROM'", ")", "-", "1", ")", ";", "}", "$", "sql", "=", "'SELECT B.* FROM ('", ".", "'SELECT A.*, rownum AS PROPEL_ROWNUM FROM ('", ".", "$", "sql", ".", "') A '", ".", "') B WHERE '", ";", "if", "(", "$", "offset", ">", "0", ")", "{", "$", "sql", ".=", "' B.PROPEL_ROWNUM > '", ".", "$", "offset", ";", "if", "(", "$", "limit", ">", "0", ")", "{", "$", "sql", ".=", "' AND B.PROPEL_ROWNUM <= '", ".", "(", "$", "offset", "+", "$", "limit", ")", ";", "}", "}", "else", "{", "$", "sql", ".=", "' B.PROPEL_ROWNUM <= '", ".", "$", "limit", ";", "}", "}" ]
@see DBAdapter::applyLimit() @param string $sql @param integer $offset @param integer $limit @param null|Criteria $criteria
[ "@see", "DBAdapter", "::", "applyLimit", "()" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBOracle.php#L119-L138
propelorm/Propel
runtime/lib/adapter/DBOracle.php
DBOracle.getId
public function getId(PDO $con, $name = null) { if ($name === null) { throw new PropelException("Unable to fetch next sequence ID without sequence name."); } $stmt = $con->query("SELECT " . $name . ".nextval FROM dual"); $row = $stmt->fetch(PDO::FETCH_NUM); return $row[0]; }
php
public function getId(PDO $con, $name = null) { if ($name === null) { throw new PropelException("Unable to fetch next sequence ID without sequence name."); } $stmt = $con->query("SELECT " . $name . ".nextval FROM dual"); $row = $stmt->fetch(PDO::FETCH_NUM); return $row[0]; }
[ "public", "function", "getId", "(", "PDO", "$", "con", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "throw", "new", "PropelException", "(", "\"Unable to fetch next sequence ID without sequence name.\"", ")", ";", "}", "$", "stmt", "=", "$", "con", "->", "query", "(", "\"SELECT \"", ".", "$", "name", ".", "\".nextval FROM dual\"", ")", ";", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_NUM", ")", ";", "return", "$", "row", "[", "0", "]", ";", "}" ]
@param PDO $con @param string $name @throws PropelException @return integer
[ "@param", "PDO", "$con", "@param", "string", "$name" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBOracle.php#L155-L165
propelorm/Propel
runtime/lib/adapter/DBOracle.php
DBOracle.doExplainPlan
public function doExplainPlan(PropelPDO $con, $query) { $con->beginTransaction(); if ($query instanceof ModelCriteria) { $params = array(); $dbMap = Propel::getDatabaseMap($query->getDbName()); $sql = BasePeer::createSelectSql($query, $params); } else { $sql = $query; } // unique id for the query string $uniqueId = uniqid('Propel', true); $stmt = $con->prepare($this->getExplainPlanQuery($sql, $uniqueId)); if ($query instanceof ModelCriteria) { $this->bindValues($stmt, $params, $dbMap); } $stmt->execute(); // explain plan is save in a table, data must be commit $con->commit(); $stmt = $con->prepare($this->getExplainPlanReadQuery($uniqueId)); $stmt->execute(); return $stmt; }
php
public function doExplainPlan(PropelPDO $con, $query) { $con->beginTransaction(); if ($query instanceof ModelCriteria) { $params = array(); $dbMap = Propel::getDatabaseMap($query->getDbName()); $sql = BasePeer::createSelectSql($query, $params); } else { $sql = $query; } // unique id for the query string $uniqueId = uniqid('Propel', true); $stmt = $con->prepare($this->getExplainPlanQuery($sql, $uniqueId)); if ($query instanceof ModelCriteria) { $this->bindValues($stmt, $params, $dbMap); } $stmt->execute(); // explain plan is save in a table, data must be commit $con->commit(); $stmt = $con->prepare($this->getExplainPlanReadQuery($uniqueId)); $stmt->execute(); return $stmt; }
[ "public", "function", "doExplainPlan", "(", "PropelPDO", "$", "con", ",", "$", "query", ")", "{", "$", "con", "->", "beginTransaction", "(", ")", ";", "if", "(", "$", "query", "instanceof", "ModelCriteria", ")", "{", "$", "params", "=", "array", "(", ")", ";", "$", "dbMap", "=", "Propel", "::", "getDatabaseMap", "(", "$", "query", "->", "getDbName", "(", ")", ")", ";", "$", "sql", "=", "BasePeer", "::", "createSelectSql", "(", "$", "query", ",", "$", "params", ")", ";", "}", "else", "{", "$", "sql", "=", "$", "query", ";", "}", "// unique id for the query string", "$", "uniqueId", "=", "uniqid", "(", "'Propel'", ",", "true", ")", ";", "$", "stmt", "=", "$", "con", "->", "prepare", "(", "$", "this", "->", "getExplainPlanQuery", "(", "$", "sql", ",", "$", "uniqueId", ")", ")", ";", "if", "(", "$", "query", "instanceof", "ModelCriteria", ")", "{", "$", "this", "->", "bindValues", "(", "$", "stmt", ",", "$", "params", ",", "$", "dbMap", ")", ";", "}", "$", "stmt", "->", "execute", "(", ")", ";", "// explain plan is save in a table, data must be commit", "$", "con", "->", "commit", "(", ")", ";", "$", "stmt", "=", "$", "con", "->", "prepare", "(", "$", "this", "->", "getExplainPlanReadQuery", "(", "$", "uniqueId", ")", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "return", "$", "stmt", ";", "}" ]
Do Explain Plan for query object or query string @param PropelPDO $con propel connection @param ModelCriteria|string $query query the criteria or the query string @throws PropelException @return PDOStatement A PDO statement executed using the connection, ready to be fetched
[ "Do", "Explain", "Plan", "for", "query", "object", "or", "query", "string" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/adapter/DBOracle.php#L254-L281
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.setBuildProperties
public function setBuildProperties($props) { $this->buildProperties = array(); $renamedPropelProps = array(); foreach ($props as $key => $propValue) { if (strpos($key, "propel.") === 0) { $newKey = substr($key, strlen("propel.")); $j = strpos($newKey, '.'); while ($j !== false) { $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); $j = strpos($newKey, '.'); } $this->setBuildProperty($newKey, $propValue); } } }
php
public function setBuildProperties($props) { $this->buildProperties = array(); $renamedPropelProps = array(); foreach ($props as $key => $propValue) { if (strpos($key, "propel.") === 0) { $newKey = substr($key, strlen("propel.")); $j = strpos($newKey, '.'); while ($j !== false) { $newKey = substr($newKey, 0, $j) . ucfirst(substr($newKey, $j + 1)); $j = strpos($newKey, '.'); } $this->setBuildProperty($newKey, $propValue); } } }
[ "public", "function", "setBuildProperties", "(", "$", "props", ")", "{", "$", "this", "->", "buildProperties", "=", "array", "(", ")", ";", "$", "renamedPropelProps", "=", "array", "(", ")", ";", "foreach", "(", "$", "props", "as", "$", "key", "=>", "$", "propValue", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "\"propel.\"", ")", "===", "0", ")", "{", "$", "newKey", "=", "substr", "(", "$", "key", ",", "strlen", "(", "\"propel.\"", ")", ")", ";", "$", "j", "=", "strpos", "(", "$", "newKey", ",", "'.'", ")", ";", "while", "(", "$", "j", "!==", "false", ")", "{", "$", "newKey", "=", "substr", "(", "$", "newKey", ",", "0", ",", "$", "j", ")", ".", "ucfirst", "(", "substr", "(", "$", "newKey", ",", "$", "j", "+", "1", ")", ")", ";", "$", "j", "=", "strpos", "(", "$", "newKey", ",", "'.'", ")", ";", "}", "$", "this", "->", "setBuildProperty", "(", "$", "newKey", ",", "$", "propValue", ")", ";", "}", "}", "}" ]
Parses the passed-in properties, renaming and saving eligible properties in this object. Renames the propel.xxx properties to just xxx and renames any xxx.yyy properties to xxxYyy as PHP doesn't like the xxx.yyy syntax. @param mixed $props Array or Iterator
[ "Parses", "the", "passed", "-", "in", "properties", "renaming", "and", "saving", "eligible", "properties", "in", "this", "object", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L64-L80
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.getBuildProperty
public function getBuildProperty($name) { return isset($this->buildProperties[$name]) ? $this->buildProperties[$name] : null; }
php
public function getBuildProperty($name) { return isset($this->buildProperties[$name]) ? $this->buildProperties[$name] : null; }
[ "public", "function", "getBuildProperty", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "buildProperties", "[", "$", "name", "]", ")", "?", "$", "this", "->", "buildProperties", "[", "$", "name", "]", ":", "null", ";", "}" ]
Gets a specific propel (renamed) property from the build. @param string $name @return mixed
[ "Gets", "a", "specific", "propel", "(", "renamed", ")", "property", "from", "the", "build", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L89-L92
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.getClassname
public function getClassname($propname) { $classpath = $this->getBuildProperty($propname); if (null === $classpath) { throw new BuildException("Unable to find class path for '$propname' property."); } // This is a slight hack to workaround camel case inconsistencies for the DataSQL classes. // Basically, we want to turn ?.?.?.sqliteDataSQLBuilder into ?.?.?.SqliteDataSQLBuilder $lastdotpos = strrpos($classpath, '.'); if ($lastdotpos !== false) { $classpath{$lastdotpos + 1} = strtoupper($classpath{$lastdotpos + 1}); } else { // Allows to configure full classname instead of a dot-path notation if (class_exists($classpath)) { return $classpath; } $classpath = ucfirst($classpath); } if (empty($classpath)) { throw new BuildException("Unable to find class path for '$propname' property."); } $clazz = Phing::import($classpath); return $clazz; }
php
public function getClassname($propname) { $classpath = $this->getBuildProperty($propname); if (null === $classpath) { throw new BuildException("Unable to find class path for '$propname' property."); } // This is a slight hack to workaround camel case inconsistencies for the DataSQL classes. // Basically, we want to turn ?.?.?.sqliteDataSQLBuilder into ?.?.?.SqliteDataSQLBuilder $lastdotpos = strrpos($classpath, '.'); if ($lastdotpos !== false) { $classpath{$lastdotpos + 1} = strtoupper($classpath{$lastdotpos + 1}); } else { // Allows to configure full classname instead of a dot-path notation if (class_exists($classpath)) { return $classpath; } $classpath = ucfirst($classpath); } if (empty($classpath)) { throw new BuildException("Unable to find class path for '$propname' property."); } $clazz = Phing::import($classpath); return $clazz; }
[ "public", "function", "getClassname", "(", "$", "propname", ")", "{", "$", "classpath", "=", "$", "this", "->", "getBuildProperty", "(", "$", "propname", ")", ";", "if", "(", "null", "===", "$", "classpath", ")", "{", "throw", "new", "BuildException", "(", "\"Unable to find class path for '$propname' property.\"", ")", ";", "}", "// This is a slight hack to workaround camel case inconsistencies for the DataSQL classes.", "// Basically, we want to turn ?.?.?.sqliteDataSQLBuilder into ?.?.?.SqliteDataSQLBuilder", "$", "lastdotpos", "=", "strrpos", "(", "$", "classpath", ",", "'.'", ")", ";", "if", "(", "$", "lastdotpos", "!==", "false", ")", "{", "$", "classpath", "{", "$", "lastdotpos", "+", "1", "}", "=", "strtoupper", "(", "$", "classpath", "{", "$", "lastdotpos", "+", "1", "}", ")", ";", "}", "else", "{", "// Allows to configure full classname instead of a dot-path notation", "if", "(", "class_exists", "(", "$", "classpath", ")", ")", "{", "return", "$", "classpath", ";", "}", "$", "classpath", "=", "ucfirst", "(", "$", "classpath", ")", ";", "}", "if", "(", "empty", "(", "$", "classpath", ")", ")", "{", "throw", "new", "BuildException", "(", "\"Unable to find class path for '$propname' property.\"", ")", ";", "}", "$", "clazz", "=", "Phing", "::", "import", "(", "$", "classpath", ")", ";", "return", "$", "clazz", ";", "}" ]
Resolves and returns the class name based on the specified property value. @param string $propname The name of the property that holds the class path (dot-path notation). @return string The class name. @throws BuildException If the classname cannot be determined or class cannot be loaded.
[ "Resolves", "and", "returns", "the", "class", "name", "based", "on", "the", "specified", "property", "value", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L113-L140
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.getConfiguredPlatform
public function getConfiguredPlatform(PDO $con = null, $database = null) { $buildConnection = $this->getBuildConnection($database); //First try to load platform from the user provided build properties if ($this->getBuildProperty('platformClass')) { // propel.platform.class = platform.${propel.database}Platform by default $clazz = $this->getClassname('platformClass'); } elseif (null !== $buildConnection['adapter']) { $clazz = Phing::import('platform.' . ucfirst($buildConnection['adapter']) . 'Platform'); } else { return null; } $platform = new $clazz(); if (!$platform instanceof PropelPlatformInterface) { throw new BuildException("Specified platform class ($clazz) does not implement teh PropelPlatformInterface interface."); } if ($this->getBuildProperty('disableIdentifierQuoting')) { $platform->setIdentifierQuoting(false); } else { $platform->setIdentifierQuoting(true); } $platform->setConnection($con); $platform->setGeneratorConfig($this); return $platform; }
php
public function getConfiguredPlatform(PDO $con = null, $database = null) { $buildConnection = $this->getBuildConnection($database); //First try to load platform from the user provided build properties if ($this->getBuildProperty('platformClass')) { // propel.platform.class = platform.${propel.database}Platform by default $clazz = $this->getClassname('platformClass'); } elseif (null !== $buildConnection['adapter']) { $clazz = Phing::import('platform.' . ucfirst($buildConnection['adapter']) . 'Platform'); } else { return null; } $platform = new $clazz(); if (!$platform instanceof PropelPlatformInterface) { throw new BuildException("Specified platform class ($clazz) does not implement teh PropelPlatformInterface interface."); } if ($this->getBuildProperty('disableIdentifierQuoting')) { $platform->setIdentifierQuoting(false); } else { $platform->setIdentifierQuoting(true); } $platform->setConnection($con); $platform->setGeneratorConfig($this); return $platform; }
[ "public", "function", "getConfiguredPlatform", "(", "PDO", "$", "con", "=", "null", ",", "$", "database", "=", "null", ")", "{", "$", "buildConnection", "=", "$", "this", "->", "getBuildConnection", "(", "$", "database", ")", ";", "//First try to load platform from the user provided build properties", "if", "(", "$", "this", "->", "getBuildProperty", "(", "'platformClass'", ")", ")", "{", "// propel.platform.class = platform.${propel.database}Platform by default", "$", "clazz", "=", "$", "this", "->", "getClassname", "(", "'platformClass'", ")", ";", "}", "elseif", "(", "null", "!==", "$", "buildConnection", "[", "'adapter'", "]", ")", "{", "$", "clazz", "=", "Phing", "::", "import", "(", "'platform.'", ".", "ucfirst", "(", "$", "buildConnection", "[", "'adapter'", "]", ")", ".", "'Platform'", ")", ";", "}", "else", "{", "return", "null", ";", "}", "$", "platform", "=", "new", "$", "clazz", "(", ")", ";", "if", "(", "!", "$", "platform", "instanceof", "PropelPlatformInterface", ")", "{", "throw", "new", "BuildException", "(", "\"Specified platform class ($clazz) does not implement teh PropelPlatformInterface interface.\"", ")", ";", "}", "if", "(", "$", "this", "->", "getBuildProperty", "(", "'disableIdentifierQuoting'", ")", ")", "{", "$", "platform", "->", "setIdentifierQuoting", "(", "false", ")", ";", "}", "else", "{", "$", "platform", "->", "setIdentifierQuoting", "(", "true", ")", ";", "}", "$", "platform", "->", "setConnection", "(", "$", "con", ")", ";", "$", "platform", "->", "setGeneratorConfig", "(", "$", "this", ")", ";", "return", "$", "platform", ";", "}" ]
Creates and configures a new Platform class. @param PDO $con @return Platform @throws BuildException
[ "Creates", "and", "configures", "a", "new", "Platform", "class", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L164-L191
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.getConfiguredSchemaParser
public function getConfiguredSchemaParser(PDO $con = null) { $clazz = $this->getClassname("reverseParserClass"); $parser = new $clazz(); if (!$parser instanceof SchemaParser) { throw new BuildException("Specified platform class ($clazz) does implement SchemaParser interface.", $this->getLocation()); } $parser->setConnection($con); $parser->setMigrationTable($this->getBuildProperty('migrationTable')); $parser->setGeneratorConfig($this); return $parser; }
php
public function getConfiguredSchemaParser(PDO $con = null) { $clazz = $this->getClassname("reverseParserClass"); $parser = new $clazz(); if (!$parser instanceof SchemaParser) { throw new BuildException("Specified platform class ($clazz) does implement SchemaParser interface.", $this->getLocation()); } $parser->setConnection($con); $parser->setMigrationTable($this->getBuildProperty('migrationTable')); $parser->setGeneratorConfig($this); return $parser; }
[ "public", "function", "getConfiguredSchemaParser", "(", "PDO", "$", "con", "=", "null", ")", "{", "$", "clazz", "=", "$", "this", "->", "getClassname", "(", "\"reverseParserClass\"", ")", ";", "$", "parser", "=", "new", "$", "clazz", "(", ")", ";", "if", "(", "!", "$", "parser", "instanceof", "SchemaParser", ")", "{", "throw", "new", "BuildException", "(", "\"Specified platform class ($clazz) does implement SchemaParser interface.\"", ",", "$", "this", "->", "getLocation", "(", ")", ")", ";", "}", "$", "parser", "->", "setConnection", "(", "$", "con", ")", ";", "$", "parser", "->", "setMigrationTable", "(", "$", "this", "->", "getBuildProperty", "(", "'migrationTable'", ")", ")", ";", "$", "parser", "->", "setGeneratorConfig", "(", "$", "this", ")", ";", "return", "$", "parser", ";", "}" ]
Creates and configures a new SchemaParser class for specified platform. @param PDO $con @return SchemaParser @throws BuildException
[ "Creates", "and", "configures", "a", "new", "SchemaParser", "class", "for", "specified", "platform", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L201-L213
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.getConfiguredBuilder
public function getConfiguredBuilder(Table $table, $type, $cache = true) { $classname = $this->getBuilderClassname($type); $builder = new $classname($table); $builder->setGeneratorConfig($this); return $builder; }
php
public function getConfiguredBuilder(Table $table, $type, $cache = true) { $classname = $this->getBuilderClassname($type); $builder = new $classname($table); $builder->setGeneratorConfig($this); return $builder; }
[ "public", "function", "getConfiguredBuilder", "(", "Table", "$", "table", ",", "$", "type", ",", "$", "cache", "=", "true", ")", "{", "$", "classname", "=", "$", "this", "->", "getBuilderClassname", "(", "$", "type", ")", ";", "$", "builder", "=", "new", "$", "classname", "(", "$", "table", ")", ";", "$", "builder", "->", "setGeneratorConfig", "(", "$", "this", ")", ";", "return", "$", "builder", ";", "}" ]
Gets a configured data model builder class for specified table and based on type. @param Table $table @param string $type The type of builder ('ddl', 'sql', etc.) @return DataModelBuilder
[ "Gets", "a", "configured", "data", "model", "builder", "class", "for", "specified", "table", "and", "based", "on", "type", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L223-L230
propelorm/Propel
generator/lib/config/GeneratorConfig.php
GeneratorConfig.getConfiguredBehavior
public function getConfiguredBehavior($name) { $propname = 'behavior' . ucfirst(strtolower($name)) . 'Class'; try { $ret = $this->getClassname($propname); } catch (BuildException $e) { // class path not configured $ret = false; } return $ret; }
php
public function getConfiguredBehavior($name) { $propname = 'behavior' . ucfirst(strtolower($name)) . 'Class'; try { $ret = $this->getClassname($propname); } catch (BuildException $e) { // class path not configured $ret = false; } return $ret; }
[ "public", "function", "getConfiguredBehavior", "(", "$", "name", ")", "{", "$", "propname", "=", "'behavior'", ".", "ucfirst", "(", "strtolower", "(", "$", "name", ")", ")", ".", "'Class'", ";", "try", "{", "$", "ret", "=", "$", "this", "->", "getClassname", "(", "$", "propname", ")", ";", "}", "catch", "(", "BuildException", "$", "e", ")", "{", "// class path not configured", "$", "ret", "=", "false", ";", "}", "return", "$", "ret", ";", "}" ]
Gets a configured behavior class @param string $name a behavior name @return string a behavior class name
[ "Gets", "a", "configured", "behavior", "class" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/config/GeneratorConfig.php#L252-L263
propelorm/Propel
generator/lib/reverse/mssql/MssqlSchemaParser.php
MssqlSchemaParser.addIndexes
protected function addIndexes(Table $table) { $stmt = $this->dbh->query("sp_indexes_rowset '" . $table->getName() . "'"); $indexes = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $colName = $this->cleanDelimitedIdentifiers($row["COLUMN_NAME"]); $name = $this->cleanDelimitedIdentifiers($row['INDEX_NAME']); // FIXME -- Add UNIQUE support if (!isset($indexes[$name])) { $indexes[$name] = new Index($name); $table->addIndex($indexes[$name]); } $indexes[$name]->addColumn($table->getColumn($colName)); } }
php
protected function addIndexes(Table $table) { $stmt = $this->dbh->query("sp_indexes_rowset '" . $table->getName() . "'"); $indexes = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $colName = $this->cleanDelimitedIdentifiers($row["COLUMN_NAME"]); $name = $this->cleanDelimitedIdentifiers($row['INDEX_NAME']); // FIXME -- Add UNIQUE support if (!isset($indexes[$name])) { $indexes[$name] = new Index($name); $table->addIndex($indexes[$name]); } $indexes[$name]->addColumn($table->getColumn($colName)); } }
[ "protected", "function", "addIndexes", "(", "Table", "$", "table", ")", "{", "$", "stmt", "=", "$", "this", "->", "dbh", "->", "query", "(", "\"sp_indexes_rowset '\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"'\"", ")", ";", "$", "indexes", "=", "array", "(", ")", ";", "while", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "$", "colName", "=", "$", "this", "->", "cleanDelimitedIdentifiers", "(", "$", "row", "[", "\"COLUMN_NAME\"", "]", ")", ";", "$", "name", "=", "$", "this", "->", "cleanDelimitedIdentifiers", "(", "$", "row", "[", "'INDEX_NAME'", "]", ")", ";", "// FIXME -- Add UNIQUE support", "if", "(", "!", "isset", "(", "$", "indexes", "[", "$", "name", "]", ")", ")", "{", "$", "indexes", "[", "$", "name", "]", "=", "new", "Index", "(", "$", "name", ")", ";", "$", "table", "->", "addIndex", "(", "$", "indexes", "[", "$", "name", "]", ")", ";", "}", "$", "indexes", "[", "$", "name", "]", "->", "addColumn", "(", "$", "table", "->", "getColumn", "(", "$", "colName", ")", ")", ";", "}", "}" ]
Load indexes for this table
[ "Load", "indexes", "for", "this", "table" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/reverse/mssql/MssqlSchemaParser.php#L198-L215
propelorm/Propel
generator/lib/behavior/sluggable/SluggableBehavior.php
SluggableBehavior.modifyTable
public function modifyTable() { if (!$this->getTable()->containsColumn($this->getParameter('slug_column'))) { $this->getTable()->addColumn(array( 'name' => $this->getParameter('slug_column'), 'type' => 'VARCHAR', 'size' => 255 )); // add a unique to column $unique = new Unique($this->getColumnForParameter('slug_column')); $unique->setName($this->getTable()->getCommonName() . '_slug'); $unique->addColumn($this->getTable()->getColumn($this->getParameter('slug_column'))); if ($this->getParameter('scope_column')) { $unique->addColumn($this->getTable()->getColumn($this->getParameter('scope_column'))); } $this->getTable()->addUnique($unique); } }
php
public function modifyTable() { if (!$this->getTable()->containsColumn($this->getParameter('slug_column'))) { $this->getTable()->addColumn(array( 'name' => $this->getParameter('slug_column'), 'type' => 'VARCHAR', 'size' => 255 )); // add a unique to column $unique = new Unique($this->getColumnForParameter('slug_column')); $unique->setName($this->getTable()->getCommonName() . '_slug'); $unique->addColumn($this->getTable()->getColumn($this->getParameter('slug_column'))); if ($this->getParameter('scope_column')) { $unique->addColumn($this->getTable()->getColumn($this->getParameter('scope_column'))); } $this->getTable()->addUnique($unique); } }
[ "public", "function", "modifyTable", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getTable", "(", ")", "->", "containsColumn", "(", "$", "this", "->", "getParameter", "(", "'slug_column'", ")", ")", ")", "{", "$", "this", "->", "getTable", "(", ")", "->", "addColumn", "(", "array", "(", "'name'", "=>", "$", "this", "->", "getParameter", "(", "'slug_column'", ")", ",", "'type'", "=>", "'VARCHAR'", ",", "'size'", "=>", "255", ")", ")", ";", "// add a unique to column", "$", "unique", "=", "new", "Unique", "(", "$", "this", "->", "getColumnForParameter", "(", "'slug_column'", ")", ")", ";", "$", "unique", "->", "setName", "(", "$", "this", "->", "getTable", "(", ")", "->", "getCommonName", "(", ")", ".", "'_slug'", ")", ";", "$", "unique", "->", "addColumn", "(", "$", "this", "->", "getTable", "(", ")", "->", "getColumn", "(", "$", "this", "->", "getParameter", "(", "'slug_column'", ")", ")", ")", ";", "if", "(", "$", "this", "->", "getParameter", "(", "'scope_column'", ")", ")", "{", "$", "unique", "->", "addColumn", "(", "$", "this", "->", "getTable", "(", ")", "->", "getColumn", "(", "$", "this", "->", "getParameter", "(", "'scope_column'", ")", ")", ")", ";", "}", "$", "this", "->", "getTable", "(", ")", "->", "addUnique", "(", "$", "unique", ")", ";", "}", "}" ]
Add the slug_column to the current table
[ "Add", "the", "slug_column", "to", "the", "current", "table" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/behavior/sluggable/SluggableBehavior.php#L36-L53
propelorm/Propel
runtime/lib/validator/NotMatchValidator.php
NotMatchValidator.prepareRegexp
private function prepareRegexp($exp) { // remove surrounding '/' marks so that they don't get escaped in next step if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') { $exp = '/' . $exp . '/'; } // if they did not escape / chars; we do that for them $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); return $exp; }
php
private function prepareRegexp($exp) { // remove surrounding '/' marks so that they don't get escaped in next step if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') { $exp = '/' . $exp . '/'; } // if they did not escape / chars; we do that for them $exp = preg_replace('/([^\\\])\/([^$])/', '$1\/$2', $exp); return $exp; }
[ "private", "function", "prepareRegexp", "(", "$", "exp", ")", "{", "// remove surrounding '/' marks so that they don't get escaped in next step", "if", "(", "$", "exp", "{", "0", "}", "!==", "'/'", "||", "$", "exp", "{", "strlen", "(", "$", "exp", ")", "-", "1", "}", "!==", "'/'", ")", "{", "$", "exp", "=", "'/'", ".", "$", "exp", ".", "'/'", ";", "}", "// if they did not escape / chars; we do that for them", "$", "exp", "=", "preg_replace", "(", "'/([^\\\\\\])\\/([^$])/'", ",", "'$1\\/$2'", ",", "$", "exp", ")", ";", "return", "$", "exp", ";", "}" ]
Prepares the regular expression entered in the XML for use with preg_match(). @param string $exp @return string
[ "Prepares", "the", "regular", "expression", "entered", "in", "the", "XML", "for", "use", "with", "preg_match", "()", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/validator/NotMatchValidator.php#L48-L59
propelorm/Propel
runtime/lib/validator/NotMatchValidator.php
NotMatchValidator.isValid
public function isValid(ValidatorMap $map, $str) { return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0); }
php
public function isValid(ValidatorMap $map, $str) { return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0); }
[ "public", "function", "isValid", "(", "ValidatorMap", "$", "map", ",", "$", "str", ")", "{", "return", "(", "preg_match", "(", "$", "this", "->", "prepareRegexp", "(", "$", "map", "->", "getValue", "(", ")", ")", ",", "$", "str", ")", "==", "0", ")", ";", "}" ]
@see BasicValidator::isValid() @param ValidatorMap $map @param string $str @return boolean
[ "@see", "BasicValidator", "::", "isValid", "()" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/validator/NotMatchValidator.php#L69-L72
propelorm/Propel
runtime/lib/collection/PropelOnDemandIterator.php
PropelOnDemandIterator.next
public function next() { $this->currentRow = $this->stmt->fetch(PDO::FETCH_NUM); $this->currentKey++; $this->isValid = (boolean) $this->currentRow; if (!$this->isValid) { $this->closeCursor(); if ($this->enableInstancePoolingOnFinish) { Propel::enableInstancePooling(); } } }
php
public function next() { $this->currentRow = $this->stmt->fetch(PDO::FETCH_NUM); $this->currentKey++; $this->isValid = (boolean) $this->currentRow; if (!$this->isValid) { $this->closeCursor(); if ($this->enableInstancePoolingOnFinish) { Propel::enableInstancePooling(); } } }
[ "public", "function", "next", "(", ")", "{", "$", "this", "->", "currentRow", "=", "$", "this", "->", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_NUM", ")", ";", "$", "this", "->", "currentKey", "++", ";", "$", "this", "->", "isValid", "=", "(", "boolean", ")", "$", "this", "->", "currentRow", ";", "if", "(", "!", "$", "this", "->", "isValid", ")", "{", "$", "this", "->", "closeCursor", "(", ")", ";", "if", "(", "$", "this", "->", "enableInstancePoolingOnFinish", ")", "{", "Propel", "::", "enableInstancePooling", "(", ")", ";", "}", "}", "}" ]
Advances the cursor in the statement Closes the cursor if the end of the statement is reached
[ "Advances", "the", "cursor", "in", "the", "statement", "Closes", "the", "cursor", "if", "the", "end", "of", "the", "statement", "is", "reached" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelOnDemandIterator.php#L97-L108
propelorm/Propel
runtime/lib/collection/PropelOnDemandIterator.php
PropelOnDemandIterator.rewind
public function rewind() { // check that the hydration can begin if (null === $this->formatter) { throw new PropelException('The On Demand collection requires a formatter. Add it by calling setFormatter()'); } if (null === $this->stmt) { throw new PropelException('The On Demand collection requires a statement. Add it by calling setStatement()'); } if (null !== $this->isValid) { throw new PropelException('The On Demand collection can only be iterated once'); } // initialize the current row and key $this->next(); }
php
public function rewind() { // check that the hydration can begin if (null === $this->formatter) { throw new PropelException('The On Demand collection requires a formatter. Add it by calling setFormatter()'); } if (null === $this->stmt) { throw new PropelException('The On Demand collection requires a statement. Add it by calling setStatement()'); } if (null !== $this->isValid) { throw new PropelException('The On Demand collection can only be iterated once'); } // initialize the current row and key $this->next(); }
[ "public", "function", "rewind", "(", ")", "{", "// check that the hydration can begin", "if", "(", "null", "===", "$", "this", "->", "formatter", ")", "{", "throw", "new", "PropelException", "(", "'The On Demand collection requires a formatter. Add it by calling setFormatter()'", ")", ";", "}", "if", "(", "null", "===", "$", "this", "->", "stmt", ")", "{", "throw", "new", "PropelException", "(", "'The On Demand collection requires a statement. Add it by calling setStatement()'", ")", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "isValid", ")", "{", "throw", "new", "PropelException", "(", "'The On Demand collection can only be iterated once'", ")", ";", "}", "// initialize the current row and key", "$", "this", "->", "next", "(", ")", ";", "}" ]
Initializes the iterator by advancing to the first position This method can only be called once (this is a NoRewindIterator)
[ "Initializes", "the", "iterator", "by", "advancing", "to", "the", "first", "position", "This", "method", "can", "only", "be", "called", "once", "(", "this", "is", "a", "NoRewindIterator", ")" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/runtime/lib/collection/PropelOnDemandIterator.php#L114-L129
propelorm/Propel
generator/lib/builder/util/StandardEnglishPluralizer.php
StandardEnglishPluralizer.getPluralForm
public function getPluralForm($root) { // save some time in the case that singular and plural are the same if (in_array(strtolower($root), $this->_uncountable)) { return $root; } // check for irregular singular words foreach ($this->_irregular as $pattern => $result) { $searchPattern = '/' . $pattern . '$/i'; if (preg_match($searchPattern, $root)) { $replacement = preg_replace($searchPattern, $result, $root); // look at the first char and see if it's upper case // I know it won't handle more than one upper case char here (but I'm OK with that) if (preg_match('/^[A-Z]/', $root)) { $replacement = ucfirst($replacement); } return $replacement; } } // check for irregular singular suffixes foreach ($this->_plural as $pattern => $result) { $searchPattern = '/' . $pattern . '$/i'; if (preg_match($searchPattern, $root)) { return preg_replace($searchPattern, $result, $root); } } // fallback to naive pluralization return $root . 's'; }
php
public function getPluralForm($root) { // save some time in the case that singular and plural are the same if (in_array(strtolower($root), $this->_uncountable)) { return $root; } // check for irregular singular words foreach ($this->_irregular as $pattern => $result) { $searchPattern = '/' . $pattern . '$/i'; if (preg_match($searchPattern, $root)) { $replacement = preg_replace($searchPattern, $result, $root); // look at the first char and see if it's upper case // I know it won't handle more than one upper case char here (but I'm OK with that) if (preg_match('/^[A-Z]/', $root)) { $replacement = ucfirst($replacement); } return $replacement; } } // check for irregular singular suffixes foreach ($this->_plural as $pattern => $result) { $searchPattern = '/' . $pattern . '$/i'; if (preg_match($searchPattern, $root)) { return preg_replace($searchPattern, $result, $root); } } // fallback to naive pluralization return $root . 's'; }
[ "public", "function", "getPluralForm", "(", "$", "root", ")", "{", "// save some time in the case that singular and plural are the same", "if", "(", "in_array", "(", "strtolower", "(", "$", "root", ")", ",", "$", "this", "->", "_uncountable", ")", ")", "{", "return", "$", "root", ";", "}", "// check for irregular singular words", "foreach", "(", "$", "this", "->", "_irregular", "as", "$", "pattern", "=>", "$", "result", ")", "{", "$", "searchPattern", "=", "'/'", ".", "$", "pattern", ".", "'$/i'", ";", "if", "(", "preg_match", "(", "$", "searchPattern", ",", "$", "root", ")", ")", "{", "$", "replacement", "=", "preg_replace", "(", "$", "searchPattern", ",", "$", "result", ",", "$", "root", ")", ";", "// look at the first char and see if it's upper case", "// I know it won't handle more than one upper case char here (but I'm OK with that)", "if", "(", "preg_match", "(", "'/^[A-Z]/'", ",", "$", "root", ")", ")", "{", "$", "replacement", "=", "ucfirst", "(", "$", "replacement", ")", ";", "}", "return", "$", "replacement", ";", "}", "}", "// check for irregular singular suffixes", "foreach", "(", "$", "this", "->", "_plural", "as", "$", "pattern", "=>", "$", "result", ")", "{", "$", "searchPattern", "=", "'/'", ".", "$", "pattern", ".", "'$/i'", ";", "if", "(", "preg_match", "(", "$", "searchPattern", ",", "$", "root", ")", ")", "{", "return", "preg_replace", "(", "$", "searchPattern", ",", "$", "result", ",", "$", "root", ")", ";", "}", "}", "// fallback to naive pluralization", "return", "$", "root", ".", "'s'", ";", "}" ]
Generate a plural name based on the passed in root. @param string $root The root that needs to be pluralized (e.g. Author) @return string The plural form of $root (e.g. Authors).
[ "Generate", "a", "plural", "name", "based", "on", "the", "passed", "in", "root", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/util/StandardEnglishPluralizer.php#L119-L151
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.validateModel
protected function validateModel() { parent::validateModel(); $table = $this->getTable(); // Check to see whether any generated foreign key names // will conflict with column names. $colPhpNames = array(); $fkPhpNames = array(); foreach ($table->getColumns() as $col) { $colPhpNames[] = $col->getPhpName(); } foreach ($table->getForeignKeys() as $fk) { $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false); } $intersect = array_intersect($colPhpNames, $fkPhpNames); if (!empty($intersect)) { throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")"); } // Check foreign keys to see if there are any foreign keys that // are also matched with an inversed referencing foreign key // (this is currently unsupported behavior) // see: http://trac.propelorm.org/ticket/549 foreach ($table->getForeignKeys() as $fk) { if ($fk->isMatchedByInverseFK()) { throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)"); } } }
php
protected function validateModel() { parent::validateModel(); $table = $this->getTable(); // Check to see whether any generated foreign key names // will conflict with column names. $colPhpNames = array(); $fkPhpNames = array(); foreach ($table->getColumns() as $col) { $colPhpNames[] = $col->getPhpName(); } foreach ($table->getForeignKeys() as $fk) { $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false); } $intersect = array_intersect($colPhpNames, $fkPhpNames); if (!empty($intersect)) { throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")"); } // Check foreign keys to see if there are any foreign keys that // are also matched with an inversed referencing foreign key // (this is currently unsupported behavior) // see: http://trac.propelorm.org/ticket/549 foreach ($table->getForeignKeys() as $fk) { if ($fk->isMatchedByInverseFK()) { throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)"); } } }
[ "protected", "function", "validateModel", "(", ")", "{", "parent", "::", "validateModel", "(", ")", ";", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "// Check to see whether any generated foreign key names", "// will conflict with column names.", "$", "colPhpNames", "=", "array", "(", ")", ";", "$", "fkPhpNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "table", "->", "getColumns", "(", ")", "as", "$", "col", ")", "{", "$", "colPhpNames", "[", "]", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "}", "foreach", "(", "$", "table", "->", "getForeignKeys", "(", ")", "as", "$", "fk", ")", "{", "$", "fkPhpNames", "[", "]", "=", "$", "this", "->", "getFKPhpNameAffix", "(", "$", "fk", ",", "$", "plural", "=", "false", ")", ";", "}", "$", "intersect", "=", "array_intersect", "(", "$", "colPhpNames", ",", "$", "fkPhpNames", ")", ";", "if", "(", "!", "empty", "(", "$", "intersect", ")", ")", "{", "throw", "new", "EngineException", "(", "\"One or more of your column names for [\"", ".", "$", "table", "->", "getName", "(", ")", ".", "\"] table conflict with foreign key names (\"", ".", "implode", "(", "\", \"", ",", "$", "intersect", ")", ".", "\")\"", ")", ";", "}", "// Check foreign keys to see if there are any foreign keys that", "// are also matched with an inversed referencing foreign key", "// (this is currently unsupported behavior)", "// see: http://trac.propelorm.org/ticket/549", "foreach", "(", "$", "table", "->", "getForeignKeys", "(", ")", "as", "$", "fk", ")", "{", "if", "(", "$", "fk", "->", "isMatchedByInverseFK", "(", ")", ")", "{", "throw", "new", "EngineException", "(", "\"The 1:1 relationship expressed by foreign key \"", ".", "$", "fk", "->", "getName", "(", ")", ".", "\" is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)\"", ")", ";", "}", "}", "}" ]
Validates the current table to make sure that it won't result in generated code that will not parse. This method may emit warnings for code which may cause problems and will throw exceptions for errors that will definitely cause problems.
[ "Validates", "the", "current", "table", "to", "make", "sure", "that", "it", "won", "t", "result", "in", "generated", "code", "that", "will", "not", "parse", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L76-L111
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.getTemporalFormatter
protected function getTemporalFormatter(Column $col) { $fmt = null; if ($col->getType() === PropelTypes::DATE) { $fmt = $this->getPlatform()->getDateFormatter(); } elseif ($col->getType() === PropelTypes::TIME) { $fmt = $this->getPlatform()->getTimeFormatter(); } elseif ($col->getType() === PropelTypes::TIMESTAMP) { $fmt = $this->getPlatform()->getTimestampFormatter(); } return $fmt; }
php
protected function getTemporalFormatter(Column $col) { $fmt = null; if ($col->getType() === PropelTypes::DATE) { $fmt = $this->getPlatform()->getDateFormatter(); } elseif ($col->getType() === PropelTypes::TIME) { $fmt = $this->getPlatform()->getTimeFormatter(); } elseif ($col->getType() === PropelTypes::TIMESTAMP) { $fmt = $this->getPlatform()->getTimestampFormatter(); } return $fmt; }
[ "protected", "function", "getTemporalFormatter", "(", "Column", "$", "col", ")", "{", "$", "fmt", "=", "null", ";", "if", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "DATE", ")", "{", "$", "fmt", "=", "$", "this", "->", "getPlatform", "(", ")", "->", "getDateFormatter", "(", ")", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIME", ")", "{", "$", "fmt", "=", "$", "this", "->", "getPlatform", "(", ")", "->", "getTimeFormatter", "(", ")", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIMESTAMP", ")", "{", "$", "fmt", "=", "$", "this", "->", "getPlatform", "(", ")", "->", "getTimestampFormatter", "(", ")", ";", "}", "return", "$", "fmt", ";", "}" ]
Returns the appropriate formatter (from platform) for a date/time column. @param Column $col @return string
[ "Returns", "the", "appropriate", "formatter", "(", "from", "platform", ")", "for", "a", "date", "/", "time", "column", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L120-L132
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.getDefaultValueString
protected function getDefaultValueString(Column $col) { $defaultValue = var_export(null, true); $val = $col->getPhpDefaultValue(); if ($val === null) { return $defaultValue; } if ($col->isTemporalType()) { $fmt = $this->getTemporalFormatter($col); try { if (!($this->getPlatform() instanceof MysqlPlatform && ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) { // while technically this is not a default value of null, // this seems to be closest in meaning. $defDt = new DateTime($val); $defaultValue = var_export($defDt->format($fmt), true); } } catch (Exception $x) { // prevent endless loop when timezone is undefined date_default_timezone_set('America/Los_Angeles'); throw new EngineException(sprintf('Unable to parse default temporal value "%s" for column "%s"', $col->getDefaultValueString(), $col->getFullyQualifiedName()), $x); } } elseif ($col->isEnumType()) { $valueSet = $col->getValueSet(); if (!in_array($val, $valueSet)) { throw new EngineException(sprintf('Default Value "%s" is not among the enumerated values', $val)); } $defaultValue = array_search($val, $valueSet); } elseif ($col->isPhpPrimitiveType()) { settype($val, $col->getPhpType()); $defaultValue = var_export($val, true); } elseif ($col->isPhpObjectType()) { $defaultValue = 'new ' . $col->getPhpType() . '(' . var_export($val, true) . ')'; } elseif ($col->isPhpArrayType()) { $defaultValue = var_export($val, true); } else { throw new EngineException("Cannot get default value string for " . $col->getFullyQualifiedName()); } return $defaultValue; }
php
protected function getDefaultValueString(Column $col) { $defaultValue = var_export(null, true); $val = $col->getPhpDefaultValue(); if ($val === null) { return $defaultValue; } if ($col->isTemporalType()) { $fmt = $this->getTemporalFormatter($col); try { if (!($this->getPlatform() instanceof MysqlPlatform && ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) { // while technically this is not a default value of null, // this seems to be closest in meaning. $defDt = new DateTime($val); $defaultValue = var_export($defDt->format($fmt), true); } } catch (Exception $x) { // prevent endless loop when timezone is undefined date_default_timezone_set('America/Los_Angeles'); throw new EngineException(sprintf('Unable to parse default temporal value "%s" for column "%s"', $col->getDefaultValueString(), $col->getFullyQualifiedName()), $x); } } elseif ($col->isEnumType()) { $valueSet = $col->getValueSet(); if (!in_array($val, $valueSet)) { throw new EngineException(sprintf('Default Value "%s" is not among the enumerated values', $val)); } $defaultValue = array_search($val, $valueSet); } elseif ($col->isPhpPrimitiveType()) { settype($val, $col->getPhpType()); $defaultValue = var_export($val, true); } elseif ($col->isPhpObjectType()) { $defaultValue = 'new ' . $col->getPhpType() . '(' . var_export($val, true) . ')'; } elseif ($col->isPhpArrayType()) { $defaultValue = var_export($val, true); } else { throw new EngineException("Cannot get default value string for " . $col->getFullyQualifiedName()); } return $defaultValue; }
[ "protected", "function", "getDefaultValueString", "(", "Column", "$", "col", ")", "{", "$", "defaultValue", "=", "var_export", "(", "null", ",", "true", ")", ";", "$", "val", "=", "$", "col", "->", "getPhpDefaultValue", "(", ")", ";", "if", "(", "$", "val", "===", "null", ")", "{", "return", "$", "defaultValue", ";", "}", "if", "(", "$", "col", "->", "isTemporalType", "(", ")", ")", "{", "$", "fmt", "=", "$", "this", "->", "getTemporalFormatter", "(", "$", "col", ")", ";", "try", "{", "if", "(", "!", "(", "$", "this", "->", "getPlatform", "(", ")", "instanceof", "MysqlPlatform", "&&", "(", "$", "val", "===", "'0000-00-00 00:00:00'", "||", "$", "val", "===", "'0000-00-00'", ")", ")", ")", "{", "// while technically this is not a default value of null,", "// this seems to be closest in meaning.", "$", "defDt", "=", "new", "DateTime", "(", "$", "val", ")", ";", "$", "defaultValue", "=", "var_export", "(", "$", "defDt", "->", "format", "(", "$", "fmt", ")", ",", "true", ")", ";", "}", "}", "catch", "(", "Exception", "$", "x", ")", "{", "// prevent endless loop when timezone is undefined", "date_default_timezone_set", "(", "'America/Los_Angeles'", ")", ";", "throw", "new", "EngineException", "(", "sprintf", "(", "'Unable to parse default temporal value \"%s\" for column \"%s\"'", ",", "$", "col", "->", "getDefaultValueString", "(", ")", ",", "$", "col", "->", "getFullyQualifiedName", "(", ")", ")", ",", "$", "x", ")", ";", "}", "}", "elseif", "(", "$", "col", "->", "isEnumType", "(", ")", ")", "{", "$", "valueSet", "=", "$", "col", "->", "getValueSet", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "val", ",", "$", "valueSet", ")", ")", "{", "throw", "new", "EngineException", "(", "sprintf", "(", "'Default Value \"%s\" is not among the enumerated values'", ",", "$", "val", ")", ")", ";", "}", "$", "defaultValue", "=", "array_search", "(", "$", "val", ",", "$", "valueSet", ")", ";", "}", "elseif", "(", "$", "col", "->", "isPhpPrimitiveType", "(", ")", ")", "{", "settype", "(", "$", "val", ",", "$", "col", "->", "getPhpType", "(", ")", ")", ";", "$", "defaultValue", "=", "var_export", "(", "$", "val", ",", "true", ")", ";", "}", "elseif", "(", "$", "col", "->", "isPhpObjectType", "(", ")", ")", "{", "$", "defaultValue", "=", "'new '", ".", "$", "col", "->", "getPhpType", "(", ")", ".", "'('", ".", "var_export", "(", "$", "val", ",", "true", ")", ".", "')'", ";", "}", "elseif", "(", "$", "col", "->", "isPhpArrayType", "(", ")", ")", "{", "$", "defaultValue", "=", "var_export", "(", "$", "val", ",", "true", ")", ";", "}", "else", "{", "throw", "new", "EngineException", "(", "\"Cannot get default value string for \"", ".", "$", "col", "->", "getFullyQualifiedName", "(", ")", ")", ";", "}", "return", "$", "defaultValue", ";", "}" ]
Returns the type-casted and stringified default value for the specified Column. This only works for scalar default values currently. @return string The default value or 'null' if there is none. @throws EngineException
[ "Returns", "the", "type", "-", "casted", "and", "stringified", "default", "value", "for", "the", "specified", "Column", ".", "This", "only", "works", "for", "scalar", "default", "values", "currently", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L141-L180
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addClassBody
protected function addClassBody(&$script) { $this->declareClassFromBuilder($this->getStubObjectBuilder()); $this->declareClassFromBuilder($this->getStubPeerBuilder()); $this->declareClassFromBuilder($this->getStubQueryBuilder()); $this->declareClasses('Propel', 'PropelException', 'PDO', 'PropelPDO', 'PropelQuery', 'Criteria', 'Persistent', 'BasePeer', 'PropelCollection', 'PropelObjectCollection', 'Exception'); $table = $this->getTable(); if (!$table->isAlias()) { $this->addConstants($script); $this->addAttributes($script); } if ($table->hasCrossForeignKeys()) { foreach ($table->getCrossFks() as $fkList) { /* @var $refFK ForeignKey */ list($refFK, $crossFK) = $fkList; $fkName = $this->getFKPhpNameAffix($crossFK, $plural = true); if (!$refFK->isLocalPrimaryKey()) { $this->addScheduledForDeletionAttribute($script, $fkName); } } } foreach ($table->getReferrers() as $refFK) { $fkName = $this->getRefFKPhpNameAffix($refFK, $plural = true); if (!$refFK->isLocalPrimaryKey()) { $this->addScheduledForDeletionAttribute($script, $fkName); } } if ($this->hasDefaultValues()) { $this->addApplyDefaultValues($script); $this->addConstructor($script); } $this->addColumnAccessorMethods($script); $this->addColumnMutatorMethods($script); $this->addHasOnlyDefaultValues($script); $this->addHydrate($script); $this->addEnsureConsistency($script); if (!$table->isReadOnly()) { $this->addManipulationMethods($script); } if ($this->isAddValidateMethod()) { $this->addValidationMethods($script); } if ($this->isAddGenericAccessors()) { $this->addGetByName($script); $this->addGetByPosition($script); $this->addToArray($script); } if ($this->isAddGenericMutators()) { $this->addSetByName($script); $this->addSetByPosition($script); $this->addFromArray($script); } $this->addBuildCriteria($script); $this->addBuildPkeyCriteria($script); $this->addGetPrimaryKey($script); $this->addSetPrimaryKey($script); $this->addIsPrimaryKeyNull($script); $this->addCopy($script); if (!$table->isAlias()) { $this->addGetPeer($script); } $this->addFKMethods($script); $this->addRefFKMethods($script); $this->addCrossFKMethods($script); $this->addClear($script); $this->addClearAllReferences($script); $this->addPrimaryString($script); $this->addIsAlreadyInSave($script); // apply behaviors $this->applyBehaviorModifier('objectMethods', $script, " "); $this->addMagicCall($script); }
php
protected function addClassBody(&$script) { $this->declareClassFromBuilder($this->getStubObjectBuilder()); $this->declareClassFromBuilder($this->getStubPeerBuilder()); $this->declareClassFromBuilder($this->getStubQueryBuilder()); $this->declareClasses('Propel', 'PropelException', 'PDO', 'PropelPDO', 'PropelQuery', 'Criteria', 'Persistent', 'BasePeer', 'PropelCollection', 'PropelObjectCollection', 'Exception'); $table = $this->getTable(); if (!$table->isAlias()) { $this->addConstants($script); $this->addAttributes($script); } if ($table->hasCrossForeignKeys()) { foreach ($table->getCrossFks() as $fkList) { /* @var $refFK ForeignKey */ list($refFK, $crossFK) = $fkList; $fkName = $this->getFKPhpNameAffix($crossFK, $plural = true); if (!$refFK->isLocalPrimaryKey()) { $this->addScheduledForDeletionAttribute($script, $fkName); } } } foreach ($table->getReferrers() as $refFK) { $fkName = $this->getRefFKPhpNameAffix($refFK, $plural = true); if (!$refFK->isLocalPrimaryKey()) { $this->addScheduledForDeletionAttribute($script, $fkName); } } if ($this->hasDefaultValues()) { $this->addApplyDefaultValues($script); $this->addConstructor($script); } $this->addColumnAccessorMethods($script); $this->addColumnMutatorMethods($script); $this->addHasOnlyDefaultValues($script); $this->addHydrate($script); $this->addEnsureConsistency($script); if (!$table->isReadOnly()) { $this->addManipulationMethods($script); } if ($this->isAddValidateMethod()) { $this->addValidationMethods($script); } if ($this->isAddGenericAccessors()) { $this->addGetByName($script); $this->addGetByPosition($script); $this->addToArray($script); } if ($this->isAddGenericMutators()) { $this->addSetByName($script); $this->addSetByPosition($script); $this->addFromArray($script); } $this->addBuildCriteria($script); $this->addBuildPkeyCriteria($script); $this->addGetPrimaryKey($script); $this->addSetPrimaryKey($script); $this->addIsPrimaryKeyNull($script); $this->addCopy($script); if (!$table->isAlias()) { $this->addGetPeer($script); } $this->addFKMethods($script); $this->addRefFKMethods($script); $this->addCrossFKMethods($script); $this->addClear($script); $this->addClearAllReferences($script); $this->addPrimaryString($script); $this->addIsAlreadyInSave($script); // apply behaviors $this->applyBehaviorModifier('objectMethods', $script, " "); $this->addMagicCall($script); }
[ "protected", "function", "addClassBody", "(", "&", "$", "script", ")", "{", "$", "this", "->", "declareClassFromBuilder", "(", "$", "this", "->", "getStubObjectBuilder", "(", ")", ")", ";", "$", "this", "->", "declareClassFromBuilder", "(", "$", "this", "->", "getStubPeerBuilder", "(", ")", ")", ";", "$", "this", "->", "declareClassFromBuilder", "(", "$", "this", "->", "getStubQueryBuilder", "(", ")", ")", ";", "$", "this", "->", "declareClasses", "(", "'Propel'", ",", "'PropelException'", ",", "'PDO'", ",", "'PropelPDO'", ",", "'PropelQuery'", ",", "'Criteria'", ",", "'Persistent'", ",", "'BasePeer'", ",", "'PropelCollection'", ",", "'PropelObjectCollection'", ",", "'Exception'", ")", ";", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "if", "(", "!", "$", "table", "->", "isAlias", "(", ")", ")", "{", "$", "this", "->", "addConstants", "(", "$", "script", ")", ";", "$", "this", "->", "addAttributes", "(", "$", "script", ")", ";", "}", "if", "(", "$", "table", "->", "hasCrossForeignKeys", "(", ")", ")", "{", "foreach", "(", "$", "table", "->", "getCrossFks", "(", ")", "as", "$", "fkList", ")", "{", "/* @var $refFK ForeignKey */", "list", "(", "$", "refFK", ",", "$", "crossFK", ")", "=", "$", "fkList", ";", "$", "fkName", "=", "$", "this", "->", "getFKPhpNameAffix", "(", "$", "crossFK", ",", "$", "plural", "=", "true", ")", ";", "if", "(", "!", "$", "refFK", "->", "isLocalPrimaryKey", "(", ")", ")", "{", "$", "this", "->", "addScheduledForDeletionAttribute", "(", "$", "script", ",", "$", "fkName", ")", ";", "}", "}", "}", "foreach", "(", "$", "table", "->", "getReferrers", "(", ")", "as", "$", "refFK", ")", "{", "$", "fkName", "=", "$", "this", "->", "getRefFKPhpNameAffix", "(", "$", "refFK", ",", "$", "plural", "=", "true", ")", ";", "if", "(", "!", "$", "refFK", "->", "isLocalPrimaryKey", "(", ")", ")", "{", "$", "this", "->", "addScheduledForDeletionAttribute", "(", "$", "script", ",", "$", "fkName", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasDefaultValues", "(", ")", ")", "{", "$", "this", "->", "addApplyDefaultValues", "(", "$", "script", ")", ";", "$", "this", "->", "addConstructor", "(", "$", "script", ")", ";", "}", "$", "this", "->", "addColumnAccessorMethods", "(", "$", "script", ")", ";", "$", "this", "->", "addColumnMutatorMethods", "(", "$", "script", ")", ";", "$", "this", "->", "addHasOnlyDefaultValues", "(", "$", "script", ")", ";", "$", "this", "->", "addHydrate", "(", "$", "script", ")", ";", "$", "this", "->", "addEnsureConsistency", "(", "$", "script", ")", ";", "if", "(", "!", "$", "table", "->", "isReadOnly", "(", ")", ")", "{", "$", "this", "->", "addManipulationMethods", "(", "$", "script", ")", ";", "}", "if", "(", "$", "this", "->", "isAddValidateMethod", "(", ")", ")", "{", "$", "this", "->", "addValidationMethods", "(", "$", "script", ")", ";", "}", "if", "(", "$", "this", "->", "isAddGenericAccessors", "(", ")", ")", "{", "$", "this", "->", "addGetByName", "(", "$", "script", ")", ";", "$", "this", "->", "addGetByPosition", "(", "$", "script", ")", ";", "$", "this", "->", "addToArray", "(", "$", "script", ")", ";", "}", "if", "(", "$", "this", "->", "isAddGenericMutators", "(", ")", ")", "{", "$", "this", "->", "addSetByName", "(", "$", "script", ")", ";", "$", "this", "->", "addSetByPosition", "(", "$", "script", ")", ";", "$", "this", "->", "addFromArray", "(", "$", "script", ")", ";", "}", "$", "this", "->", "addBuildCriteria", "(", "$", "script", ")", ";", "$", "this", "->", "addBuildPkeyCriteria", "(", "$", "script", ")", ";", "$", "this", "->", "addGetPrimaryKey", "(", "$", "script", ")", ";", "$", "this", "->", "addSetPrimaryKey", "(", "$", "script", ")", ";", "$", "this", "->", "addIsPrimaryKeyNull", "(", "$", "script", ")", ";", "$", "this", "->", "addCopy", "(", "$", "script", ")", ";", "if", "(", "!", "$", "table", "->", "isAlias", "(", ")", ")", "{", "$", "this", "->", "addGetPeer", "(", "$", "script", ")", ";", "}", "$", "this", "->", "addFKMethods", "(", "$", "script", ")", ";", "$", "this", "->", "addRefFKMethods", "(", "$", "script", ")", ";", "$", "this", "->", "addCrossFKMethods", "(", "$", "script", ")", ";", "$", "this", "->", "addClear", "(", "$", "script", ")", ";", "$", "this", "->", "addClearAllReferences", "(", "$", "script", ")", ";", "$", "this", "->", "addPrimaryString", "(", "$", "script", ")", ";", "$", "this", "->", "addIsAlreadyInSave", "(", "$", "script", ")", ";", "// apply behaviors", "$", "this", "->", "applyBehaviorModifier", "(", "'objectMethods'", ",", "$", "script", ",", "\"\t\"", ")", ";", "$", "this", "->", "addMagicCall", "(", "$", "script", ")", ";", "}" ]
Specifies the methods that are added as part of the basic OM class. This can be overridden by subclasses that wish to add more methods. @see ObjectBuilder::addClassBody()
[ "Specifies", "the", "methods", "that", "are", "added", "as", "part", "of", "the", "basic", "OM", "class", ".", "This", "can", "be", "overridden", "by", "subclasses", "that", "wish", "to", "add", "more", "methods", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L258-L350
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addAttributes
protected function addAttributes(&$script) { $table = $this->getTable(); $script .= " /** * The Peer class. * Instance provides a convenient way of calling static methods on a class * that calling code may not be able to identify. * @var " . $this->getPeerClassname() . " */ protected static \$peer; /** * The flag var to prevent infinite loop in deep copy * @var boolean */ protected \$startCopy = false; "; if (!$table->isAlias()) { $this->addColumnAttributes($script); } foreach ($table->getForeignKeys() as $fk) { $this->addFKAttributes($script, $fk); } foreach ($table->getReferrers() as $refFK) { $this->addRefFKAttributes($script, $refFK); } // many-to-many relationships foreach ($table->getCrossFks() as $fkList) { $crossFK = $fkList[1]; $this->addCrossFKAttributes($script, $crossFK); } $this->addAlreadyInSaveAttribute($script); $this->addAlreadyInValidationAttribute($script); $this->addAlreadyInClearAllReferencesDeepAttribute($script); // apply behaviors $this->applyBehaviorModifier('objectAttributes', $script, " "); }
php
protected function addAttributes(&$script) { $table = $this->getTable(); $script .= " /** * The Peer class. * Instance provides a convenient way of calling static methods on a class * that calling code may not be able to identify. * @var " . $this->getPeerClassname() . " */ protected static \$peer; /** * The flag var to prevent infinite loop in deep copy * @var boolean */ protected \$startCopy = false; "; if (!$table->isAlias()) { $this->addColumnAttributes($script); } foreach ($table->getForeignKeys() as $fk) { $this->addFKAttributes($script, $fk); } foreach ($table->getReferrers() as $refFK) { $this->addRefFKAttributes($script, $refFK); } // many-to-many relationships foreach ($table->getCrossFks() as $fkList) { $crossFK = $fkList[1]; $this->addCrossFKAttributes($script, $crossFK); } $this->addAlreadyInSaveAttribute($script); $this->addAlreadyInValidationAttribute($script); $this->addAlreadyInClearAllReferencesDeepAttribute($script); // apply behaviors $this->applyBehaviorModifier('objectAttributes', $script, " "); }
[ "protected", "function", "addAttributes", "(", "&", "$", "script", ")", "{", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "$", "script", ".=", "\"\n /**\n * The Peer class.\n * Instance provides a convenient way of calling static methods on a class\n * that calling code may not be able to identify.\n * @var \"", ".", "$", "this", "->", "getPeerClassname", "(", ")", ".", "\"\n */\n protected static \\$peer;\n\n /**\n * The flag var to prevent infinite loop in deep copy\n * @var boolean\n */\n protected \\$startCopy = false;\n\"", ";", "if", "(", "!", "$", "table", "->", "isAlias", "(", ")", ")", "{", "$", "this", "->", "addColumnAttributes", "(", "$", "script", ")", ";", "}", "foreach", "(", "$", "table", "->", "getForeignKeys", "(", ")", "as", "$", "fk", ")", "{", "$", "this", "->", "addFKAttributes", "(", "$", "script", ",", "$", "fk", ")", ";", "}", "foreach", "(", "$", "table", "->", "getReferrers", "(", ")", "as", "$", "refFK", ")", "{", "$", "this", "->", "addRefFKAttributes", "(", "$", "script", ",", "$", "refFK", ")", ";", "}", "// many-to-many relationships", "foreach", "(", "$", "table", "->", "getCrossFks", "(", ")", "as", "$", "fkList", ")", "{", "$", "crossFK", "=", "$", "fkList", "[", "1", "]", ";", "$", "this", "->", "addCrossFKAttributes", "(", "$", "script", ",", "$", "crossFK", ")", ";", "}", "$", "this", "->", "addAlreadyInSaveAttribute", "(", "$", "script", ")", ";", "$", "this", "->", "addAlreadyInValidationAttribute", "(", "$", "script", ")", ";", "$", "this", "->", "addAlreadyInClearAllReferencesDeepAttribute", "(", "$", "script", ")", ";", "// apply behaviors", "$", "this", "->", "applyBehaviorModifier", "(", "'objectAttributes'", ",", "$", "script", ",", "\"\t\"", ")", ";", "}" ]
Adds class attributes. @param string &$script The script will be modified in this method.
[ "Adds", "class", "attributes", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L385-L428
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addColumnAttributes
protected function addColumnAttributes(&$script) { $table = $this->getTable(); foreach ($table->getColumns() as $col) { $this->addColumnAttributeComment($script, $col); $this->addColumnAttributeDeclaration($script, $col); if ($col->isLazyLoad()) { $this->addColumnAttributeLoaderComment($script, $col); $this->addColumnAttributeLoaderDeclaration($script, $col); } if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) { $this->addColumnAttributeUnserializedComment($script, $col); $this->addColumnAttributeUnserializedDeclaration($script, $col); } } }
php
protected function addColumnAttributes(&$script) { $table = $this->getTable(); foreach ($table->getColumns() as $col) { $this->addColumnAttributeComment($script, $col); $this->addColumnAttributeDeclaration($script, $col); if ($col->isLazyLoad()) { $this->addColumnAttributeLoaderComment($script, $col); $this->addColumnAttributeLoaderDeclaration($script, $col); } if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) { $this->addColumnAttributeUnserializedComment($script, $col); $this->addColumnAttributeUnserializedDeclaration($script, $col); } } }
[ "protected", "function", "addColumnAttributes", "(", "&", "$", "script", ")", "{", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "foreach", "(", "$", "table", "->", "getColumns", "(", ")", "as", "$", "col", ")", "{", "$", "this", "->", "addColumnAttributeComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addColumnAttributeDeclaration", "(", "$", "script", ",", "$", "col", ")", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "this", "->", "addColumnAttributeLoaderComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addColumnAttributeLoaderDeclaration", "(", "$", "script", ",", "$", "col", ")", ";", "}", "if", "(", "$", "col", "->", "getType", "(", ")", "==", "PropelTypes", "::", "OBJECT", "||", "$", "col", "->", "getType", "(", ")", "==", "PropelTypes", "::", "PHP_ARRAY", ")", "{", "$", "this", "->", "addColumnAttributeUnserializedComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addColumnAttributeUnserializedDeclaration", "(", "$", "script", ",", "$", "col", ")", ";", "}", "}", "}" ]
Adds variables that store column values. @param string &$script The script will be modified in this method. @see addColumnNameConstants()
[ "Adds", "variables", "that", "store", "column", "values", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L437-L454
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addColumnAttributeComment
protected function addColumnAttributeComment(&$script, Column $col) { $cptype = $col->getPhpType(); $clo = strtolower($col->getName()); $script .= " /** * The value for the $clo field."; if ($col->getDefaultValue()) { if ($col->getDefaultValue()->isExpression()) { $script .= " * Note: this column has a database default value of: (expression) " . $col->getDefaultValue()->getValue(); } else { $script .= " * Note: this column has a database default value of: " . $this->getDefaultValueString($col); } } $script .= " * @var $cptype */"; }
php
protected function addColumnAttributeComment(&$script, Column $col) { $cptype = $col->getPhpType(); $clo = strtolower($col->getName()); $script .= " /** * The value for the $clo field."; if ($col->getDefaultValue()) { if ($col->getDefaultValue()->isExpression()) { $script .= " * Note: this column has a database default value of: (expression) " . $col->getDefaultValue()->getValue(); } else { $script .= " * Note: this column has a database default value of: " . $this->getDefaultValueString($col); } } $script .= " * @var $cptype */"; }
[ "protected", "function", "addColumnAttributeComment", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cptype", "=", "$", "col", "->", "getPhpType", "(", ")", ";", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "script", ".=", "\"\n /**\n * The value for the $clo field.\"", ";", "if", "(", "$", "col", "->", "getDefaultValue", "(", ")", ")", "{", "if", "(", "$", "col", "->", "getDefaultValue", "(", ")", "->", "isExpression", "(", ")", ")", "{", "$", "script", ".=", "\"\n * Note: this column has a database default value of: (expression) \"", ".", "$", "col", "->", "getDefaultValue", "(", ")", "->", "getValue", "(", ")", ";", "}", "else", "{", "$", "script", ".=", "\"\n * Note: this column has a database default value of: \"", ".", "$", "this", "->", "getDefaultValueString", "(", "$", "col", ")", ";", "}", "}", "$", "script", ".=", "\"\n * @var $cptype\n */\"", ";", "}" ]
Add comment about the attribute (variable) that stores column values @param string &$script The script will be modified in this method. @param Column $col
[ "Add", "comment", "about", "the", "attribute", "(", "variable", ")", "that", "stores", "column", "values" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L462-L482
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addColumnAttributeDeclaration
protected function addColumnAttributeDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " protected \$" . $clo . "; "; }
php
protected function addColumnAttributeDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " protected \$" . $clo . "; "; }
[ "protected", "function", "addColumnAttributeDeclaration", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "script", ".=", "\"\n protected \\$\"", ".", "$", "clo", ".", "\";\n\"", ";", "}" ]
Adds the declaration of a column value storage attribute @param string &$script The script will be modified in this method. @param Column $col
[ "Adds", "the", "declaration", "of", "a", "column", "value", "storage", "attribute" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L490-L496
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addColumnAttributeLoaderDeclaration
protected function addColumnAttributeLoaderDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " protected \$" . $clo . "_isLoaded = false; "; }
php
protected function addColumnAttributeLoaderDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " protected \$" . $clo . "_isLoaded = false; "; }
[ "protected", "function", "addColumnAttributeLoaderDeclaration", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "script", ".=", "\"\n protected \\$\"", ".", "$", "clo", ".", "\"_isLoaded = false;\n\"", ";", "}" ]
Adds the declaration of the attribute keeping track of an attribute's loaded state @param string &$script The script will be modified in this method. @param Column $col
[ "Adds", "the", "declaration", "of", "the", "attribute", "keeping", "track", "of", "an", "attribute", "s", "loaded", "state" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L521-L527
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addColumnAttributeUnserializedDeclaration
protected function addColumnAttributeUnserializedDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()) . "_unserialized"; $script .= " protected \$" . $clo . "; "; }
php
protected function addColumnAttributeUnserializedDeclaration(&$script, Column $col) { $clo = strtolower($col->getName()) . "_unserialized"; $script .= " protected \$" . $clo . "; "; }
[ "protected", "function", "addColumnAttributeUnserializedDeclaration", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ".", "\"_unserialized\"", ";", "$", "script", ".=", "\"\n protected \\$\"", ".", "$", "clo", ".", "\";\n\"", ";", "}" ]
Adds the declaration of the serialized attribute @param string &$script The script will be modified in this method. @param Column $col
[ "Adds", "the", "declaration", "of", "the", "serialized", "attribute" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L552-L558
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addGetPeer
protected function addGetPeer(&$script) { $this->addGetPeerComment($script); $this->addGetPeerFunctionOpen($script); $this->addGetPeerFunctionBody($script); $this->addGetPeerFunctionClose($script); }
php
protected function addGetPeer(&$script) { $this->addGetPeerComment($script); $this->addGetPeerFunctionOpen($script); $this->addGetPeerFunctionBody($script); $this->addGetPeerFunctionClose($script); }
[ "protected", "function", "addGetPeer", "(", "&", "$", "script", ")", "{", "$", "this", "->", "addGetPeerComment", "(", "$", "script", ")", ";", "$", "this", "->", "addGetPeerFunctionOpen", "(", "$", "script", ")", ";", "$", "this", "->", "addGetPeerFunctionBody", "(", "$", "script", ")", ";", "$", "this", "->", "addGetPeerFunctionClose", "(", "$", "script", ")", ";", "}" ]
Adds the getPeer() method. This is a convenient, non introspective way of getting the Peer class for a particular object. @param string &$script The script will be modified in this method.
[ "Adds", "the", "getPeer", "()", "method", ".", "This", "is", "a", "convenient", "non", "introspective", "way", "of", "getting", "the", "Peer", "class", "for", "a", "particular", "object", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L566-L572
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addApplyDefaultValuesBody
protected function addApplyDefaultValuesBody(&$script) { $table = $this->getTable(); // FIXME - Apply support for PHP default expressions here // see: http://trac.propelorm.org/ticket/378 $colsWithDefaults = array(); foreach ($table->getColumns() as $col) { $def = $col->getDefaultValue(); if ($def !== null && !$def->isExpression()) { $colsWithDefaults[] = $col; } } $colconsts = array(); foreach ($colsWithDefaults as $col) { $clo = strtolower($col->getName()); $defaultValue = $this->getDefaultValueString($col); $script .= " \$this->" . $clo . " = $defaultValue;"; } }
php
protected function addApplyDefaultValuesBody(&$script) { $table = $this->getTable(); // FIXME - Apply support for PHP default expressions here // see: http://trac.propelorm.org/ticket/378 $colsWithDefaults = array(); foreach ($table->getColumns() as $col) { $def = $col->getDefaultValue(); if ($def !== null && !$def->isExpression()) { $colsWithDefaults[] = $col; } } $colconsts = array(); foreach ($colsWithDefaults as $col) { $clo = strtolower($col->getName()); $defaultValue = $this->getDefaultValueString($col); $script .= " \$this->" . $clo . " = $defaultValue;"; } }
[ "protected", "function", "addApplyDefaultValuesBody", "(", "&", "$", "script", ")", "{", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "// FIXME - Apply support for PHP default expressions here", "// see: http://trac.propelorm.org/ticket/378", "$", "colsWithDefaults", "=", "array", "(", ")", ";", "foreach", "(", "$", "table", "->", "getColumns", "(", ")", "as", "$", "col", ")", "{", "$", "def", "=", "$", "col", "->", "getDefaultValue", "(", ")", ";", "if", "(", "$", "def", "!==", "null", "&&", "!", "$", "def", "->", "isExpression", "(", ")", ")", "{", "$", "colsWithDefaults", "[", "]", "=", "$", "col", ";", "}", "}", "$", "colconsts", "=", "array", "(", ")", ";", "foreach", "(", "$", "colsWithDefaults", "as", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "defaultValue", "=", "$", "this", "->", "getDefaultValueString", "(", "$", "col", ")", ";", "$", "script", ".=", "\"\n \\$this->\"", ".", "$", "clo", ".", "\" = $defaultValue;\"", ";", "}", "}" ]
Adds the function body of the applyDefault method @param string &$script The script will be modified in this method. @see addApplyDefaultValues()
[ "Adds", "the", "function", "body", "of", "the", "applyDefault", "method" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L752-L773
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addTemporalAccessor
protected function addTemporalAccessor(&$script, Column $col) { $this->addTemporalAccessorComment($script, $col); $this->addTemporalAccessorOpen($script, $col); $this->addTemporalAccessorBody($script, $col); $this->addTemporalAccessorClose($script, $col); }
php
protected function addTemporalAccessor(&$script, Column $col) { $this->addTemporalAccessorComment($script, $col); $this->addTemporalAccessorOpen($script, $col); $this->addTemporalAccessorBody($script, $col); $this->addTemporalAccessorClose($script, $col); }
[ "protected", "function", "addTemporalAccessor", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "this", "->", "addTemporalAccessorComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addTemporalAccessorOpen", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addTemporalAccessorBody", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addTemporalAccessorClose", "(", "$", "script", ",", "$", "col", ")", ";", "}" ]
Adds a date/time/timestamp getter method. @param string &$script The script will be modified in this method. @param Column $col The current column. @see parent::addColumnAccessors()
[ "Adds", "a", "date", "/", "time", "/", "timestamp", "getter", "method", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L804-L810
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addTemporalAccessorComment
public function addTemporalAccessorComment(&$script, Column $col) { $clo = strtolower($col->getName()); $useDateTime = $this->getBuildProperty('useDateTimeClass'); $dateTimeClass = $this->getBuildProperty('dateTimeClass'); if (!$dateTimeClass) { $dateTimeClass = 'DateTime'; } $handleMysqlDate = false; if ($this->getPlatform() instanceof MysqlPlatform) { if ($col->getType() === PropelTypes::TIMESTAMP) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00 00:00:00'; } elseif ($col->getType() === PropelTypes::DATE) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00'; } // 00:00:00 is a valid time, so no need to check for that. } $script .= " /** * Get the [optionally formatted] temporal [$clo] column value. * " . $col->getDescription(); if (!$useDateTime) { $script .= " * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass * option in order to avoid conversions to integers (which are limited in the dates they can express)."; } $script .= " * * @param string \$format The date/time format string (either date()-style or strftime()-style). * If format is null, then the raw " . ($useDateTime ? 'DateTime object' : 'unix timestamp integer') . " will be returned."; if ($useDateTime) { $script .= " * @return mixed Formatted date/time value as string or $dateTimeClass object (if format is null), null if column is null" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); } else { $script .= " * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is null), null if column is null" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); } $script .= " * @throws PropelException - if unable to parse/validate the date/time value. */"; }
php
public function addTemporalAccessorComment(&$script, Column $col) { $clo = strtolower($col->getName()); $useDateTime = $this->getBuildProperty('useDateTimeClass'); $dateTimeClass = $this->getBuildProperty('dateTimeClass'); if (!$dateTimeClass) { $dateTimeClass = 'DateTime'; } $handleMysqlDate = false; if ($this->getPlatform() instanceof MysqlPlatform) { if ($col->getType() === PropelTypes::TIMESTAMP) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00 00:00:00'; } elseif ($col->getType() === PropelTypes::DATE) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00'; } // 00:00:00 is a valid time, so no need to check for that. } $script .= " /** * Get the [optionally formatted] temporal [$clo] column value. * " . $col->getDescription(); if (!$useDateTime) { $script .= " * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass * option in order to avoid conversions to integers (which are limited in the dates they can express)."; } $script .= " * * @param string \$format The date/time format string (either date()-style or strftime()-style). * If format is null, then the raw " . ($useDateTime ? 'DateTime object' : 'unix timestamp integer') . " will be returned."; if ($useDateTime) { $script .= " * @return mixed Formatted date/time value as string or $dateTimeClass object (if format is null), null if column is null" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); } else { $script .= " * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is null), null if column is null" . ($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : ''); } $script .= " * @throws PropelException - if unable to parse/validate the date/time value. */"; }
[ "public", "function", "addTemporalAccessorComment", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "useDateTime", "=", "$", "this", "->", "getBuildProperty", "(", "'useDateTimeClass'", ")", ";", "$", "dateTimeClass", "=", "$", "this", "->", "getBuildProperty", "(", "'dateTimeClass'", ")", ";", "if", "(", "!", "$", "dateTimeClass", ")", "{", "$", "dateTimeClass", "=", "'DateTime'", ";", "}", "$", "handleMysqlDate", "=", "false", ";", "if", "(", "$", "this", "->", "getPlatform", "(", ")", "instanceof", "MysqlPlatform", ")", "{", "if", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIMESTAMP", ")", "{", "$", "handleMysqlDate", "=", "true", ";", "$", "mysqlInvalidDateString", "=", "'0000-00-00 00:00:00'", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "DATE", ")", "{", "$", "handleMysqlDate", "=", "true", ";", "$", "mysqlInvalidDateString", "=", "'0000-00-00'", ";", "}", "// 00:00:00 is a valid time, so no need to check for that.", "}", "$", "script", ".=", "\"\n /**\n * Get the [optionally formatted] temporal [$clo] column value.\n * \"", ".", "$", "col", "->", "getDescription", "(", ")", ";", "if", "(", "!", "$", "useDateTime", ")", "{", "$", "script", ".=", "\"\n * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass\n * option in order to avoid conversions to integers (which are limited in the dates they can express).\"", ";", "}", "$", "script", ".=", "\"\n *\n * @param string \\$format The date/time format string (either date()-style or strftime()-style).\n *\t\t\t\t If format is null, then the raw \"", ".", "(", "$", "useDateTime", "?", "'DateTime object'", ":", "'unix timestamp integer'", ")", ".", "\" will be returned.\"", ";", "if", "(", "$", "useDateTime", ")", "{", "$", "script", ".=", "\"\n * @return mixed Formatted date/time value as string or $dateTimeClass object (if format is null), null if column is null\"", ".", "(", "$", "handleMysqlDate", "?", "', and 0 if column value is '", ".", "$", "mysqlInvalidDateString", ":", "''", ")", ";", "}", "else", "{", "$", "script", ".=", "\"\n * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is null), null if column is null\"", ".", "(", "$", "handleMysqlDate", "?", "', and 0 if column value is '", ".", "$", "mysqlInvalidDateString", ":", "''", ")", ";", "}", "$", "script", ".=", "\"\n * @throws PropelException - if unable to parse/validate the date/time value.\n */\"", ";", "}" ]
Adds the comment for a temporal accessor @param string &$script The script will be modified in this method. @param Column $col The current column. @see addTemporalAccessor
[ "Adds", "the", "comment", "for", "a", "temporal", "accessor" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L821-L866
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addTemporalAccessorOpen
public function addTemporalAccessorOpen(&$script, Column $col) { $cfc = $col->getPhpName(); $defaultfmt = null; $visibility = $col->getAccessorVisibility(); // Default date/time formatter strings are specified in build.properties if ($col->getType() === PropelTypes::DATE) { $defaultfmt = $this->getBuildProperty('defaultDateFormat'); } elseif ($col->getType() === PropelTypes::TIME) { $defaultfmt = $this->getBuildProperty('defaultTimeFormat'); } elseif ($col->getType() === PropelTypes::TIMESTAMP) { $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat'); } if (empty($defaultfmt)) { $defaultfmt = 'null'; } else { $defaultfmt = var_export($defaultfmt, true); } $script .= " " . $visibility . " function get$cfc(\$format = " . $defaultfmt . ""; if ($col->isLazyLoad()) { $script .= ", \$con = null"; } $script .= ") {"; }
php
public function addTemporalAccessorOpen(&$script, Column $col) { $cfc = $col->getPhpName(); $defaultfmt = null; $visibility = $col->getAccessorVisibility(); // Default date/time formatter strings are specified in build.properties if ($col->getType() === PropelTypes::DATE) { $defaultfmt = $this->getBuildProperty('defaultDateFormat'); } elseif ($col->getType() === PropelTypes::TIME) { $defaultfmt = $this->getBuildProperty('defaultTimeFormat'); } elseif ($col->getType() === PropelTypes::TIMESTAMP) { $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat'); } if (empty($defaultfmt)) { $defaultfmt = 'null'; } else { $defaultfmt = var_export($defaultfmt, true); } $script .= " " . $visibility . " function get$cfc(\$format = " . $defaultfmt . ""; if ($col->isLazyLoad()) { $script .= ", \$con = null"; } $script .= ") {"; }
[ "public", "function", "addTemporalAccessorOpen", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "defaultfmt", "=", "null", ";", "$", "visibility", "=", "$", "col", "->", "getAccessorVisibility", "(", ")", ";", "// Default date/time formatter strings are specified in build.properties", "if", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "DATE", ")", "{", "$", "defaultfmt", "=", "$", "this", "->", "getBuildProperty", "(", "'defaultDateFormat'", ")", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIME", ")", "{", "$", "defaultfmt", "=", "$", "this", "->", "getBuildProperty", "(", "'defaultTimeFormat'", ")", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIMESTAMP", ")", "{", "$", "defaultfmt", "=", "$", "this", "->", "getBuildProperty", "(", "'defaultTimeStampFormat'", ")", ";", "}", "if", "(", "empty", "(", "$", "defaultfmt", ")", ")", "{", "$", "defaultfmt", "=", "'null'", ";", "}", "else", "{", "$", "defaultfmt", "=", "var_export", "(", "$", "defaultfmt", ",", "true", ")", ";", "}", "$", "script", ".=", "\"\n \"", ".", "$", "visibility", ".", "\" function get$cfc(\\$format = \"", ".", "$", "defaultfmt", ".", "\"\"", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\", \\$con = null\"", ";", "}", "$", "script", ".=", "\")\n {\"", ";", "}" ]
Adds the function declaration for a temporal accessor @param string &$script The script will be modified in this method. @param Column $col The current column. @see addTemporalAccessor
[ "Adds", "the", "function", "declaration", "for", "a", "temporal", "accessor" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L877-L906
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addTemporalAccessorBody
protected function addTemporalAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); $useDateTime = $this->getBuildProperty('useDateTimeClass'); $dateTimeClass = $this->getBuildProperty('dateTimeClass'); if (!$dateTimeClass) { $dateTimeClass = 'DateTime'; } $this->declareClasses($dateTimeClass); $defaultfmt = null; // Default date/time formatter strings are specified in build.properties if ($col->getType() === PropelTypes::DATE) { $defaultfmt = $this->getBuildProperty('defaultDateFormat'); } elseif ($col->getType() === PropelTypes::TIME) { $defaultfmt = $this->getBuildProperty('defaultTimeFormat'); } elseif ($col->getType() === PropelTypes::TIMESTAMP) { $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat'); } if (empty($defaultfmt)) { $defaultfmt = null; } $handleMysqlDate = false; if ($this->getPlatform() instanceof MysqlPlatform) { if ($col->getType() === PropelTypes::TIMESTAMP) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00 00:00:00'; } elseif ($col->getType() === PropelTypes::DATE) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00'; } // 00:00:00 is a valid time, so no need to check for that. } if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " if (\$this->$clo === null) { return null; } "; if ($handleMysqlDate) { $script .= " if (\$this->$clo === '$mysqlInvalidDateString') { // while technically this is not a default value of null, // this seems to be closest in meaning. return null; } try { \$dt = new $dateTimeClass(\$this->$clo); } catch (Exception \$x) { throw new PropelException(\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \" . var_export(\$this->$clo, true), \$x); } "; } else { $script .= " try { \$dt = new $dateTimeClass(\$this->$clo); } catch (Exception \$x) { throw new PropelException(\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \" . var_export(\$this->$clo, true), \$x); } "; } // if handleMyqlDate $script .= " if (\$format === null) {"; if ($useDateTime) { $script .= " // Because propel.useDateTimeClass is true, we return a $dateTimeClass object. return \$dt;"; } else { $script .= " // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates. return (int) \$dt->format('U');"; } $script .= " } if (strpos(\$format, '%') !== false) { return strftime(\$format, \$dt->format('U')); } return \$dt->format(\$format); "; }
php
protected function addTemporalAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); $useDateTime = $this->getBuildProperty('useDateTimeClass'); $dateTimeClass = $this->getBuildProperty('dateTimeClass'); if (!$dateTimeClass) { $dateTimeClass = 'DateTime'; } $this->declareClasses($dateTimeClass); $defaultfmt = null; // Default date/time formatter strings are specified in build.properties if ($col->getType() === PropelTypes::DATE) { $defaultfmt = $this->getBuildProperty('defaultDateFormat'); } elseif ($col->getType() === PropelTypes::TIME) { $defaultfmt = $this->getBuildProperty('defaultTimeFormat'); } elseif ($col->getType() === PropelTypes::TIMESTAMP) { $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat'); } if (empty($defaultfmt)) { $defaultfmt = null; } $handleMysqlDate = false; if ($this->getPlatform() instanceof MysqlPlatform) { if ($col->getType() === PropelTypes::TIMESTAMP) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00 00:00:00'; } elseif ($col->getType() === PropelTypes::DATE) { $handleMysqlDate = true; $mysqlInvalidDateString = '0000-00-00'; } // 00:00:00 is a valid time, so no need to check for that. } if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " if (\$this->$clo === null) { return null; } "; if ($handleMysqlDate) { $script .= " if (\$this->$clo === '$mysqlInvalidDateString') { // while technically this is not a default value of null, // this seems to be closest in meaning. return null; } try { \$dt = new $dateTimeClass(\$this->$clo); } catch (Exception \$x) { throw new PropelException(\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \" . var_export(\$this->$clo, true), \$x); } "; } else { $script .= " try { \$dt = new $dateTimeClass(\$this->$clo); } catch (Exception \$x) { throw new PropelException(\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \" . var_export(\$this->$clo, true), \$x); } "; } // if handleMyqlDate $script .= " if (\$format === null) {"; if ($useDateTime) { $script .= " // Because propel.useDateTimeClass is true, we return a $dateTimeClass object. return \$dt;"; } else { $script .= " // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates. return (int) \$dt->format('U');"; } $script .= " } if (strpos(\$format, '%') !== false) { return strftime(\$format, \$dt->format('U')); } return \$dt->format(\$format); "; }
[ "protected", "function", "addTemporalAccessorBody", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "useDateTime", "=", "$", "this", "->", "getBuildProperty", "(", "'useDateTimeClass'", ")", ";", "$", "dateTimeClass", "=", "$", "this", "->", "getBuildProperty", "(", "'dateTimeClass'", ")", ";", "if", "(", "!", "$", "dateTimeClass", ")", "{", "$", "dateTimeClass", "=", "'DateTime'", ";", "}", "$", "this", "->", "declareClasses", "(", "$", "dateTimeClass", ")", ";", "$", "defaultfmt", "=", "null", ";", "// Default date/time formatter strings are specified in build.properties", "if", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "DATE", ")", "{", "$", "defaultfmt", "=", "$", "this", "->", "getBuildProperty", "(", "'defaultDateFormat'", ")", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIME", ")", "{", "$", "defaultfmt", "=", "$", "this", "->", "getBuildProperty", "(", "'defaultTimeFormat'", ")", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIMESTAMP", ")", "{", "$", "defaultfmt", "=", "$", "this", "->", "getBuildProperty", "(", "'defaultTimeStampFormat'", ")", ";", "}", "if", "(", "empty", "(", "$", "defaultfmt", ")", ")", "{", "$", "defaultfmt", "=", "null", ";", "}", "$", "handleMysqlDate", "=", "false", ";", "if", "(", "$", "this", "->", "getPlatform", "(", ")", "instanceof", "MysqlPlatform", ")", "{", "if", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "TIMESTAMP", ")", "{", "$", "handleMysqlDate", "=", "true", ";", "$", "mysqlInvalidDateString", "=", "'0000-00-00 00:00:00'", ";", "}", "elseif", "(", "$", "col", "->", "getType", "(", ")", "===", "PropelTypes", "::", "DATE", ")", "{", "$", "handleMysqlDate", "=", "true", ";", "$", "mysqlInvalidDateString", "=", "'0000-00-00'", ";", "}", "// 00:00:00 is a valid time, so no need to check for that.", "}", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "$", "this", "->", "getAccessorLazyLoadSnippet", "(", "$", "col", ")", ";", "}", "$", "script", ".=", "\"\n if (\\$this->$clo === null) {\n return null;\n }\n\"", ";", "if", "(", "$", "handleMysqlDate", ")", "{", "$", "script", ".=", "\"\n if (\\$this->$clo === '$mysqlInvalidDateString') {\n // while technically this is not a default value of null,\n // this seems to be closest in meaning.\n return null;\n }\n\n try {\n \\$dt = new $dateTimeClass(\\$this->$clo);\n } catch (Exception \\$x) {\n throw new PropelException(\\\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \\\" . var_export(\\$this->$clo, true), \\$x);\n }\n\"", ";", "}", "else", "{", "$", "script", ".=", "\"\n\n try {\n \\$dt = new $dateTimeClass(\\$this->$clo);\n } catch (Exception \\$x) {\n throw new PropelException(\\\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \\\" . var_export(\\$this->$clo, true), \\$x);\n }\n\"", ";", "}", "// if handleMyqlDate", "$", "script", ".=", "\"\n if (\\$format === null) {\"", ";", "if", "(", "$", "useDateTime", ")", "{", "$", "script", ".=", "\"\n // Because propel.useDateTimeClass is true, we return a $dateTimeClass object.\n return \\$dt;\"", ";", "}", "else", "{", "$", "script", ".=", "\"\n // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.\n return (int) \\$dt->format('U');\"", ";", "}", "$", "script", ".=", "\"\n }\n\n if (strpos(\\$format, '%') !== false) {\n return strftime(\\$format, \\$dt->format('U'));\n }\n\n return \\$dt->format(\\$format);\n \"", ";", "}" ]
Adds the body of the temporal accessor @param string &$script The script will be modified in this method. @param Column $col The current column. @see addTemporalAccessor
[ "Adds", "the", "body", "of", "the", "temporal", "accessor" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L934-L1027
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addObjectAccessor
protected function addObjectAccessor(&$script, Column $col) { $this->addDefaultAccessorComment($script, $col); $this->addDefaultAccessorOpen($script, $col); $this->addObjectAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
php
protected function addObjectAccessor(&$script, Column $col) { $this->addDefaultAccessorComment($script, $col); $this->addDefaultAccessorOpen($script, $col); $this->addObjectAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
[ "protected", "function", "addObjectAccessor", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "this", "->", "addDefaultAccessorComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorOpen", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addObjectAccessorBody", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorClose", "(", "$", "script", ",", "$", "col", ")", ";", "}" ]
Adds an object getter method. @param string &$script The script will be modified in this method. @param Column $col The current column. @see parent::addColumnAccessors()
[ "Adds", "an", "object", "getter", "method", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1052-L1058
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addObjectAccessorBody
protected function addObjectAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); $cloUnserialized = $clo . '_unserialized'; if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " if (null == \$this->$cloUnserialized && null !== \$this->$clo) { \$this->$cloUnserialized = unserialize(\$this->$clo); } return \$this->$cloUnserialized;"; }
php
protected function addObjectAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); $cloUnserialized = $clo . '_unserialized'; if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " if (null == \$this->$cloUnserialized && null !== \$this->$clo) { \$this->$cloUnserialized = unserialize(\$this->$clo); } return \$this->$cloUnserialized;"; }
[ "protected", "function", "addObjectAccessorBody", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "cloUnserialized", "=", "$", "clo", ".", "'_unserialized'", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "$", "this", "->", "getAccessorLazyLoadSnippet", "(", "$", "col", ")", ";", "}", "$", "script", ".=", "\"\n if (null == \\$this->$cloUnserialized && null !== \\$this->$clo) {\n \\$this->$cloUnserialized = unserialize(\\$this->$clo);\n }\n\n return \\$this->$cloUnserialized;\"", ";", "}" ]
Adds the function body for an object accessor method @param string &$script The script will be modified in this method. @param Column $col The current column. @see addDefaultAccessor()
[ "Adds", "the", "function", "body", "for", "an", "object", "accessor", "method" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1068-L1083
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addArrayAccessor
protected function addArrayAccessor(&$script, Column $col) { $this->addDefaultAccessorComment($script, $col); $this->addDefaultAccessorOpen($script, $col); $this->addArrayAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
php
protected function addArrayAccessor(&$script, Column $col) { $this->addDefaultAccessorComment($script, $col); $this->addDefaultAccessorOpen($script, $col); $this->addArrayAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
[ "protected", "function", "addArrayAccessor", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "this", "->", "addDefaultAccessorComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorOpen", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addArrayAccessorBody", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorClose", "(", "$", "script", ",", "$", "col", ")", ";", "}" ]
Adds an array getter method. @param string &$script The script will be modified in this method. @param Column $col The current column. @see parent::addColumnAccessors()
[ "Adds", "an", "array", "getter", "method", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1093-L1099
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addEnumAccessor
protected function addEnumAccessor(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " /** * Get the [$clo] column value. * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " * @return " . $col->getPhpType() . " * @throws PropelException - if the stored enum key is unknown. */"; $this->addDefaultAccessorOpen($script, $col); $this->addEnumAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
php
protected function addEnumAccessor(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " /** * Get the [$clo] column value. * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " * @return " . $col->getPhpType() . " * @throws PropelException - if the stored enum key is unknown. */"; $this->addDefaultAccessorOpen($script, $col); $this->addEnumAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
[ "protected", "function", "addEnumAccessor", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "script", ".=", "\"\n /**\n * Get the [$clo] column value.\n * \"", ".", "$", "col", "->", "getDescription", "(", ")", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\"\n * @param PropelPDO \\$con An optional PropelPDO connection to use for fetching this lazy-loaded column.\"", ";", "}", "$", "script", ".=", "\"\n * @return \"", ".", "$", "col", "->", "getPhpType", "(", ")", ".", "\"\n * @throws PropelException - if the stored enum key is unknown.\n */\"", ";", "$", "this", "->", "addDefaultAccessorOpen", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addEnumAccessorBody", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorClose", "(", "$", "script", ",", "$", "col", ")", ";", "}" ]
Adds an enum getter method. @param string &$script The script will be modified in this method. @param Column $col The current column. @see parent::addColumnAccessors()
[ "Adds", "an", "enum", "getter", "method", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1138-L1157
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addEnumAccessorBody
protected function addEnumAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " if (null === \$this->$clo) { return null; } \$valueSet = " . $this->getPeerClassname() . "::getValueSet(" . $this->getColumnConstant($col) . "); if (!isset(\$valueSet[\$this->$clo])) { throw new PropelException('Unknown stored enum key: ' . \$this->$clo); } return \$valueSet[\$this->$clo];"; }
php
protected function addEnumAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " if (null === \$this->$clo) { return null; } \$valueSet = " . $this->getPeerClassname() . "::getValueSet(" . $this->getColumnConstant($col) . "); if (!isset(\$valueSet[\$this->$clo])) { throw new PropelException('Unknown stored enum key: ' . \$this->$clo); } return \$valueSet[\$this->$clo];"; }
[ "protected", "function", "addEnumAccessorBody", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "$", "this", "->", "getAccessorLazyLoadSnippet", "(", "$", "col", ")", ";", "}", "$", "script", ".=", "\"\n if (null === \\$this->$clo) {\n return null;\n }\n \\$valueSet = \"", ".", "$", "this", "->", "getPeerClassname", "(", ")", ".", "\"::getValueSet(\"", ".", "$", "this", "->", "getColumnConstant", "(", "$", "col", ")", ".", "\");\n if (!isset(\\$valueSet[\\$this->$clo])) {\n throw new PropelException('Unknown stored enum key: ' . \\$this->$clo);\n }\n\n return \\$valueSet[\\$this->$clo];\"", ";", "}" ]
Adds the function body for an enum accessor method @param string &$script The script will be modified in this method. @param Column $col The current column. @see addDefaultAccessor()
[ "Adds", "the", "function", "body", "for", "an", "enum", "accessor", "method" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1167-L1185
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addHasArrayElement
protected function addHasArrayElement(&$script, Column $col) { $clo = strtolower($col->getName()); $cfc = $col->getPhpName(); $visibility = $col->getAccessorVisibility(); $singularPhpName = rtrim($cfc, 's'); $script .= " /** * Test the presence of a value in the [$clo] array column value. * @param mixed \$value * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " * @return boolean */ $visibility function has$singularPhpName(\$value"; if ($col->isLazyLoad()) { $script .= ", PropelPDO \$con = null"; } $script .= ") { return in_array(\$value, \$this->get$cfc("; if ($col->isLazyLoad()) { $script .= "\$con"; } $script .= ")); } // has$singularPhpName() "; }
php
protected function addHasArrayElement(&$script, Column $col) { $clo = strtolower($col->getName()); $cfc = $col->getPhpName(); $visibility = $col->getAccessorVisibility(); $singularPhpName = rtrim($cfc, 's'); $script .= " /** * Test the presence of a value in the [$clo] array column value. * @param mixed \$value * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " * @return boolean */ $visibility function has$singularPhpName(\$value"; if ($col->isLazyLoad()) { $script .= ", PropelPDO \$con = null"; } $script .= ") { return in_array(\$value, \$this->get$cfc("; if ($col->isLazyLoad()) { $script .= "\$con"; } $script .= ")); } // has$singularPhpName() "; }
[ "protected", "function", "addHasArrayElement", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "visibility", "=", "$", "col", "->", "getAccessorVisibility", "(", ")", ";", "$", "singularPhpName", "=", "rtrim", "(", "$", "cfc", ",", "'s'", ")", ";", "$", "script", ".=", "\"\n /**\n * Test the presence of a value in the [$clo] array column value.\n * @param mixed \\$value\n * \"", ".", "$", "col", "->", "getDescription", "(", ")", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\"\n * @param PropelPDO \\$con An optional PropelPDO connection to use for fetching this lazy-loaded column.\"", ";", "}", "$", "script", ".=", "\"\n * @return boolean\n */\n $visibility function has$singularPhpName(\\$value\"", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\", PropelPDO \\$con = null\"", ";", "}", "$", "script", ".=", "\")\n {\n return in_array(\\$value, \\$this->get$cfc(\"", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\"\\$con\"", ";", "}", "$", "script", ".=", "\"));\n } // has$singularPhpName()\n\"", ";", "}" ]
Adds a tester method for an array column. @param string &$script The script will be modified in this method. @param Column $col The current column.
[ "Adds", "a", "tester", "method", "for", "an", "array", "column", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1193-L1224
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addDefaultAccessor
protected function addDefaultAccessor(&$script, Column $col) { $this->addDefaultAccessorComment($script, $col); $this->addDefaultAccessorOpen($script, $col); $this->addDefaultAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
php
protected function addDefaultAccessor(&$script, Column $col) { $this->addDefaultAccessorComment($script, $col); $this->addDefaultAccessorOpen($script, $col); $this->addDefaultAccessorBody($script, $col); $this->addDefaultAccessorClose($script, $col); }
[ "protected", "function", "addDefaultAccessor", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "this", "->", "addDefaultAccessorComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorOpen", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorBody", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addDefaultAccessorClose", "(", "$", "script", ",", "$", "col", ")", ";", "}" ]
Adds a normal (non-temporal) getter method. @param string &$script The script will be modified in this method. @param Column $col The current column. @see parent::addColumnAccessors()
[ "Adds", "a", "normal", "(", "non", "-", "temporal", ")", "getter", "method", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1234-L1240
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addDefaultAccessorComment
public function addDefaultAccessorComment(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " /** * Get the [$clo] column value. * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " * @return " . $col->getPhpType() . " */"; }
php
public function addDefaultAccessorComment(&$script, Column $col) { $clo = strtolower($col->getName()); $script .= " /** * Get the [$clo] column value. * " . $col->getDescription(); if ($col->isLazyLoad()) { $script .= " * @param PropelPDO \$con An optional PropelPDO connection to use for fetching this lazy-loaded column."; } $script .= " * @return " . $col->getPhpType() . " */"; }
[ "public", "function", "addDefaultAccessorComment", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "$", "script", ".=", "\"\n /**\n * Get the [$clo] column value.\n * \"", ".", "$", "col", "->", "getDescription", "(", ")", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\"\n * @param PropelPDO \\$con An optional PropelPDO connection to use for fetching this lazy-loaded column.\"", ";", "}", "$", "script", ".=", "\"\n * @return \"", ".", "$", "col", "->", "getPhpType", "(", ")", ".", "\"\n */\"", ";", "}" ]
Add the comment for a default accessor method (a getter) @param string &$script The script will be modified in this method. @param Column $col The current column. @see addDefaultAccessor()
[ "Add", "the", "comment", "for", "a", "default", "accessor", "method", "(", "a", "getter", ")" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1250-L1265
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addDefaultAccessorOpen
public function addDefaultAccessorOpen(&$script, Column $col) { $cfc = $col->getPhpName(); $visibility = $col->getAccessorVisibility(); $script .= " " . $visibility . " function get$cfc("; if ($col->isLazyLoad()) { $script .= "PropelPDO \$con = null"; } $script .= ") {"; }
php
public function addDefaultAccessorOpen(&$script, Column $col) { $cfc = $col->getPhpName(); $visibility = $col->getAccessorVisibility(); $script .= " " . $visibility . " function get$cfc("; if ($col->isLazyLoad()) { $script .= "PropelPDO \$con = null"; } $script .= ") {"; }
[ "public", "function", "addDefaultAccessorOpen", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "visibility", "=", "$", "col", "->", "getAccessorVisibility", "(", ")", ";", "$", "script", ".=", "\"\n \"", ".", "$", "visibility", ".", "\" function get$cfc(\"", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "\"PropelPDO \\$con = null\"", ";", "}", "$", "script", ".=", "\")\n {\"", ";", "}" ]
Adds the function declaration for a default accessor @param string &$script The script will be modified in this method. @param Column $col The current column. @see addDefaultAccessor()
[ "Adds", "the", "function", "declaration", "for", "a", "default", "accessor" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1275-L1287
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addDefaultAccessorBody
protected function addDefaultAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " return \$this->$clo;"; }
php
protected function addDefaultAccessorBody(&$script, Column $col) { $cfc = $col->getPhpName(); $clo = strtolower($col->getName()); if ($col->isLazyLoad()) { $script .= $this->getAccessorLazyLoadSnippet($col); } $script .= " return \$this->$clo;"; }
[ "protected", "function", "addDefaultAccessorBody", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "cfc", "=", "$", "col", "->", "getPhpName", "(", ")", ";", "$", "clo", "=", "strtolower", "(", "$", "col", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "col", "->", "isLazyLoad", "(", ")", ")", "{", "$", "script", ".=", "$", "this", "->", "getAccessorLazyLoadSnippet", "(", "$", "col", ")", ";", "}", "$", "script", ".=", "\"\n\n return \\$this->$clo;\"", ";", "}" ]
Adds the function body for a default accessor method @param string &$script The script will be modified in this method. @param Column $col The current column. @see addDefaultAccessor()
[ "Adds", "the", "function", "body", "for", "a", "default", "accessor", "method" ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1297-L1308
propelorm/Propel
generator/lib/builder/om/PHP5ObjectBuilder.php
PHP5ObjectBuilder.addLazyLoader
protected function addLazyLoader(&$script, Column $col) { $this->addLazyLoaderComment($script, $col); $this->addLazyLoaderOpen($script, $col); $this->addLazyLoaderBody($script, $col); $this->addLazyLoaderClose($script, $col); }
php
protected function addLazyLoader(&$script, Column $col) { $this->addLazyLoaderComment($script, $col); $this->addLazyLoaderOpen($script, $col); $this->addLazyLoaderBody($script, $col); $this->addLazyLoaderClose($script, $col); }
[ "protected", "function", "addLazyLoader", "(", "&", "$", "script", ",", "Column", "$", "col", ")", "{", "$", "this", "->", "addLazyLoaderComment", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addLazyLoaderOpen", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addLazyLoaderBody", "(", "$", "script", ",", "$", "col", ")", ";", "$", "this", "->", "addLazyLoaderClose", "(", "$", "script", ",", "$", "col", ")", ";", "}" ]
Adds the lazy loader method. @param string &$script The script will be modified in this method. @param Column $col The current column. @see parent::addColumnAccessors()
[ "Adds", "the", "lazy", "loader", "method", "." ]
train
https://github.com/propelorm/Propel/blob/3f7a284906ce3e402bcb101938270842fdad71fa/generator/lib/builder/om/PHP5ObjectBuilder.php#L1333-L1339