本文整理汇总了PHP中Cake\Database\Schema\Table::name方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::name方法的具体用法?PHP Table::name怎么用?PHP Table::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Database\Schema\Table
的用法示例。
在下文中一共展示了Table::name方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: truncateTableSql
public function truncateTableSql(Table $table)
{
$tableName = $table->name();
if ($this->_driver->autoQuoting()) {
$tableName = $this->_driver->quoteIdentifier($tableName);
}
return [sprintf("TRUNCATE TABLE %s", $tableName)];
}
示例2: dropTableSql
/**
* Generate the SQL to drop a table.
*
* @param \Cake\Database\Schema\Table $table Table instance
* @return array SQL statements to drop a table.
*/
public function dropTableSql(Table $table)
{
$sql = sprintf('DROP TABLE %s CASCADE', $this->_driver->quoteIdentifier($table->name()));
return [$sql];
}
示例3: truncateTableSql
/**
* {@inheritDoc}
*/
public function truncateTableSql(Table $table)
{
$name = $table->name();
$sql = [];
if ($this->hasSequences()) {
$sql[] = sprintf('DELETE FROM sqlite_sequence WHERE name="%s"', $name);
}
$sql[] = sprintf('DELETE FROM "%s"', $name);
return $sql;
}
示例4: column
/**
* Returns an array of column data for a single column
*
* @param \Cake\Database\Schema\Table $tableSchema Name of the table to retrieve columns for
* @param string $column A column to retrieve data for
* @return array
*/
public function column($tableSchema, $column)
{
return ['columnType' => $tableSchema->columnType($column), 'options' => $this->attributes($tableSchema->name(), $column)];
}
示例5: createTableSql
/**
* {@inheritDoc}
*/
public function createTableSql(Table $table, $columns, $constraints, $indexes)
{
$content = implode(",\n", array_merge($columns, $constraints, $indexes));
$temporary = $table->temporary() ? ' TEMPORARY ' : ' ';
$content = sprintf("CREATE%sTABLE `%s` (\n%s\n)", $temporary, $table->name(), $content);
$options = $table->options();
if (isset($options['engine'])) {
$content .= sprintf(' ENGINE=%s', $options['engine']);
}
if (isset($options['charset'])) {
$content .= sprintf(' DEFAULT CHARSET=%s', $options['charset']);
}
if (isset($options['collate'])) {
$content .= sprintf(' COLLATE=%s', $options['collate']);
}
return [$content];
}
示例6: dropConstraintSql
/**
* {@inheritDoc}
*/
public function dropConstraintSql(Table $table)
{
$sqlPattern = 'ALTER TABLE %s DROP FOREIGN KEY %s;';
$sql = [];
foreach ($table->constraints() as $name) {
$constraint = $table->constraint($name);
if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
$tableName = $this->_driver->quoteIdentifier($table->name());
$constraintName = $this->_driver->quoteIdentifier($name);
$sql[] = sprintf($sqlPattern, $tableName, $constraintName);
}
}
return $sql;
}
示例7: truncateTableSql
/**
* {@inheritDoc}
*/
public function truncateTableSql(Table $table)
{
$name = $this->_driver->quoteIdentifier($table->name());
return [sprintf('TRUNCATE TABLE %s', $name)];
}
示例8: truncateTableSql
/**
* {@inheritDoc}
*/
public function truncateTableSql(Table $table)
{
$name = $this->_driver->quoteIdentifier($table->name());
$queries = [sprintf('DELETE FROM %s', $name)];
// Restart identity sequences
$pk = $table->primaryKey();
if (count($pk) === 1) {
$column = $table->column($pk[0]);
if (in_array($column['type'], ['integer', 'biginteger'])) {
$queries[] = sprintf('DBCC CHECKIDENT(%s, RESEED, 0)', $name);
}
}
return $queries;
}
示例9: dropTableSql
/**
* Generate the SQL to drop a table.
*
* @param \Cake\Database\Schema\Table $table Table instance
* @return array SQL statements to drop a table.
*/
public function dropTableSql(Table $table)
{
$sql = sprintf('DROP TABLE %s CASCADE CONSTRAINTS', $this->_driver->quoteIfAutoQuote($table->name()));
return [$sql];
}
示例10: _generateDropForeignKeys
/**
* Generates SQL statements dropping foreign keys for the table.
*
* @param \Cake\Database\Connection $db Connection to run the SQL queries on.
* @param \Cake\Database\Schema\Table $table Drop foreign keys for this table.
* @return array List of SQL statements dropping foreign keys.
*/
protected function _generateDropForeignKeys($db, Schema $table)
{
$type = 'other';
if ($db->driver() instanceof Mysql) {
$type = 'mysql';
}
$queries = [];
foreach ($table->constraints() as $constraintName) {
$constraint = $table->constraint($constraintName);
if ($constraint['type'] === Schema::CONSTRAINT_FOREIGN) {
// TODO: Move this into the driver
if ($type === 'mysql') {
$template = 'ALTER TABLE %s DROP FOREIGN KEY %s';
} else {
$template = 'ALTER TABLE %s DROP CONSTRAINT %s';
}
$queries[] = sprintf($template, $table->name(), $constraintName);
}
}
return $queries;
}