Example #1
0
 /**
  * Executes an insert query against the database and returns the auto-increment id
  *
  * @param SqlCommand $command
  * @return long last id inserted for this connection
  */
 public function ExecuteInsert(ISqlCommand $command)
 {
     $this->Connection->Connect();
     //Log::Debug('Database::ExecuteInsert %s', $command->GetQuery());
     $this->Connection->Execute($command);
     $insertedId = $this->Connection->GetLastInsertId();
     $this->Connection->Disconnect();
     return $insertedId;
 }
Example #2
0
 /**
  * @param IDbConnection $connection
  * @throws \OC\DatabaseSetupException
  */
 private function createDBUser($connection)
 {
     $name = $this->dbUser;
     $password = $this->dbPassword;
     // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one,
     // the anonymous user would take precedence when there is one.
     $query = "CREATE USER '{$name}'@'localhost' IDENTIFIED BY '{$password}'";
     $connection->executeUpdate($query);
     $query = "CREATE USER '{$name}'@'%' IDENTIFIED BY '{$password}'";
     $connection->executeUpdate($query);
 }