A command object is usually created by calling [[Connection::createCommand()]].
The SQL statement it represents can be set via the [[sql]] property.
To execute a non-query SQL (such as INSERT, REPLACE, DELETE, UPDATE), call [[execute()]].
To execute a SQL statement that returns result data set (such as SELECT, CALL SNIPPETS, CALL KEYWORDS),
use [[queryAll()]], [[queryOne()]], [[queryColumn()]], [[queryScalar()]], or [[query()]].
For example,
~~~
$articles = $connection->createCommand("SELECT * FROM idx_article WHERE MATCH('programming')")->queryAll();
~~~
Command supports SQL statement preparation and parameter binding just as Command does.
Command also supports building SQL statements by providing methods such as [[insert()]],
Command::update, etc. For example,
~~~
$connection->createCommand()->update('idx_article', [
'genre_id' => 15,
'author_id' => 157,
])->execute();
~~~
To build SELECT SQL statements, please use Query and QueryBuilder instead.