public function __construct($host, $user, $password, $database = "mysqlslideshow", $table = "mysqlslideshow") { $database = is_null($database) ? 'mysqlslideshow' : $database; $table = is_null($table) ? 'mysqlslideshow' : $table; $this->table = $table; // Call the Database constructor parent::__construct($host, $user, $password, $database); // open the database }
/** * query() * Query database table * @param string $query SQL statement. * @return mixed result-set for select etc, true/false for insert etc. * On error calls SqlError() and exits. */ public function query($query) { $db = $this->opendb(); self::$lastQuery = $query; // for debugging $result = $db->query($query); if ($result === false) { throw new SqlException($query, $this); } if ($result === true) { // did not return a result object $numrows = $db->affected_rows; self::$lastNonSelectResult = $result; } else { // NOTE: we don't change result for inserts etc. only for selects etc. $this->result = $result; $numrows = $result->num_rows; } return $numrows; }