20.11.2014 Views

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The truncateTable method builds and executes a SQL statement for truncating a table.<br />

The $table parameter specifies the name of the table to be truncated. The query builder<br />

will quote the table name properly.<br />

Below is an example showing how to truncate a table:<br />

// TRUNCATE TABLE `tbl_user`<br />

truncateTable('tbl_user')<br />

addColumn<br />

function addColumn($table, $column, $type)<br />

The addColumn method builds and executes a SQL statement for adding a new table<br />

column. The $table parameter specifies the name of the table that the new column will be<br />

added to. The $column parameter specifies the name of the new column. And $type<br />

specifies the definition of the new column. Column definition can contain abstract data<br />

type, as described in the subsection of "createTable". The query builder will quote the table<br />

name as well as the column name properly.<br />

Below is an example showing how to add a table column:<br />

// ALTER TABLE `tbl_user` ADD `email` varchar(255) NOT NULL<br />

addColumn('tbl_user', 'email', 'string NOT NULL')<br />

dropColumn<br />

function dropColumn($table, $column)<br />

The dropColumn method builds and executes a SQL statement for dropping a table<br />

column. The $table parameter specifies the name of the table whose column is to be<br />

dropped. The $column parameter specifies the name of the column to be dropped. The<br />

query builder will quote the table name as well as the column name properly.<br />

Below is an example showing how to drop a table column:<br />

// ALTER TABLE `tbl_user` DROP COLUMN `location`<br />

dropColumn('tbl_user', 'location')<br />

renameColumn<br />

function renameColumn($table, $name, $newName)<br />

The renameColumn method builds and executes a SQL statement for renaming a table<br />

column. The $table parameter specifies the name of the table whose column is to be<br />

renamed. The $name parameter specifies the old column name. And $newName specifies

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!