CDbCommand Yii 1


yii framework

A good practice of programming is to use “statement”, to do CRUD actions in a safe and scalable way. The Yii framework has by default its library for ease of development.

SELECT

$user = Yii::app()->db->createCommand()
    ->select('username, password')
    ->from('tbl_user')
    ->where('id=:id', array(':id'=>1))
    ->queryRow();

Queryng with the template referencing the primary key:

Sites::model()->findByPk($site_id);

INSERT

$command->insert('tbl_user', array(
    'name'=>'Tester',
    'email'=>'tester@example.com',
));

DELETE

$command->delete('tbl_user', 'id=:id', array(':id'=>1));


Moeda Tipo Valor
Dollar Compra R$ 5,03
Dollar Venda R$ 5,03
Data 21/10/2026

October 2026
S M T W T F S
 123
45678910
11121314151617
18192021222324
25262728293031