本文整理汇总了PHP中Table::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::getName方法的具体用法?PHP Table::getName怎么用?PHP Table::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installedStuffLookup
function installedStuffLookup($title, $tableName)
{
?>
<section>
<header class="tableRow gray"><h3><?php
echo $title;
?>
</h3></header>
<?php
global $computer;
$table = new Table($tableName);
$result = $table->runQuery();
$installedItems = explode(" - ", $computer[$table->getName() . "_list"]);
$i = 0;
foreach ($result as $row) {
if ($i == 0) {
echo "\t\t\t\t<div class=\"tableRow\">";
}
$isInstalled = in_array($row[$table->getName() . "_name"], $installedItems);
echo "\t\t\t\t\t\t\t<div class=\"tableCell quarterWidth" . ($isInstalled ? " gray" : "") . "\">\r\n\t\t\t\t\t\t\t\t<label class=\"configLabel\"><input class=\"configCheckbox\" name=\"{$table->getName()}_list[]\" type=\"checkbox\" value=\"{$row[$table->getName() . "_name"]}\"" . ($isInstalled ? " checked" : "") . "/>\r\n\t\t\t\t\t\t\t\t{$row[$table->getName() . "_name"]}</label>\r\n\t\t\t\t\t\t\t</div>\r\n";
if ($i++ == 3) {
echo "\t\t\t\t</div>";
$i = 0;
}
}
?>
</section>
<?php
}
示例2: getDropTableDDL
public function getDropTableDDL(Table $table)
{
$ret = '';
foreach ($table->getForeignKeys() as $fk) {
$ret .= "\nIF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='" . $fk->getName() . "')\n ALTER TABLE " . $this->quoteIdentifier($table->getName()) . " DROP CONSTRAINT " . $this->quoteIdentifier($fk->getName()) . ";\n";
}
self::$dropCount++;
$ret .= "\nIF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = '" . $table->getName() . "')\nBEGIN\n DECLARE @reftable_" . self::$dropCount . " nvarchar(60), @constraintname_" . self::$dropCount . " nvarchar(60)\n DECLARE refcursor CURSOR FOR\n select reftables.name tablename, cons.name constraintname\n from sysobjects tables,\n sysobjects reftables,\n sysobjects cons,\n sysreferences ref\n where tables.id = ref.rkeyid\n and cons.id = ref.constid\n and reftables.id = ref.fkeyid\n and tables.name = '" . $table->getName() . "'\n OPEN refcursor\n FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . "\n while @@FETCH_STATUS = 0\n BEGIN\n exec ('alter table '+@reftable_" . self::$dropCount . "+' drop constraint '+@constraintname_" . self::$dropCount . ")\n FETCH NEXT from refcursor into @reftable_" . self::$dropCount . ", @constraintname_" . self::$dropCount . "\n END\n CLOSE refcursor\n DEALLOCATE refcursor\n DROP TABLE " . $this->quoteIdentifier($table->getName()) . "\nEND\n";
return $ret;
}
示例3: 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 = array();
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();
}
}
示例4: buildDescription
protected function buildDescription()
{
if ($this->foreignTable === null) {
throw new \yentu\exceptions\DatabaseManipulatorException("No references defined for foreign key {$this->name}");
}
return array('columns' => $this->columns, 'table' => $this->table->getName(), 'schema' => $this->table->getSchema()->getName(), 'foreign_columns' => $this->foreignColumns, 'foreign_table' => $this->foreignTable->getName(), 'foreign_schema' => $this->foreignTable->getSchema()->getName(), 'name' => $this->name, 'on_delete' => $this->onDelete, 'on_update' => $this->onUpdate);
}
示例5: testGetName
public function testGetName()
{
$db = $this->getMockBuilder(Db::class)->disableOriginalConstructor()->getMock();
$tableName = 'language';
$table = new Table($db, $tableName);
$this->assertSame($tableName, $table->getName());
}
示例6: addGetLastVersions
protected function addGetLastVersions(&$script)
{
$versionTable = $this->behavior->getVersionTable();
$versionARClassname = $this->builder->getNewStubObjectBuilder($versionTable)->getClassname();
$versionForeignColumn = $versionTable->getColumn($this->behavior->getParameter('version_column'));
$fks = $versionTable->getForeignKeysReferencingTable($this->table->getName());
$relCol = $this->builder->getRefFKPhpNameAffix($fks[0], $plural = true);
$versionGetter = 'get' . $relCol;
$versionPeerBuilder = $this->builder->getNewStubPeerBuilder($versionTable);
$this->builder->declareClassFromBuilder($versionPeerBuilder);
$versionPeer = $versionPeerBuilder->getClassname();
$script .= <<<EOF
/**
* retrieve the last \$number versions.
*
* @param integer \$number the number of record to return.
* @param {$this->getVersionQueryClassName()}|Criteria \$criteria Additional criteria to filter.
* @param PropelPDO \$con An optional connection to use.
*
* @return PropelCollection|{$versionARClassname}[] List of {$versionARClassname} objects
*/
public function getLastVersions(\$number = 10, \$criteria = null, PropelPDO \$con = null)
{
\$criteria = {$this->getVersionQueryClassName()}::create(null, \$criteria);
\$criteria->addDescendingOrderByColumn({$versionPeer}::VERSION);
\$criteria->limit(\$number);
return \$this->{$versionGetter}(\$criteria, \$con);
}
EOF;
}
示例7: testTable
public function testTable()
{
$table = new Table($this->connection, 'foo_table', array('bar' => TableInterface::TYPE_INT), array());
$this->assertEquals('foo_table', $table->getName());
$this->assertEquals(array('bar' => TableInterface::TYPE_INT), $table->getColumns());
$this->assertEquals(array(), $table->getConnections());
$table->addConnection('bar', 'bar_table');
$this->assertEquals(array('bar' => 'bar_table'), $table->getConnections());
}
示例8: staticAttributes
public function staticAttributes($builder)
{
$tableName = $this->table->getName();
$script = "\n/**\n * rank column\n */\nconst RANK_COL = '" . $tableName . '.' . $this->getColumnConstant('rank_column') . "';\n";
if ($this->behavior->useScope()) {
if ($this->behavior->hasMultipleScopes()) {
foreach ($this->behavior->getScopes() as $scope) {
$col[] = "{$tableName}." . strtoupper($scope);
}
$col = json_encode($col);
$col = "'{$col}'";
$script .= "\n/**\n * If defined, the `SCOPE_COL` contains a json_encoded array with all columns.\n * @var boolean\n */\nconst MULTI_SCOPE_COL = true;\n";
} else {
$colNames = $this->getColumnConstant('scope_column');
$col = "'{$tableName}.{$colNames}'";
}
$script .= "\n/**\n * Scope column for the set\n */\nconst SCOPE_COL = {$col};\n";
}
return $script;
}
示例9: _getWhereQuery
/**
* Constructs where statement for retrieving row(s).
*
* @param bool $useDirty
* @return array
*/
protected function _getWhereQuery($useDirty = true)
{
$where = array();
$primaryKey = $this->_getPrimaryKey($useDirty);
$db = $this->_table->getAdapter();
$tableName = $db->quoteIdentifier($this->_table->getName(), true);
// retrieve recently updated row using primary keys
foreach ($primaryKey as $column => $value) {
$columnName = $db->quoteIdentifier($column, true);
$where[] = $db->quoteInto("{$tableName}.{$columnName} = ?", $value);
}
return $where;
}
示例10: __construct
/**
* @param Driver $driver
* @param Table $table
* @param Query $query
* @param bool $asArray
*/
public function __construct(Driver $driver, Table $table, Query $query, $asArray = false)
{
$this->asArray = $asArray;
$this->table = $table;
$params = [];
$this->tableName = $table->getName();
if (!$this->asArray) {
$this->recordClasses = [$this->tableName => $table->getDatabase()->getClassMapper()->getClassForRecord($this->tableName)];
}
$sql = $query->getRawSql();
if ($sql === null) {
$sql = $driver->buildSQL($table, $query, $params);
$this->fetchStyle = \PDO::FETCH_NUM;
foreach ($table->getColumns() as $column) {
if ($column->isPrimaryKey()) {
$this->primaryKeyOrdinals[$this->tableName][$column->getOrdinal()] = true;
}
$this->columnOrdinalMap[$this->tableName][$column->getOrdinal()] = $column->getName();
}
$offset = count($table->getColumns());
foreach ($query->getJoins() as $join) {
if (isset($join['cardinality'])) {
$joinedTableName = $join['table'];
$joinedTable = $table->getDatabase()->getTable($joinedTableName);
$this->joinedTables[$joinedTableName] = $joinedTable;
if (!$this->asArray) {
$this->recordClasses[$joinedTableName] = $joinedTable->getDatabase()->getClassMapper()->getClassForRecord($joinedTableName);
}
foreach ($joinedTable->getColumns() as $column) {
if ($column->isPrimaryKey()) {
$this->primaryKeyOrdinals[$joinedTableName][$offset + $column->getOrdinal()] = true;
}
$this->columnOrdinalMap[$joinedTableName][$offset + $column->getOrdinal()] = $column->getName();
}
$this->cardinalities[$joinedTableName] = $join['cardinality'];
if ($join['cardinality'] === Query::CARDINALITY_ONE_TO_MANY) {
$this->properties[$joinedTableName] = $joinedTableName;
} else {
$this->properties[$joinedTableName] = array_keys($join['on']);
}
$offset += count($joinedTable->getColumns());
}
}
} else {
$this->fetchStyle = \PDO::FETCH_ASSOC;
$this->rawSql = true;
}
$this->result = $driver->query($sql, $params);
$this->fetchNextRow();
}
示例11: computeAlter
/**
* @param Table $old
* @param Table $new
* @return bool|string
*/
public static function computeAlter(Table $old, Table $new)
{
$oldColumnNames = array_keys($old->getColumns());
$newColumnNames = array_keys($new->getColumns());
$alterLines = [];
// Check for changed columns
$possiblyChangedColumnNames = array_intersect($oldColumnNames, $newColumnNames);
foreach ($possiblyChangedColumnNames as $possiblyChangedColumnName) {
$oldColumn = $old->getColumn($possiblyChangedColumnName);
$newColumn = $new->getColumn($possiblyChangedColumnName);
if ($oldColumn && $newColumn) {
$alter = Column::computeAlter($oldColumn, $newColumn);
if ($alter) {
$alterLines[] = $alter;
}
}
}
// check if columns have been added
$addedColumnNames = array_diff($newColumnNames, $oldColumnNames);
foreach ($addedColumnNames as $added) {
$column = $new->getColumn($added);
$query = "ADD COLUMN " . $column;
if ($column->isFirst()) {
$query .= " FIRST";
} elseif ($column->getAfter() !== false) {
$query .= " AFTER `" . $column->getAfter() . "`";
}
$alterLines[] = $query;
}
// check if columns have been removed
$removedColumnNames = array_diff($oldColumnNames, $newColumnNames);
foreach ($removedColumnNames as $removedColumnName) {
$alterLines[] = "DROP COLUMN `" . $removedColumnName . "`";
}
if (!empty($alterLines)) {
return "ALTER TABLE `" . $new->getName() . "`\n\t" . implode(",\n\t", $alterLines);
}
return false;
}
示例12: getPrimaryKeyName
public function getPrimaryKeyName(Table $table)
{
$tableName = $table->getName();
// pk constraint name must be 30 chars at most
$tableName = substr($tableName, 0, min(27, strlen($tableName)));
return $tableName . '_PK';
}
示例13: getCultureColumn
/**
* Finds the supplied translation table's culture column.
*
* @return Column
*
* @throws InvalidArgumentException If there is not a column marked as "isCulture"
*/
protected function getCultureColumn(Table $table)
{
foreach ($table->getColumns() as $column) {
if ('true' == $column->getAttribute('isCulture')) {
return $column;
}
}
throw new InvalidArgumentException(sprintf('The table "%s" does not have a column marked with the "isCulture" attribute.', $table->getName()));
}
示例14: getDropTableDDL
public function getDropTableDDL(Table $table)
{
return "\nDROP TABLE IF EXISTS " . $this->quoteIdentifier($table->getName()) . ";\n";
}
示例15: getTableBaseIdentifier
/**
* Get the quoted identifier for the table name
* @param Table $table
* @return string
*/
public function getTableBaseIdentifier(Table $table)
{
return $this->quoteObjectIdentifier($table->getDatabase()->getPrefix() . $table->getName());
}