Search

Oct 12, 2015

Yii: Get all record by id - Cdbcommand Yii


// Get all record from archives table by IdUserCreate
    public function getAllByUserId($id) {
        $conn = Yii::app()->db;
        $conn->active = true; // Start connect
        $command = $conn->createCommand();
        $rows = $command->select('*')
            ->from('archives')
            ->where('IdUserCreate=:id', array(':id'=>$id))
            ->query();
        $result = $rows->readAll();
        $conn->active =  false; // Close connect
        return $result;
    }

No comments:

Post a Comment