本文整理汇总了PHP中Propel\Generator\Model\Table::getUnices方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::getUnices方法的具体用法?PHP Table::getUnices怎么用?PHP Table::getUnices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Table
的用法示例。
在下文中一共展示了Table::getUnices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAddTableDDL
public function getAddTableDDL(Table $table)
{
$tableDescription = $table->hasDescription() ? $this->getCommentLineDDL($table->getDescription()) : '';
$lines = [];
foreach ($table->getColumns() as $column) {
$lines[] = $this->getColumnDDL($column);
}
foreach ($table->getUnices() as $unique) {
$lines[] = $this->getUniqueDDL($unique);
}
$sep = ",\n ";
$pattern = "\n%sCREATE TABLE %s\n(\n %s\n)%s;\n";
$ret = sprintf($pattern, $tableDescription, $this->quoteIdentifier($table->getName()), implode($sep, $lines), $this->generateBlockStorage($table));
$ret .= $this->getAddPrimaryKeyDDL($table);
$ret .= $this->getAddSequencesDDL($table);
return $ret;
}
示例2: testAddArrayUnique
public function testAddArrayUnique()
{
$table = new Table();
$table->addUnique(array('name' => 'author_unq'));
$this->assertCount(1, $table->getUnices());
}
示例3: normalizeTable
/**
* Unfortunately, SQLite does not support composite pks where one is AUTOINCREMENT,
* so we have to flag both as NOT NULL and create a UNIQUE constraint.
*
* @param Table $table
*/
public function normalizeTable(Table $table)
{
if (count($pks = $table->getPrimaryKey()) > 1 && $table->hasAutoIncrementPrimaryKey()) {
foreach ($pks as $pk) {
//no pk can be NULL, as usual
$pk->setNotNull(true);
//in SQLite the column with the AUTOINCREMENT MUST be a primary key, too.
if (!$pk->isAutoIncrement()) {
//for all other sub keys we remove it, since we create a UNIQUE constraint over all primary keys.
$pk->setPrimaryKey(false);
}
}
//search if there is already a UNIQUE constraint over the primary keys
$pkUniqueExist = false;
foreach ($table->getUnices() as $unique) {
$allPk = false;
foreach ($unique->getColumns() as $columnName) {
$allPk &= $table->getColumn($columnName)->isPrimaryKey();
}
if ($allPk) {
//there's already a unique constraint with the composite pk
$pkUniqueExist = true;
break;
}
}
//there is none, let's create it
if (!$pkUniqueExist) {
$unique = new Unique();
foreach ($pks as $pk) {
$unique->addColumn($pk);
}
$table->addUnique($unique);
}
}
parent::normalizeTable($table);
}
示例4: appendTableNode
/**
* Appends the generated <table> XML node to its parent node.
*
* @param Table $table The Table model instance
* @param \DOMNode $parentNode The parent DOMNode object
*/
private function appendTableNode(Table $table, \DOMNode $parentNode)
{
$tableNode = $parentNode->appendChild($this->document->createElement('table'));
$tableNode->setAttribute('name', $table->getCommonName());
$database = $table->getDatabase();
$schema = $table->getSchema();
if ($schema && $schema !== $database->getSchema()) {
$tableNode->setAttribute('schema', $schema);
}
if (IdMethod::NO_ID_METHOD !== ($idMethod = $table->getIdMethod())) {
$tableNode->setAttribute('idMethod', $idMethod);
}
if ($phpName = $table->getPhpName()) {
$tableNode->setAttribute('phpName', $phpName);
}
$package = $table->getPackage();
if ($package && !$table->isPackageOverriden()) {
$tableNode->setAttribute('package', $package);
}
if ($namespace = $table->getNamespace()) {
$tableNode->setAttribute('namespace', $namespace);
}
if ($table->isSkipSql()) {
$tableNode->setAttribute('skipSql', 'true');
}
if ($table->isAbstract()) {
$tableNode->setAttribute('abstract', 'true');
}
if ($interface = $table->getInterface()) {
$tableNode->setAttribute('interface', $interface);
}
if ($table->isCrossRef()) {
$tableNode->setAttribute('isCrossRef', 'true');
}
$phpNamingMethod = $table->getPhpNamingMethod();
if ($phpNamingMethod && $phpNamingMethod !== $database->getDefaultPhpNamingMethod()) {
$tableNode->setAttribute('phpNamingMethod', $phpNamingMethod);
}
if ($baseClass = $table->getBaseClass()) {
$tableNode->setAttribute('baseClass', $baseClass);
}
if ($baseQueryClass = $table->getBaseQueryClass()) {
$tableNode->setAttribute('baseQueryClass', $baseQueryClass);
}
if ($table->isReadOnly()) {
$tableNode->setAttribute('readOnly', 'true');
}
if ($table->isReloadOnInsert()) {
$tableNode->setAttribute('reloadOnInsert', 'true');
}
if ($table->isReloadOnUpdate()) {
$tableNode->setAttribute('reloadOnUpdate', 'true');
}
if (null !== ($referenceOnly = $table->isForReferenceOnly())) {
$tableNode->setAttribute('forReferenceOnly', $referenceOnly ? 'true' : 'false');
}
if ($alias = $table->getAlias()) {
$tableNode->setAttribute('alias', $alias);
}
if ($description = $table->getDescription()) {
$tableNode->setAttribute('description', $description);
}
$defaultStringFormat = $table->getDefaultStringFormat();
if (Table::DEFAULT_STRING_FORMAT !== $defaultStringFormat) {
$tableNode->setAttribute('defaultStringFormat', $defaultStringFormat);
}
$defaultAccessorVisibility = $table->getDefaultAccessorVisibility();
if ($defaultAccessorVisibility !== Table::VISIBILITY_PUBLIC) {
$tableNode->setAttribute('defaultAccessorVisibility', $defaultAccessorVisibility);
}
$defaultMutatorVisibility = $table->getDefaultMutatorVisibility();
if ($defaultMutatorVisibility !== Table::VISIBILITY_PUBLIC) {
$tableNode->setAttribute('defaultMutatorVisibility', $defaultMutatorVisibility);
}
foreach ($table->getColumns() as $column) {
$this->appendColumnNode($column, $tableNode);
}
foreach ($table->getForeignKeys() as $foreignKey) {
$this->appendForeignKeyNode($foreignKey, $tableNode);
}
foreach ($table->getIdMethodParameters() as $parameter) {
$this->appendIdMethodParameterNode($parameter, $tableNode);
}
foreach ($table->getIndices() as $index) {
$this->appendIndexNode($index, $tableNode);
}
foreach ($table->getUnices() as $index) {
$this->appendUniqueIndexNode($index, $tableNode);
}
foreach ($table->getVendorInformation() as $vendorInformation) {
$this->appendVendorInformationNode($vendorInformation, $tableNode);
}
foreach ($table->getBehaviors() as $behavior) {
$this->appendBehaviorNode($behavior, $tableNode);
//.........这里部分代码省略.........