コード例 #1
0
ファイル: DataTable.php プロジェクト: midmike/h0001pre
 /**
  * Execute an SQL query on the database
  *
  * @param  resource $db  Database handler
  * @param  array    $bindings Array of PDO binding values from bind() to be
  *   used for safely escaping strings. Note that this can be given as the
  *   SQL query string if no bindings are required.
  * @param  string   $sql SQL query to execute.
  * @return array         Result from the query (all rows)
  */
 static function sql_exec($bindings, $sql = null)
 {
     // Argument shifting
     if ($sql === null) {
         $sql = $bindings;
     }
     //$stmt = $db->prepare( $sql );
     //echo $sql;
     $result = DatabaseHandler::Prepare($sql);
     // Bind parameters
     if (is_array($bindings)) {
         $result = DatabaseHandler::GetAllWithBinding($result, $bindings, PDO::FETCH_BOTH);
     } else {
         $result = DatabaseHandler::GetAll($result, null, PDO::FETCH_BOTH);
     }
     // Return all
     return $result;
 }