Пример #1
0
 public function getJSONFromDB()
 {
     $db = new DBConnector();
     $sql = "SELECT s.spieltag, s.datum, sp.datum, sp.stadion, sp.heim, sp.gast, sp.tore_heim, sp.tore_gast FROM spieltag s, spiele sp WHERE s.spieltag = sp.spieltag_id";
     $mysql = $db->connect();
     $result = $mysql->query($sql);
     $json = array();
     while ($row = $result->fetch_assoc()) {
         $json[] = $row;
     }
     return $json;
 }
Пример #2
0
 /**
  * Instruct the database to generate a live connection
  *
  * @param array $parameters An map of parameters, which should include:
  *  - server: The server, eg, localhost
  *  - username: The username to log on with
  *  - password: The password to log on with
  *  - database: The database to connect to
  *  - charset: The character set to use. Defaults to utf8
  *  - timezone: (optional) The timezone offset. For example: +12:00, "Pacific/Auckland", or "SYSTEM"
  *  - driver: (optional) Driver name
  */
 public function connect($parameters)
 {
     // Ensure that driver is available (required by PDO)
     if (empty($parameters['driver'])) {
         $parameters['driver'] = $this->getDatabaseServer();
     }
     // Notify connector of parameters
     $this->connector->connect($parameters);
     // SS_Database subclass maintains responsibility for selecting database
     // once connected in order to correctly handle schema queries about
     // existence of database, error handling at the correct level, etc
     if (!empty($parameters['database'])) {
         $this->selectDatabase($parameters['database'], false, false);
     }
 }
Пример #3
0
<?php

/**
 * Created by PhpStorm.
 * User: Denis
 * Date: 30.11.2015
 * Time: 12:44
 */
$collection = new Collection();
$connection = new DBConnector();
$db = $connection->connect();
$sql = mysql_query("SELECT * FROM author", $db);
var_dump($sql);
$author_1 = new SimpleAuthor();