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$ 4,96
Dollar Venda R$ 4,97
Data 22/04/2026

April 2026
S M T W T F S
 1234
567891011
12131415161718
19202122232425
2627282930