Beispiel #1
0
 /**
  * createTable(argument) Execute the CREATE query
  *
  * @return bool
  */
 public function createTable($tablename, $connection = NULL)
 {
     $connection = DatabaseQuery::connect();
     try {
         $sqlQuery = self::sanitizeQuery($tablename);
         $query = $connection->prepare($sqlQuery);
         if ($query->execute()) {
             return true;
         }
     } catch (PDOException $e) {
         return $e->getMessage();
     }
 }
Beispiel #2
0
 /**
  * destroy($value)
  * Delete data from database
  *
  * @return bool
  */
 public function destroy($value, $dbConnection = NULL)
 {
     $connection = DatabaseQuery::checkConnection($dbConnection);
     $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = ' . $value);
     $query->execute();
     $check = $query->rowCount();
     if ($check) {
         return true;
     }
     throw new DataNotFoundException();
 }
 /**
  * getTableName()
  *
  * @return string
  */
 protected function getTableName($connection)
 {
     return DatabaseQuery::checkTableName($this->getClassName(), $connection);
 }