CDbCommand Yii 1
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 |
Peterrlw says:
Delete,please!
adrianoApi says:
$command->delete(‘tbl_user’, ‘id=:id’, array(‘:id’=>1));