# Command

> Command represents an SQLite's SQL statement to be executed against a database.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [db](/docs/api/yii/db/index.md) › [sqlite](/docs/api/yii/db/sqlite/index.md) › Command

| class | `yii\db\sqlite\Command` |
| --- | --- |
| Extends | [`yii\db\Command`](/docs/api/yii/db/command/index.md) » [`yii\base\Component`](/docs/api/yii/base/component/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Since | 2.0.14 |
| Source | [`framework/db/sqlite/Command.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/db/sqlite/Command.php#L23) |

Command represents an SQLite's SQL statement to be executed against a database.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-behaviors"></span>[`$behaviors`](/docs/api/yii/base/component/index.md#property-behaviors) read-only | `array<`[`yii\base\Behavior`](/docs/api/yii/base/behavior/index.md)`<static>>` | List of behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="property-db"></span>[`$db`](/docs/api/yii/db/command/index.md#property-db) | [`yii\db\Connection`](/docs/api/yii/db/connection/index.md) | The DB connection that this command is associated with Default: `null`. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-fetchMode"></span>[`$fetchMode`](/docs/api/yii/db/command/index.md#property-fetchMode) | `int` | The default fetch mode for this command. Default: `\PDO::FETCH_ASSOC`. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-params"></span>[`$params`](/docs/api/yii/db/command/index.md#property-params) | `array` | The parameters (name => value) that are bound to the current PDO statement. Default: `[]`. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-pdoStatement"></span>[`$pdoStatement`](/docs/api/yii/db/command/index.md#property-pdoStatement) | [`PDOStatement`](https://www.php.net/manual/en/class.pdostatement.php)`\|null` | The PDOStatement object that this command is associated with Default: `null`. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-queryCacheDependency"></span>[`$queryCacheDependency`](/docs/api/yii/db/command/index.md#property-queryCacheDependency) | [`yii\caching\Dependency`](/docs/api/yii/caching/dependency/index.md) | The dependency to be associated with the cached query result for this command Default: `null`. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-queryCacheDuration"></span>[`$queryCacheDuration`](/docs/api/yii/db/command/index.md#property-queryCacheDuration) | `int` | The default number of seconds that query results can remain valid in cache. Default: `null`. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-rawSql"></span>[`$rawSql`](/docs/api/yii/db/command/index.md#property-rawSql) | `string` | The raw SQL with parameter values inserted into the corresponding placeholders in [`$sql`](/docs/api/yii/db/command/index.md#property-sql). | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-sql"></span>[`$sql`](/docs/api/yii/db/command/index.md#property-sql) | `string` | The SQL statement to be executed. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="property-pendingParams"></span>[`$pendingParams`](/docs/api/yii/db/command/index.md#property-pendingParams) protected | `array` | Pending parameters to be bound to the current PDO statement. Default: `[]`. Available since 2.0.33. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/component/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__clone"></span>[`__clone()`](/docs/api/yii/base/component/index.md#method-__clone) | This method is called after the object is created by cloning an existing one. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/component/index.md#method-__get) | Returns the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/component/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/component/index.md#method-__set) | Sets the value of a component property. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/component/index.md#method-__unset) | Sets a component property to be null. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-addCheck"></span>[`addCheck()`](/docs/api/yii/db/command/index.md#method-addCheck) | Creates a SQL command for adding a check constraint to an existing table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addColumn"></span>[`addColumn()`](/docs/api/yii/db/command/index.md#method-addColumn) | Creates a SQL command for adding a new DB column. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addCommentOnColumn"></span>[`addCommentOnColumn()`](/docs/api/yii/db/command/index.md#method-addCommentOnColumn) | Builds a SQL command for adding comment to column. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addCommentOnTable"></span>[`addCommentOnTable()`](/docs/api/yii/db/command/index.md#method-addCommentOnTable) | Builds a SQL command for adding comment to table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addDefaultValue"></span>[`addDefaultValue()`](/docs/api/yii/db/command/index.md#method-addDefaultValue) | Creates a SQL command for adding a default value constraint to an existing table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addForeignKey"></span>[`addForeignKey()`](/docs/api/yii/db/command/index.md#method-addForeignKey) | Creates a SQL command for adding a foreign key constraint to an existing table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addPrimaryKey"></span>[`addPrimaryKey()`](/docs/api/yii/db/command/index.md#method-addPrimaryKey) | Creates a SQL command for adding a primary key constraint to an existing table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-addUnique"></span>[`addUnique()`](/docs/api/yii/db/command/index.md#method-addUnique) | Creates a SQL command for adding an unique constraint to an existing table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-alterColumn"></span>[`alterColumn()`](/docs/api/yii/db/command/index.md#method-alterColumn) | Creates a SQL command for changing the definition of a column. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-attachBehavior"></span>[`attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) | Attaches a behavior to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-attachBehaviors"></span>[`attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) | Attaches a list of behaviors to the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-batchInsert"></span>[`batchInsert()`](/docs/api/yii/db/command/index.md#method-batchInsert) | Creates a batch INSERT command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-behaviors"></span>[`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) | Returns a list of behaviors that this component should behave as. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-bindParam"></span>[`bindParam()`](/docs/api/yii/db/command/index.md#method-bindParam) | Binds a parameter to the SQL statement to be executed. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-bindValue"></span>[`bindValue()`](/docs/api/yii/db/command/index.md#method-bindValue) | Binds a value to a parameter. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-bindValues"></span>[`bindValues()`](/docs/api/yii/db/command/index.md#method-bindValues) | Binds a list of values to the corresponding parameters. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-cache"></span>[`cache()`](/docs/api/yii/db/command/index.md#method-cache) | Enables query cache for this command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-cancel"></span>[`cancel()`](/docs/api/yii/db/command/index.md#method-cancel) | Cancels the execution of the SQL statement. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/component/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/component/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`checkIntegrity()`](#method-checkIntegrity) | Builds a SQL command for enabling or disabling integrity check. | `Command` |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-createIndex"></span>[`createIndex()`](/docs/api/yii/db/command/index.md#method-createIndex) | Creates a SQL command for creating a new index. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-createTable"></span>[`createTable()`](/docs/api/yii/db/command/index.md#method-createTable) | Creates a SQL command for creating a new DB table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-createView"></span>[`createView()`](/docs/api/yii/db/command/index.md#method-createView) | Creates a SQL View. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-delete"></span>[`delete()`](/docs/api/yii/db/command/index.md#method-delete) | Creates a DELETE command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-detachBehavior"></span>[`detachBehavior()`](/docs/api/yii/base/component/index.md#method-detachBehavior) | Detaches a behavior from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-detachBehaviors"></span>[`detachBehaviors()`](/docs/api/yii/base/component/index.md#method-detachBehaviors) | Detaches all behaviors from the component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-dropCheck"></span>[`dropCheck()`](/docs/api/yii/db/command/index.md#method-dropCheck) | Creates a SQL command for dropping a check constraint. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropColumn"></span>[`dropColumn()`](/docs/api/yii/db/command/index.md#method-dropColumn) | Creates a SQL command for dropping a DB column. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropCommentFromColumn"></span>[`dropCommentFromColumn()`](/docs/api/yii/db/command/index.md#method-dropCommentFromColumn) | Builds a SQL command for dropping comment from column. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropCommentFromTable"></span>[`dropCommentFromTable()`](/docs/api/yii/db/command/index.md#method-dropCommentFromTable) | Builds a SQL command for dropping comment from table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropDefaultValue"></span>[`dropDefaultValue()`](/docs/api/yii/db/command/index.md#method-dropDefaultValue) | Creates a SQL command for dropping a default value constraint. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropForeignKey"></span>[`dropForeignKey()`](/docs/api/yii/db/command/index.md#method-dropForeignKey) | Creates a SQL command for dropping a foreign key constraint. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropIndex"></span>[`dropIndex()`](/docs/api/yii/db/command/index.md#method-dropIndex) | Creates a SQL command for dropping an index. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropPrimaryKey"></span>[`dropPrimaryKey()`](/docs/api/yii/db/command/index.md#method-dropPrimaryKey) | Creates a SQL command for removing a primary key constraint to an existing table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropTable"></span>[`dropTable()`](/docs/api/yii/db/command/index.md#method-dropTable) | Creates a SQL command for dropping a DB table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropUnique"></span>[`dropUnique()`](/docs/api/yii/db/command/index.md#method-dropUnique) | Creates a SQL command for dropping an unique constraint. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-dropView"></span>[`dropView()`](/docs/api/yii/db/command/index.md#method-dropView) | Drops a SQL View. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-ensureBehaviors"></span>[`ensureBehaviors()`](/docs/api/yii/base/component/index.md#method-ensureBehaviors) | Makes sure that the behaviors declared in [`behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) are attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`execute()`](#method-execute) | Executes the SQL statement. | `Command` |
| <span id="method-executeResetSequence"></span>[`executeResetSequence()`](/docs/api/yii/db/command/index.md#method-executeResetSequence) | Executes a db command resetting the sequence value of a table's primary key. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-getBehavior"></span>[`getBehavior()`](/docs/api/yii/base/component/index.md#method-getBehavior) | Returns the named behavior object. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getBehaviors"></span>[`getBehaviors()`](/docs/api/yii/base/component/index.md#method-getBehaviors) | Returns all behaviors attached to this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-getRawSql"></span>[`getRawSql()`](/docs/api/yii/db/command/index.md#method-getRawSql) | Returns the raw SQL by inserting parameter values into the corresponding placeholders in [`$sql`](/docs/api/yii/db/command/index.md#property-sql). | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-getSql"></span>[`getSql()`](/docs/api/yii/db/command/index.md#method-getSql) | Returns the SQL statement for this command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-hasEventHandlers"></span>[`hasEventHandlers()`](/docs/api/yii/base/component/index.md#method-hasEventHandlers) | Returns a value indicating whether there is any handler attached to the named event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/component/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/component/index.md#method-hasProperty) | Returns a value indicating whether a property is defined for this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-init"></span>[`init()`](/docs/api/yii/base/baseobject/index.md#method-init) | Initializes the object. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-insert"></span>[`insert()`](/docs/api/yii/db/command/index.md#method-insert) | Creates an INSERT command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-noCache"></span>[`noCache()`](/docs/api/yii/db/command/index.md#method-noCache) | Disables query cache for this command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-off"></span>[`off()`](/docs/api/yii/base/component/index.md#method-off) | Detaches an existing event handler from this component. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-on"></span>[`on()`](/docs/api/yii/base/component/index.md#method-on) | Attaches an event handler to an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| [`prepare()`](#method-prepare) | Prepares the SQL statement to be executed. | `Command` |
| <span id="method-query"></span>[`query()`](/docs/api/yii/db/command/index.md#method-query) | Executes the SQL statement and returns query result. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-queryAll"></span>[`queryAll()`](/docs/api/yii/db/command/index.md#method-queryAll) | Executes the SQL statement and returns ALL rows at once. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-queryColumn"></span>[`queryColumn()`](/docs/api/yii/db/command/index.md#method-queryColumn) | Executes the SQL statement and returns the first column of the result. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-queryOne"></span>[`queryOne()`](/docs/api/yii/db/command/index.md#method-queryOne) | Executes the SQL statement and returns the first row of the result. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-queryScalar"></span>[`queryScalar()`](/docs/api/yii/db/command/index.md#method-queryScalar) | Executes the SQL statement and returns the value of the first column in the first row of data. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-renameColumn"></span>[`renameColumn()`](/docs/api/yii/db/command/index.md#method-renameColumn) | Creates a SQL command for renaming a column. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-renameTable"></span>[`renameTable()`](/docs/api/yii/db/command/index.md#method-renameTable) | Creates a SQL command for renaming a DB table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-resetSequence"></span>[`resetSequence()`](/docs/api/yii/db/command/index.md#method-resetSequence) | Creates a SQL command for resetting the sequence value of a table's primary key. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-setRawSql"></span>[`setRawSql()`](/docs/api/yii/db/command/index.md#method-setRawSql) | Specifies the SQL statement to be executed. The SQL statement will not be modified in any way. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-setSql"></span>[`setSql()`](/docs/api/yii/db/command/index.md#method-setSql) | Specifies the SQL statement to be executed. The SQL statement will be quoted using [`Connection::quoteSql()`](/docs/api/yii/db/connection/index.md#method-quoteSql). | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-trigger"></span>[`trigger()`](/docs/api/yii/base/component/index.md#method-trigger) | Triggers an event. | [`yii\base\Component`](/docs/api/yii/base/component/index.md) |
| <span id="method-truncateTable"></span>[`truncateTable()`](/docs/api/yii/db/command/index.md#method-truncateTable) | Creates a SQL command for truncating a DB table. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-update"></span>[`update()`](/docs/api/yii/db/command/index.md#method-update) | Creates an UPDATE command. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-upsert"></span>[`upsert()`](/docs/api/yii/db/command/index.md#method-upsert) | Creates a command to insert rows into a database table if they do not already exist (matching unique constraints), or update them if they do. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-bindPendingParams"></span>[`bindPendingParams()`](/docs/api/yii/db/command/index.md#method-bindPendingParams) protected | Binds pending parameters that were registered via [`bindValue()`](/docs/api/yii/db/command/index.md#method-bindValue) and [`bindValues()`](/docs/api/yii/db/command/index.md#method-bindValues). | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-getCacheKey"></span>[`getCacheKey()`](/docs/api/yii/db/command/index.md#method-getCacheKey) protected | Returns the cache key for the query. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-internalExecute"></span>[`internalExecute()`](/docs/api/yii/db/command/index.md#method-internalExecute) protected | Executes a prepared statement. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-logQuery"></span>[`logQuery()`](/docs/api/yii/db/command/index.md#method-logQuery) protected | Logs the current database query if query logging is enabled and returns the profiling token if profiling is enabled. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| [`queryInternal()`](#method-queryInternal) protected | Performs the actual DB query of a SQL statement. | `Command` |
| <span id="method-refreshTableSchema"></span>[`refreshTableSchema()`](/docs/api/yii/db/command/index.md#method-refreshTableSchema) protected | Refreshes table schema, which was marked by [`requireTableSchemaRefresh()`](/docs/api/yii/db/command/index.md#method-requireTableSchemaRefresh). | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-requireTableSchemaRefresh"></span>[`requireTableSchemaRefresh()`](/docs/api/yii/db/command/index.md#method-requireTableSchemaRefresh) protected | Marks a specified table schema to be refreshed after command execution. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| <span id="method-requireTransaction"></span>[`requireTransaction()`](/docs/api/yii/db/command/index.md#method-requireTransaction) protected | Marks the command to be executed in transaction. | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |
| [`reset()`](#method-reset) protected | Resets command properties to their initial state. | `Command` |
| <span id="method-setRetryHandler"></span>[`setRetryHandler()`](/docs/api/yii/db/command/index.md#method-setRetryHandler) protected | Sets a callable (e.g. anonymous function) that is called when [`Exception`](/docs/api/yii/db/exception/index.md) is thrown when executing the command. The signature of the callable should be: | [`yii\db\Command`](/docs/api/yii/db/command/index.md) |

## Method details

### checkIntegrity() <span id="method-checkIntegrity"></span>

```php
public function checkIntegrity(mixed $check = true, mixed $schema = '', mixed $table = ''): $this
```

Builds a SQL command for enabling or disabling integrity check.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$check` | `mixed` | Whether to turn on or off the integrity check. |
| `$schema` | `mixed` | The schema name of the tables. Defaults to empty string, meaning the current or default schema. |
| `$table` | `mixed` | The table name. |

**Returns**

`$this`: The command object itself

**Throws**

- [`yii\base\NotSupportedException`](/docs/api/yii/base/notsupportedexception/index.md): if this is not supported by the underlying DBMS

### execute() <span id="method-execute"></span>

```php
public function execute(): int
```

Executes the SQL statement.

This method should only be used for executing non-query SQL statement, such as `INSERT`, `DELETE`, `UPDATE` SQLs.
No result set will be returned.

**Returns**

`int`: Number of rows affected by the execution.

**Throws**

- [`yii\db\Exception`](/docs/api/yii/db/exception/index.md): execution failed

### prepare() <span id="method-prepare"></span>

```php
public function prepare(mixed $forRead = null): mixed
```

Prepares the SQL statement to be executed.

For complex SQL statement that is to be executed multiple times,
this may improve performance.
For SQL statement with binding parameters, this method is invoked
automatically.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$forRead` | `mixed` | Whether this method is called for a read query. If null, it means the SQL statement should be used to determine whether it is for read or write. |

**Returns**

`mixed`

**Throws**

- [`yii\db\Exception`](/docs/api/yii/db/exception/index.md): if there is any DB error

### queryInternal() <span id="method-queryInternal"></span>

```php
protected function queryInternal(mixed $method, mixed $fetchMode = null): mixed
```

Performs the actual DB query of a SQL statement.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$method` | `mixed` | Method of PDOStatement to be called |
| `$fetchMode` | `mixed` | The result fetch mode. Please refer to [PHP manual](https://www.php.net/manual/en/function.PDOStatement-setFetchMode.php) for valid fetch modes. If this parameter is null, the value set in [`$fetchMode`](/docs/api/yii/db/command/index.md#property-fetchMode) will be used. |

**Returns**

`mixed`: The method execution result

**Throws**

- [`yii\db\Exception`](/docs/api/yii/db/exception/index.md): if the query causes any problem

### reset() <span id="method-reset"></span>

```php
protected function reset(): mixed
```

Resets command properties to their initial state.

**Returns**

`mixed`

**Since**

2.0.13