Find us on facebook

Showing posts with label CreateCommand. Show all posts
Showing posts with label CreateCommand. Show all posts

Jul 17, 2014

Insert Update Delete with createCommand in yii

public function assignVehicle($driver_id=null,$vehicle_id=null)
{
$sql = "UPDATE `drivers` SET `vehical_id`=$vehicle_id WHERE id=:driver_id";

$parameters = array(":driver_id"=>$driver_id);


Yii::app()->db->createCommand($sql)->execute($parameters);

}

public function insertCharges($area_id=null,$charge=null){



$sql = "insert into delivery_charge (`area_id`,`charge`) values (:area_id,:charge)";

$parameters = array(":area_id"=>$area_id,":charge"=>$charge);


Yii::app()->db->createCommand($sql)->execute($parameters);



}

$sql = "delete from `AuthItemChild` where parent=:parent AND child=:child";

  $parameters = array(":parent"=>$parent,":child"=>$child);


  Yii::app()->db->createCommand($sql)->execute($parameters);