本文整理汇总了PHP中Propel\Generator\Model\Table类的典型用法代码示例。如果您正苦于以下问题:PHP Table类的具体用法?PHP Table怎么用?PHP Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrimaryKeyDDL
public function getPrimaryKeyDDL(Table $table)
{
if ($table->hasPrimaryKey()) {
$pattern = 'CONSTRAINT %s PRIMARY KEY (%s)';
return sprintf($pattern, $this->quoteIdentifier($this->getPrimaryKeyName($table)), $this->getColumnListDDL($table->getPrimaryKey()));
}
}
示例2: testTable
public function testTable()
{
$b = new Behavior();
$this->assertNull($b->getTable(), 'Behavior Table is null by default');
$t = new Table();
$t->setCommonName('fooTable');
$b->setTable($t);
$this->assertEquals($b->getTable(), $t, 'setTable() sets the name, and getTable() gets it');
}
示例3: addUniqueConstraint
/**
* Adds a unique constraint to the table to enforce uniqueness of the slug_column
*
* @param Table $table
*/
protected function addUniqueConstraint(Table $table)
{
$unique = new Unique($this->getColumnForParameter('slug_column'));
$unique->setName($table->getCommonName() . '_slug');
$unique->addColumn($table->getColumn($this->getParameter('slug_column')));
if ($this->getParameter('scope_column')) {
$unique->addColumn($table->getColumn($this->getParameter('scope_column')));
}
$table->addUnique($unique);
}
示例4: testTableNamespaceAndDbNamespace
public function testTableNamespaceAndDbNamespace()
{
$d = new Database('fooDb');
$d->setNamespace('Baz');
$t = new Table('fooTable');
$t->setNamespace('Foo\\Bar');
$d->addTable($t);
$builder = new TestableOMBuilder2($t);
$this->assertEquals('Baz\\Foo\\Bar', $builder->getNamespace(), 'Builder namespace is composed from the database and table namespaces when both are set');
}
示例5: _before
/**
* @return void
*/
protected function _before()
{
$config = new QuickGeneratorConfig();
$table = new Table('Foo');
$column = new Column('testColumn', PropelTypes::INTEGER);
$table->addColumn($column);
$table->setNamespace('Unit\\Spryker\\Zed\\Propel\\Business\\Builder\\QueryBuilder');
$table->setDatabase(new Database('TestDB', new DefaultPlatform()));
foreach ($this->getFilesToGenerate() as $fileName => $builderClass) {
$builder = new $builderClass($table);
$builder->setGeneratorConfig($config);
$this->writePropelFile($builder, $fileName);
}
}
示例6: hasPlatform
/**
* Returns whether or not this column has a platform adapter.
*
* @return boolean
*/
public function hasPlatform()
{
if (null === $this->parentTable) {
return false;
}
return $this->parentTable->getPlatform() ? true : false;
}
示例7: buildFormFields
/**
* Build the fields in the FormType.
*
* @param Table $table Table from which the fields will be extracted.
*
* @return string The FormType code.
*/
protected function buildFormFields(Table $table)
{
$buildCode = '';
foreach ($table->getColumns() as $column) {
if ($column->isPrimaryKey()) {
continue;
}
$name = $column->getPhpName();
// Use foreignKey table name, so the TypeGuesser gets it right
if ($column->isForeignKey()) {
/** @var ForeignKey $foreignKey */
$foreignKey = current($column->getForeignKeys());
$name = $foreignKey->getForeignTable()->getPhpName();
}
$buildCode .= sprintf("\n \$builder->add('%s');", lcfirst($name));
}
return $buildCode;
}
示例8: getOtherFks
/**
* Returns the list of other foreign keys starting on the same table.
* Used in many-to-many relationships.
*
* @return ForeignKey[]
*/
public function getOtherFks()
{
$fks = [];
foreach ($this->parentTable->getForeignKeys() as $fk) {
if ($fk !== $this) {
$fks[] = $fk;
}
}
return $fks;
}
示例9: getPlatform
/**
* Convenience method to returns the Platform class for this table (database).
* @return PlatformInterface
*/
public function getPlatform()
{
if (null === $this->platform) {
// try to load the platform from the table
$table = $this->getTable();
if ($table && ($database = $table->getDatabase())) {
$this->setPlatform($database->getPlatform());
}
}
if (!$this->table->isIdentifierQuotingEnabled()) {
$this->platform->setIdentifierQuoting(false);
}
return $this->platform;
}
示例10: endElement
public function endElement($parser, $name)
{
if ('index' === $name) {
$this->currTable->addIndex($this->currIndex);
} else {
if ('unique' === $name) {
$this->currTable->addUnique($this->currUnique);
}
}
if (self::DEBUG) {
print 'endElement(' . $name . ") called\n";
}
$this->popCurrentSchemaTag();
}
示例11: validateTableColumns
protected function validateTableColumns(Table $table)
{
if (!$table->hasPrimaryKey() && !$table->isSkipSql()) {
$this->errors[] = sprintf('Table "%s" does not have a primary key defined. Propel requires all tables to have a primary key.', $table->getName());
}
$phpNames = [];
foreach ($table->getColumns() as $column) {
if (in_array($column->getPhpName(), $phpNames)) {
$this->errors[] = sprintf('Column "%s" declares a phpName already used in table "%s"', $column->getName(), $table->getName());
}
$phpNames[] = $column->getPhpName();
}
}
示例12: getAddTableDDL
public function getAddTableDDL(Table $table)
{
$tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : '';
$lines = array();
foreach ($table->getColumns() as $column) {
$lines[] = $this->getColumnDDL($column);
}
if ($table->hasPrimaryKey() && count($table->getPrimaryKey()) > 1) {
$lines[] = $this->getPrimaryKeyDDL($table);
}
foreach ($table->getUnices() as $unique) {
$lines[] = $this->getUniqueDDL($unique);
}
$sep = ",\n ";
$pattern = "\n%sCREATE TABLE %s\n(\n %s\n);\n";
return sprintf($pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines));
}
示例13: addToArrayKeyLookUp
/**
* Adds the switch-statement for looking up the array-key name for toArray
* @see toArray
*/
protected function addToArrayKeyLookUp($phpName, Table $table, $plural)
{
if ($phpName == "") {
$phpName = $table->getPhpName();
}
$camelCaseName = $table->getCamelCaseName();
$fieldName = $table->getName();
if ($plural) {
$phpName = $this->getPluralizer()->getPluralForm($phpName);
$camelCaseName = $this->getPluralizer()->getPluralForm($camelCaseName);
$fieldName = $this->getPluralizer()->getPluralForm($fieldName);
}
return "\n switch (\$keyType) {\n case TableMap::TYPE_CAMELNAME:\n \$key = '" . $camelCaseName . "';\n break;\n case TableMap::TYPE_FIELDNAME:\n \$key = '" . $fieldName . "';\n break;\n default:\n \$key = '" . $phpName . "';\n }\n ";
}
示例14: testGetPrimaryKeyDDLCompositeKey
public function testGetPrimaryKeyDDLCompositeKey()
{
$table = new Table('foo');
$column1 = new Column('bar1');
$column1->setPrimaryKey(true);
$table->addColumn($column1);
$column2 = new Column('bar2');
$column2->setPrimaryKey(true);
$table->addColumn($column2);
$expected = 'PRIMARY KEY ([bar1],[bar2])';
$this->assertEquals($expected, $this->getPlatform()->getPrimaryKeyDDL($table));
}
示例15: getDropPrimaryKeyDDL
/**
* Builds the DDL SQL to drop the primary key of a table.
*
* @param Table $table
* @return string
*/
public function getDropPrimaryKeyDDL(Table $table)
{
if (!$table->hasPrimaryKey()) {
return '';
}
$pattern = "\nALTER TABLE %s DROP PRIMARY KEY;\n";
return sprintf($pattern, $this->quoteIdentifier($table->getName()));
}