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,97
Dollar Venda R$ 5,97
Data 22/01/2025

January 2025
S M T W T F S
 1234
567891011
12131415161718
19202122232425
262728293031