Beispiel #1
0
 private function runDbScript()
 {
     try {
         $connection = new CDbConnection("{$this->dbDriver}:host={$this->dbHost};dbname={$this->dbName}", $this->dbUser, $this->dbPassword);
         $connection->active = true;
         $sqlFile = Yii::getPathOfAlias('webroot.protected.data') . '/schema.mysql.sql';
         $sql = file_get_contents($sqlFile);
         $connection->beginTransaction();
         $connection->createCommand("SET CHARACTER SET utf8")->execute();
         $command = $connection->createCommand($sql);
         $command->execute(array(':username' => $this->username, ':salt' => $salt = substr(md5(uniqid(rand(), true)), 0, 9), ':password' => sha1($salt . sha1($salt . sha1($this->password))), ':email' => $this->email));
         $connection->getCurrentTransaction()->commit();
         $connection->active = false;
         return true;
     } catch (Exception $ex) {
         return false;
     }
 }
 public function commit()
 {
     //        $this->db->flush();
     $this->db->getCurrentTransaction()->commit();
 }