Search

Oct 12, 2015

Yii: Insert new record to database - Cdbcommand

// Save to database
    public function save(){
        $conn = Yii::app()->db;
        $conn->active = true; // Start connect
        $command = $conn->createCommand();
        $command->insert('archives', array(
            'IdUserCreate' => $this->idUserCreate,
            'Name'=> $this->name,
            'Path'=> $this->path,
            'DateCreate' => $this->dateCreate,
        ));
        $conn->active =  false; // Close connect

    }

No comments:

Post a Comment