#3 docu db
This commit is contained in:
parent
82dc71547c
commit
014da5c539
@ -1,10 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection Class provided by System to open a Connection to a Database.
|
||||||
|
*/
|
||||||
class Connection extends ConnectionAbstr{
|
class Connection extends ConnectionAbstr{
|
||||||
//The open Connection
|
/** ressource Variable to store then open Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
|
|
||||||
//Connects to DB, dependent on DBInfo a connection will be established
|
/**
|
||||||
|
* Connect to the DB upon Construction.
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Information Object or Null for default Connection
|
||||||
|
*/
|
||||||
public function __construct(DBInfo $dbinfo = null){
|
public function __construct(DBInfo $dbinfo = null){
|
||||||
if(!$dbinfo){
|
if(!$dbinfo){
|
||||||
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
||||||
@ -21,28 +39,62 @@ class Connection extends ConnectionAbstr{
|
|||||||
throw new \Exception('Could not understand Database Settings. Check ur Database Settings');}
|
throw new \Exception('Could not understand Database Settings. Check ur Database Settings');}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Destruct connection object.
|
/**
|
||||||
|
* Destruct the Database Connection upon Destruction.
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
unset($this->connection);}
|
unset($this->connection);}
|
||||||
|
|
||||||
//Query connected Database with prepared statements, $stmt = sql string with ?; $values = array of values
|
/**
|
||||||
public function prepare($stmtName, $stmt, $values){
|
* Close the Database Connection.
|
||||||
return $this->connection->prepare($stmtName, $stmt, $values);}
|
*
|
||||||
|
* @return bool Returns true or false depending on success
|
||||||
//Close Connection
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
return $this->connection->close();}
|
return $this->connection->close();}
|
||||||
|
|
||||||
//Query connected Database
|
/**
|
||||||
|
* Query the Connection using Prepare Statement
|
||||||
|
*
|
||||||
|
* @param string $stmtName Name of the Statement - espec for PostgreSQL important
|
||||||
|
* @param string $stmt SQL string of the Statement
|
||||||
|
* @param array $values Array of Prepare Values
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
public function prepare($stmtName, $stmt, $values){
|
||||||
|
return $this->connection->prepare($stmtName, $stmt, $values);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the Connection using normal Query Statement
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function query($query){
|
public function query($query){
|
||||||
return $this->connection->query($query);}
|
return $this->connection->query($query);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec Query on Database
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function exec($query){
|
public function exec($query){
|
||||||
return $this->connection->exec($query);}
|
return $this->connection->exec($query);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function trans(){
|
public function trans(){
|
||||||
return $this->connection->trans();}
|
return $this->connection->trans();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function commit(){
|
public function commit(){
|
||||||
return $this->connection->commit();}
|
return $this->connection->commit();}
|
||||||
}
|
}
|
||||||
@ -1,11 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AMQP Connection Class provided by System to connect to AMQP Services.
|
||||||
|
*/
|
||||||
class ConnectionAMQP extends ConnectionAbstr {
|
class ConnectionAMQP extends ConnectionAbstr {
|
||||||
|
/** ressource Variable to store then open Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to the DB upon Construction.
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Information Object
|
||||||
|
*/
|
||||||
public function __construct(DBInfo $dbinfo){
|
public function __construct(DBInfo $dbinfo){
|
||||||
$this->connection = new \AMQPConnection(
|
$this->connection = new \AMQPConnection(
|
||||||
array(
|
array(
|
||||||
@ -22,6 +39,12 @@ class ConnectionAMQP extends ConnectionAbstr {
|
|||||||
throw new \SYSTEM\LOG\ERROR('Cannot connect to the amqp queue!');}
|
throw new \SYSTEM\LOG\ERROR('Cannot connect to the amqp queue!');}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a Message to the AMQP Server
|
||||||
|
*
|
||||||
|
* @param array $msg Query Object
|
||||||
|
* @return null Retuns null or trows an Error
|
||||||
|
*/
|
||||||
public function send($msg){
|
public function send($msg){
|
||||||
$channel = new \AMQPChannel($this->connection);
|
$channel = new \AMQPChannel($this->connection);
|
||||||
$exchange = new \AMQPExchange($channel);
|
$exchange = new \AMQPExchange($channel);
|
||||||
@ -45,22 +68,65 @@ class ConnectionAMQP extends ConnectionAbstr {
|
|||||||
$channel->commitTransaction();
|
$channel->commitTransaction();
|
||||||
|
|
||||||
if(!$message) {
|
if(!$message) {
|
||||||
throw new \SYSTEM\LOG\ERROR("Error: Message '".$message."' was not sent to queue.!");
|
throw new \SYSTEM\LOG\ERROR("Error: Message '".$message."' was not sent to queue.!");}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destruct the Database Connection upon Destruction.
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();
|
$this->close();}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the Database Connection.
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
if (!$this->connection->disconnect()) {
|
return $this->connection->disconnect();}
|
||||||
throw new Exception("Could not disconnect !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function query($query){ }
|
/**
|
||||||
|
* Query the Connection using normal Query Statement
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
public function query($query){
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
|
|
||||||
public function prepare($stmtName, $stmt, $values){}
|
/**
|
||||||
|
* Query the Connection using Prepare Statement
|
||||||
|
*
|
||||||
|
* @param string $stmtName Name of the Statement - espec for PostgreSQL important
|
||||||
|
* @param string $stmt SQL string of the Statement
|
||||||
|
* @param array $values Array of Prepare Values
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
public function prepare($stmtName, $stmt, $values){
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
|
public function commit(){
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec Query on Database
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
public function exec($query){
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
|
public function trans(){
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
}
|
}
|
||||||
@ -1,29 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract Connection Class provided by System as a PDO Controller.
|
||||||
|
*/
|
||||||
abstract class ConnectionAbstr {
|
abstract class ConnectionAbstr {
|
||||||
//Connects to Database with given DBInfos
|
/**
|
||||||
|
* Connect to the DB upon Construction.
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Information Object
|
||||||
|
*/
|
||||||
abstract public function __construct(DBInfo $dbinfo);
|
abstract public function __construct(DBInfo $dbinfo);
|
||||||
//Close Connection to Database
|
|
||||||
|
/**
|
||||||
|
* Destruct the Database Connection upon Destruction.
|
||||||
|
*/
|
||||||
abstract public function __destruct();
|
abstract public function __destruct();
|
||||||
//Close Connection to Database
|
|
||||||
|
/**
|
||||||
|
* Close the Database Connection.
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success
|
||||||
|
*/
|
||||||
abstract public function close();
|
abstract public function close();
|
||||||
//Query Database with prepared Statement with $stmtName = name of the stament(pg only) $stmt = string and $values = array()
|
|
||||||
|
/**
|
||||||
|
* Query the Connection using Prepare Statement
|
||||||
|
*
|
||||||
|
* @param string $stmtName Name of the Statement - espec for PostgreSQL important
|
||||||
|
* @param string $stmt SQL string of the Statement
|
||||||
|
* @param array $values Array of Prepare Values
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
abstract public function prepare($stmtName, $stmt, $values);
|
abstract public function prepare($stmtName, $stmt, $values);
|
||||||
//Query Database with normal Statement with $query = SQLString
|
|
||||||
|
/**
|
||||||
|
* Query the Connection using normal Query Statement
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
abstract public function query($query);
|
abstract public function query($query);
|
||||||
abstract public function commit();
|
|
||||||
|
/**
|
||||||
|
* Exec Query on Database
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
abstract public function exec($query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
abstract public function trans();
|
abstract public function trans();
|
||||||
//Convert Prepared Values to SQL Type identifiers
|
|
||||||
|
/**
|
||||||
|
* Commit a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
|
abstract public function commit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helperfunction to convert Prepared Values to SQL Type identifiers
|
||||||
|
*
|
||||||
|
* @param string $value Value to be examined regarding Type
|
||||||
|
* @return string Returns d,i,s or b depending on the values type.
|
||||||
|
*/
|
||||||
protected static function getPrepareValueType($value){
|
protected static function getPrepareValueType($value){
|
||||||
if(is_double($value)){
|
if(is_double($value)){return 'd';}
|
||||||
return 'd';}
|
if(is_integer($value)){return 'i';}
|
||||||
if(is_integer($value)){
|
if(is_string($value)){return 's';}
|
||||||
return 'i';}
|
return 'b';//blob
|
||||||
if(is_string($value)){
|
|
||||||
return 's';}
|
|
||||||
//blob
|
|
||||||
return 'b';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MYSQL Connection Class provided by System to connect to MYSQL Database.
|
||||||
|
*/
|
||||||
class ConnectionMYS extends ConnectionAbstr {
|
class ConnectionMYS extends ConnectionAbstr {
|
||||||
|
/** ressource Variable to store then open Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to the DB upon Construction.
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Information Object
|
||||||
|
* @param bool $new_link Force new Connection
|
||||||
|
* @param int $client_flag Client Flag transmitted on connection
|
||||||
|
*/
|
||||||
public function __construct(DBInfo $dbinfo, $new_link = false, $client_flag = 0){
|
public function __construct(DBInfo $dbinfo, $new_link = false, $client_flag = 0){
|
||||||
$this->connection = @mysqli_connect($dbinfo->m_host, $dbinfo->m_user, $dbinfo->m_password, $new_link, $client_flag);
|
$this->connection = @mysqli_connect($dbinfo->m_host, $dbinfo->m_user, $dbinfo->m_password, $new_link, $client_flag);
|
||||||
if(!$this->connection){
|
if(!$this->connection){
|
||||||
@ -15,9 +37,28 @@ class ConnectionMYS extends ConnectionAbstr {
|
|||||||
\mysqli_set_charset($this->connection, 'utf8');
|
\mysqli_set_charset($this->connection, 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destruct the Database Connection upon Destruction.
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the Database Connection.
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success
|
||||||
|
*/
|
||||||
|
public function close(){
|
||||||
|
return mysqli_close($this->connection);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the Connection using Prepare Statement
|
||||||
|
*
|
||||||
|
* @param string $stmtName Name of the Statement - espec for PostgreSQL important
|
||||||
|
* @param string $stmt SQL string of the Statement
|
||||||
|
* @param array $values Array of Prepare Values
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function prepare($stmtName, $stmt, $values){
|
public function prepare($stmtName, $stmt, $values){
|
||||||
$prepStmt = \mysqli_prepare($this->connection, $stmt);
|
$prepStmt = \mysqli_prepare($this->connection, $stmt);
|
||||||
if(!$prepStmt){
|
if(!$prepStmt){
|
||||||
@ -37,29 +78,45 @@ class ConnectionMYS extends ConnectionAbstr {
|
|||||||
return new ResultMysqliPrepare($prepStmt,$this);
|
return new ResultMysqliPrepare($prepStmt,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(){
|
/**
|
||||||
return mysqli_close($this->connection);}
|
* Query the Connection using normal Query Statement
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function query($query){
|
public function query($query){
|
||||||
$result = \mysqli_query($this->connection, $query);
|
$result = \mysqli_query($this->connection, $query);
|
||||||
if(!$result){
|
if(!$result){
|
||||||
throw new \Exception('Could not query Database. Check ur Query Syntax or required Rights: '.\mysqli_error($this->connection));}
|
throw new \Exception('Could not query Database. Check ur Query Syntax or required Rights: '.\mysqli_error($this->connection));}
|
||||||
|
return $result === true ? $result : new ResultMysqli($result);
|
||||||
if($result === TRUE){
|
|
||||||
return TRUE;}
|
|
||||||
|
|
||||||
return new ResultMysqli($result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec Query on Database
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
public function exec($query){
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function commit(){
|
public function commit(){
|
||||||
if(!\mysqli_commit($this->connection)){
|
if(!\mysqli_commit($this->connection)){
|
||||||
throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));}
|
throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));}
|
||||||
return true;
|
return true;}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function trans(){
|
public function trans(){
|
||||||
if(!\mysqli_begin_transaction($this->connection,MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT)){
|
if(!\mysqli_begin_transaction($this->connection,MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT)){
|
||||||
throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));}
|
throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));}
|
||||||
return true;
|
return true;}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,23 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PostgreSQL Connection Class provided by System to connect to PostgreSQL Database.
|
||||||
|
*/
|
||||||
class ConnectionPG extends ConnectionAbstr {
|
class ConnectionPG extends ConnectionAbstr {
|
||||||
|
/** ressource Variable to store then open Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
//private $dbinfo = NULL;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to the DB upon Construction.
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Information Object
|
||||||
|
*/
|
||||||
public function __construct(DBInfo $dbinfo){
|
public function __construct(DBInfo $dbinfo){
|
||||||
//$this->dbinfo = $dbinfo;
|
|
||||||
|
|
||||||
$this->connection = pg_connect("host=".$dbinfo->m_host." port=".$dbinfo->m_port." dbname=".$dbinfo->m_database."
|
$this->connection = pg_connect("host=".$dbinfo->m_host." port=".$dbinfo->m_port." dbname=".$dbinfo->m_database."
|
||||||
user=".$dbinfo->m_user." password=".$dbinfo->m_password."");
|
user=".$dbinfo->m_user." password=".$dbinfo->m_password."");
|
||||||
if(!$this->connection){
|
if(!$this->connection){
|
||||||
throw new \Exception('Could not connect to Database. Check ur Database Settings');}
|
throw new \Exception('Could not connect to Database. Check ur Database Settings');}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destruct the Database Connection upon Destruction.
|
||||||
|
*/
|
||||||
public function __destruct(){}
|
public function __destruct(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the Database Connection.
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success
|
||||||
|
*/
|
||||||
|
public function close(){
|
||||||
|
return pg_close($this->connection);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the Connection using Prepare Statement
|
||||||
|
*
|
||||||
|
* @param string $stmtName Name of the Statement - espec for PostgreSQL important
|
||||||
|
* @param string $stmt SQL string of the Statement
|
||||||
|
* @param array $values Array of Prepare Values
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function prepare($stmtName, $stmt, $values){
|
public function prepare($stmtName, $stmt, $values){
|
||||||
$result = pg_query_params($this->connection, 'SELECT name FROM pg_prepared_statements WHERE name = $1', array($stmtName));
|
$result = pg_query_params($this->connection, 'SELECT name FROM pg_prepared_statements WHERE name = $1', array($stmtName));
|
||||||
//var_dump($stmt);
|
//var_dump($stmt);
|
||||||
@ -41,9 +74,12 @@ class ConnectionPG extends ConnectionAbstr {
|
|||||||
return new ResultPostgres($result,$this);
|
return new ResultPostgres($result,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(){
|
/**
|
||||||
return pg_close($this->connection);}
|
* Query the Connection using normal Query Statement
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function query($query){
|
public function query($query){
|
||||||
$result = \pg_query($this->connection, $query);
|
$result = \pg_query($this->connection, $query);
|
||||||
if(($info = \pg_last_notice($this->connection)) != ''){
|
if(($info = \pg_last_notice($this->connection)) != ''){
|
||||||
@ -58,10 +94,28 @@ class ConnectionPG extends ConnectionAbstr {
|
|||||||
return new ResultPostgres($result,$this);
|
return new ResultPostgres($result,$this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function trans(){
|
public function trans(){
|
||||||
return $this->connection->trans();}
|
return $this->connection->trans();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function commit(){
|
public function commit(){
|
||||||
return $this->connection->commit();}
|
return $this->connection->commit();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec Query on Database
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
|
public function exec($query) {
|
||||||
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
}
|
}
|
||||||
@ -1,20 +1,57 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQLite Connection Class provided by System to connect to SQLite Databasefile.
|
||||||
|
*/
|
||||||
class ConnectionSQLite extends ConnectionAbstr {
|
class ConnectionSQLite extends ConnectionAbstr {
|
||||||
|
/** ressource Variable to store the open Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
|
|
||||||
public function __construct(DBInfo $dbinfo, $new_link = false, $client_flag = 0){
|
/**
|
||||||
|
* Connect to the DB upon Construction.
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Information Object
|
||||||
|
*/
|
||||||
|
public function __construct(DBInfo $dbinfo){
|
||||||
$error = null;
|
$error = null;
|
||||||
$this->connection = new \SQLite3($dbinfo->m_database);
|
$this->connection = new \SQLite3($dbinfo->m_database);
|
||||||
if(!$this->connection){
|
if(!$this->connection){
|
||||||
throw new \Exception('Could not connect to Database. Check ur Database Settings: '.$error);}
|
throw new \Exception('Could not connect to Database. Check ur Database Settings: '.$error);}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destruct the Database Connection upon Destruction.
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the Database Connection.
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success
|
||||||
|
*/
|
||||||
|
public function close(){
|
||||||
|
return $this->connection->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the Connection using Prepare Statement
|
||||||
|
*
|
||||||
|
* @param string $stmtName Name of the Statement - espec for PostgreSQL important
|
||||||
|
* @param string $stmt SQL string of the Statement
|
||||||
|
* @param array $values Array of Prepare Values
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function prepare($stmtName, $stmt, $values){
|
public function prepare($stmtName, $stmt, $values){
|
||||||
$prepStmt = $this->connection->prepare($stmt);
|
$prepStmt = $this->connection->prepare($stmt);
|
||||||
if(!$prepStmt){
|
if(!$prepStmt){
|
||||||
@ -29,9 +66,12 @@ class ConnectionSQLite extends ConnectionAbstr {
|
|||||||
return new ResultSQLite($result,$prepStmt);
|
return new ResultSQLite($result,$prepStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(){
|
/**
|
||||||
return $this->connection->close();}
|
* Query the Connection using normal Query Statement
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function query($query){
|
public function query($query){
|
||||||
$result = $this->connection->query($query);
|
$result = $this->connection->query($query);
|
||||||
if(!$result){
|
if(!$result){
|
||||||
@ -42,13 +82,28 @@ class ConnectionSQLite extends ConnectionAbstr {
|
|||||||
return new ResultSQLite($result,null);
|
return new ResultSQLite($result,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exec Query on Database
|
||||||
|
*
|
||||||
|
* @param string $query SQL string of the Statement
|
||||||
|
* @return Result Returns Database Query Result.
|
||||||
|
*/
|
||||||
public function exec($query){
|
public function exec($query){
|
||||||
return $this->connection->exec($query);
|
return $this->connection->exec($query);}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function commit(){
|
public function commit(){
|
||||||
throw new \Exception('Could not start Transaction: not implemented');}
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a Transaction on the Database Connection
|
||||||
|
*
|
||||||
|
* @return bool Returns true or false depending on success.
|
||||||
|
*/
|
||||||
public function trans(){
|
public function trans(){
|
||||||
throw new \Exception('Could not start Transaction: not implemented');}
|
throw new \Exception('Could not start Transaction: not implemented');}
|
||||||
}
|
}
|
||||||
@ -1,13 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBInfo Abstract Class provided by System to hold Database Information.
|
||||||
|
*/
|
||||||
abstract class DBInfo {
|
abstract class DBInfo {
|
||||||
|
/** string Variable to store Database name */
|
||||||
public $m_database = null;
|
public $m_database = null;
|
||||||
|
/** string Variable to store Database user */
|
||||||
public $m_user = null;
|
public $m_user = null;
|
||||||
|
/** string Variable to store Database password */
|
||||||
public $m_password = null;
|
public $m_password = null;
|
||||||
|
/** string Variable to store Database host */
|
||||||
public $m_host = null;
|
public $m_host = null;
|
||||||
|
/** int Variable to store Database port */
|
||||||
public $m_port = null;
|
public $m_port = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store Data upon Construction.
|
||||||
|
*
|
||||||
|
* @param string $database Database name
|
||||||
|
* @param string $user Database user
|
||||||
|
* @param string $password Database password
|
||||||
|
* @param string $host Database host
|
||||||
|
* @param int $port Database port
|
||||||
|
*/
|
||||||
abstract public function __construct($database , $user , $password, $host, $port = null);
|
abstract public function __construct($database , $user , $password, $host, $port = null);
|
||||||
}
|
}
|
||||||
@ -1,8 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBInfoAMQP Class provided by System to hold AMQP Database Information.
|
||||||
|
*/
|
||||||
class DBInfoAMQP extends \SYSTEM\DB\DBInfo {
|
class DBInfoAMQP extends \SYSTEM\DB\DBInfo {
|
||||||
|
/**
|
||||||
|
* Store Data upon Construction.
|
||||||
|
*
|
||||||
|
* @param string $database Database name
|
||||||
|
* @param string $user Database user
|
||||||
|
* @param string $password Database password
|
||||||
|
* @param string $host Database host
|
||||||
|
* @param int $port Database port
|
||||||
|
*/
|
||||||
public function __construct($vhost , $user , $password, $host, $port = null){
|
public function __construct($vhost , $user , $password, $host, $port = null){
|
||||||
$this->m_database = $vhost;
|
$this->m_database = $vhost;
|
||||||
$this->m_user = $user;
|
$this->m_user = $user;
|
||||||
|
|||||||
@ -1,8 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBInfoMYS Class provided by System to hold MYSQL Database Information.
|
||||||
|
*/
|
||||||
class DBInfoMYS extends \SYSTEM\DB\DBInfo {
|
class DBInfoMYS extends \SYSTEM\DB\DBInfo {
|
||||||
|
/**
|
||||||
|
* Store Data upon Construction.
|
||||||
|
*
|
||||||
|
* @param string $database Database name
|
||||||
|
* @param string $user Database user
|
||||||
|
* @param string $password Database password
|
||||||
|
* @param string $host Database host
|
||||||
|
* @param int $port Database port
|
||||||
|
*/
|
||||||
public function __construct($database , $user , $password, $host, $port = null){
|
public function __construct($database , $user , $password, $host, $port = null){
|
||||||
$this->m_database = $database;
|
$this->m_database = $database;
|
||||||
$this->m_user = $user;
|
$this->m_user = $user;
|
||||||
|
|||||||
@ -1,8 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBInfoPG Class provided by System to hold PostgreSQL Database Information.
|
||||||
|
*/
|
||||||
class DBInfoPG extends \SYSTEM\DB\DBInfo {
|
class DBInfoPG extends \SYSTEM\DB\DBInfo {
|
||||||
|
/**
|
||||||
|
* Store Data upon Construction.
|
||||||
|
*
|
||||||
|
* @param string $database Database name
|
||||||
|
* @param string $user Database user
|
||||||
|
* @param string $password Database password
|
||||||
|
* @param string $host Database host
|
||||||
|
* @param int $port Database port
|
||||||
|
*/
|
||||||
public function __construct($database , $user , $password, $host, $port = null){
|
public function __construct($database , $user , $password, $host, $port = null){
|
||||||
$this->m_database = $database;
|
$this->m_database = $database;
|
||||||
$this->m_user = $user;
|
$this->m_user = $user;
|
||||||
|
|||||||
@ -1,7 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DBInfoSQLite Class provided by System to hold SQLite File-Database Information.
|
||||||
|
*/
|
||||||
class DBInfoSQLite extends \SYSTEM\DB\DBInfo {
|
class DBInfoSQLite extends \SYSTEM\DB\DBInfo {
|
||||||
|
/**
|
||||||
|
* Store Data upon Construction.
|
||||||
|
*
|
||||||
|
* @param string $database Database name
|
||||||
|
* @param string $user Database user
|
||||||
|
* @param string $password Database password
|
||||||
|
* @param string $host Database host
|
||||||
|
* @param int $port Database port
|
||||||
|
*/
|
||||||
public function __construct($database , $user = null , $password = null, $host = null, $port = null){
|
public function __construct($database , $user = null , $password = null, $host = null, $port = null){
|
||||||
$this->m_database = $database;
|
$this->m_database = $database;
|
||||||
$this->m_user = $user;
|
$this->m_user = $user;
|
||||||
|
|||||||
21
db/qq/QI.php
21
db/qq/QI.php
@ -1,6 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QI Class provided by System to execute quick installation statements.
|
||||||
|
*/
|
||||||
class QI {
|
class QI {
|
||||||
|
/**
|
||||||
|
* Executes stored action by calling either files_pgsql() or files_mysql()
|
||||||
|
* of inherting class
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return array Returns array with Files and execution results
|
||||||
|
*/
|
||||||
public static function QI($dbinfo = null){
|
public static function QI($dbinfo = null){
|
||||||
if(!$dbinfo){
|
if(!$dbinfo){
|
||||||
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
||||||
|
|||||||
42
db/qq/QP.php
42
db/qq/QP.php
@ -1,7 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QQ Class provided by System to execute quick prepare statements.
|
||||||
|
*/
|
||||||
class QP {
|
class QP {
|
||||||
|
/**
|
||||||
|
* Executes stored action and return Database Object
|
||||||
|
*
|
||||||
|
* @param array $params Parameter passed to the prepare-query
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return Result Returns Database Result Object
|
||||||
|
*/
|
||||||
public static function QQ($params,$dbinfo = null){
|
public static function QQ($params,$dbinfo = null){
|
||||||
if(!$dbinfo){
|
if(!$dbinfo){
|
||||||
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
||||||
@ -29,6 +49,13 @@ class QP {
|
|||||||
throw new \Exception('Could not understand Database Settings. Check ur Database Settings');
|
throw new \Exception('Could not understand Database Settings. Check ur Database Settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes stored action and return all Data found
|
||||||
|
*
|
||||||
|
* @param array $params Parameter passed to the prepare-query
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return array Returns array with all lines of Database Query
|
||||||
|
*/
|
||||||
public static function QA($params,$dbinfo = null){
|
public static function QA($params,$dbinfo = null){
|
||||||
$res = self::QQ($params,$dbinfo);
|
$res = self::QQ($params,$dbinfo);
|
||||||
$result = array();
|
$result = array();
|
||||||
@ -37,9 +64,24 @@ class QP {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes stored action and return one line of Data found
|
||||||
|
*
|
||||||
|
* @param array $params Parameter passed to the prepare-query
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return array Returns array with all field of one lines of the Database Query
|
||||||
|
*/
|
||||||
public static function Q1($params,$dbinfo = null){
|
public static function Q1($params,$dbinfo = null){
|
||||||
return self::QQ($params,$dbinfo)->next();}
|
return self::QQ($params,$dbinfo)->next();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes stored action and return Database Result Object.
|
||||||
|
* Use this function if the Result is either true or false (update/delete/insert)
|
||||||
|
*
|
||||||
|
* @param array $params Parameter passed to the prepare-query
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return bool Returns true or false (or Result if used incorrectly)
|
||||||
|
*/
|
||||||
public static function QI($params,$dbinfo = null){
|
public static function QI($params,$dbinfo = null){
|
||||||
$qq = self::QQ($params,$dbinfo);
|
$qq = self::QQ($params,$dbinfo);
|
||||||
return $qq->affectedRows() != (0||null);}
|
return $qq->affectedRows() != (0||null);}
|
||||||
|
|||||||
39
db/qq/QQ.php
39
db/qq/QQ.php
@ -1,7 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QQ Class provided by System to execute quick query statements.
|
||||||
|
*/
|
||||||
class QQ {
|
class QQ {
|
||||||
|
/**
|
||||||
|
* Executes stored action and return Database Object
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return Result Returns Database Result Object
|
||||||
|
*/
|
||||||
public static function QQ($dbinfo = null){
|
public static function QQ($dbinfo = null){
|
||||||
if(!$dbinfo){
|
if(!$dbinfo){
|
||||||
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
$dbinfo = \SYSTEM\system::getSystemDBInfo();}
|
||||||
@ -31,6 +50,12 @@ class QQ {
|
|||||||
throw new \Exception('Could not understand Database Settings. Check ur Database Settings');
|
throw new \Exception('Could not understand Database Settings. Check ur Database Settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes stored action and return all Data found
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return array Returns array with all lines of Database Query
|
||||||
|
*/
|
||||||
public static function QA($dbinfo = null){
|
public static function QA($dbinfo = null){
|
||||||
$res = self::QQ($dbinfo);
|
$res = self::QQ($dbinfo);
|
||||||
$result = array();
|
$result = array();
|
||||||
@ -39,8 +64,22 @@ class QQ {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes stored action and return one line of Data found
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return array Returns array with all field of one lines of the Database Query
|
||||||
|
*/
|
||||||
public static function Q1($dbinfo = null){
|
public static function Q1($dbinfo = null){
|
||||||
return self::QQ($dbinfo)->next();}
|
return self::QQ($dbinfo)->next();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes stored action and return Database Result Object.
|
||||||
|
* Use this function if the Result is either true or false (update/delete/insert)
|
||||||
|
*
|
||||||
|
* @param DBINFO $dbinfo Database Info or Null for Default DB
|
||||||
|
* @return bool Returns true or false (or Result if used incorrectly)
|
||||||
|
*/
|
||||||
public static function QI($dbinfo = null){
|
public static function QI($dbinfo = null){
|
||||||
return self::QQ($dbinfo);}
|
return self::QQ($dbinfo);}
|
||||||
}
|
}
|
||||||
@ -1,16 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result Class provided by System to hold Database Query Result Ressources.
|
||||||
|
*/
|
||||||
abstract class Result {
|
abstract class Result {
|
||||||
|
/**
|
||||||
|
* Counts the Lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of lines in the result
|
||||||
|
*/
|
||||||
public abstract function count();
|
public abstract function count();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the affected lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of affected lines in the result
|
||||||
|
*/
|
||||||
public abstract function affectedRows();
|
public abstract function affectedRows();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next line in the Resultset
|
||||||
|
*
|
||||||
|
* @param bool $object Determines if the result will be an object or array
|
||||||
|
* @return array Returns an array(object) containing the next line
|
||||||
|
*/
|
||||||
public abstract function next($object = false);
|
public abstract function next($object = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seeks an amount of lines within the Resultset
|
||||||
|
*
|
||||||
|
* @param int $row_number Lines to seek over
|
||||||
|
* @return bool Returns true or false
|
||||||
|
*/
|
||||||
public abstract function seek($row_number);
|
public abstract function seek($row_number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the Resultset
|
||||||
|
*
|
||||||
|
* @return null Returns null
|
||||||
|
*/
|
||||||
public abstract function close();
|
public abstract function close();
|
||||||
}
|
}
|
||||||
@ -1,28 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result Class provided by System to hold Database Query Result Ressources of AMQP Querys.
|
||||||
|
*/
|
||||||
class ResultAMQP extends \SYSTEM\DB\Result{ // < maybe not ? check if amqpchannel is compatible with dbresult.
|
class ResultAMQP extends \SYSTEM\DB\Result{ // < maybe not ? check if amqpchannel is compatible with dbresult.
|
||||||
|
/** ressource Variable to store Database Result-ressource */
|
||||||
private $res = NULL;
|
private $res = NULL;
|
||||||
|
/** ressource Variable to store current Line either as array or object */
|
||||||
private $current = NULL;
|
private $current = NULL;
|
||||||
|
|
||||||
//Result from mysql_query
|
/**
|
||||||
|
* Construct the Resultset with a database ressource
|
||||||
|
*/
|
||||||
public function __construct($res){
|
public function __construct($res){
|
||||||
$this->res = $res;}
|
$this->res = $res;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Resultset upon destruction
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the Resultset
|
||||||
|
*
|
||||||
|
* @return null Returns null
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
pg_free_result($this->res);}
|
pg_free_result($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the Lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of lines in the result
|
||||||
|
*/
|
||||||
public function count(){
|
public function count(){
|
||||||
return pg_num_rows($this->res);}
|
return pg_num_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the affected lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of affected lines in the result
|
||||||
|
*/
|
||||||
public function affectedRows(){
|
public function affectedRows(){
|
||||||
throw new \SYSTEM\LOG\ERROR("Not Supported!");}
|
throw new \SYSTEM\LOG\ERROR("Not Supported!");}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next line in the Resultset
|
||||||
|
*
|
||||||
|
* @param bool $object Determines if the result will be an object or array
|
||||||
|
* @param int $result_type Mysql Fetch result Type
|
||||||
|
* @return array Returns an array(object) containing the next line
|
||||||
|
*/
|
||||||
public function next($object = false, $result_type = MYSQL_BOTH){
|
public function next($object = false, $result_type = MYSQL_BOTH){
|
||||||
if($object){
|
if($object){
|
||||||
$this->current = pg_fetch_object($this->res);
|
$this->current = pg_fetch_object($this->res);
|
||||||
@ -32,6 +72,12 @@ class ResultAMQP extends \SYSTEM\DB\Result{ // < maybe not ? check if amqpchanne
|
|||||||
return $this->current;
|
return $this->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seeks an amount of lines within the Resultset
|
||||||
|
*
|
||||||
|
* @param int $row_number Lines to seek over
|
||||||
|
* @return bool Returns true or false
|
||||||
|
*/
|
||||||
public function seek($row_number){
|
public function seek($row_number){
|
||||||
return pg_data_seek($this->res,$row_number);}
|
return pg_data_seek($this->res,$row_number);}
|
||||||
}
|
}
|
||||||
@ -1,28 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result Class provided by System to hold Database Query Result Ressources of MYSQL Querys.
|
||||||
|
*/
|
||||||
class ResultMysqli extends \SYSTEM\DB\Result{
|
class ResultMysqli extends \SYSTEM\DB\Result{
|
||||||
|
/** ressource Variable to store Database Result-ressource */
|
||||||
private $res = NULL;
|
private $res = NULL;
|
||||||
|
/** ressource Variable to store current Line either as array or object */
|
||||||
private $current = NULL;
|
private $current = NULL;
|
||||||
|
|
||||||
//Result from mysql_query
|
/**
|
||||||
|
* Construct the Resultset with a database ressource
|
||||||
|
*/
|
||||||
public function __construct($res){
|
public function __construct($res){
|
||||||
$this->res = $res;}
|
$this->res = $res;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Resultset upon destruction
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the Resultset
|
||||||
|
*
|
||||||
|
* @return null Returns null
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
mysqli_free_result($this->res);}
|
mysqli_free_result($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the Lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of lines in the result
|
||||||
|
*/
|
||||||
public function count(){
|
public function count(){
|
||||||
return mysqli_num_rows($this->res);}
|
return mysqli_num_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the affected lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of affected lines in the result
|
||||||
|
*/
|
||||||
public function affectedRows(){
|
public function affectedRows(){
|
||||||
return mysqli_affected_rows($this->res);}
|
return mysqli_affected_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next line in the Resultset
|
||||||
|
*
|
||||||
|
* @param bool $object Determines if the result will be an object or array
|
||||||
|
* @param int $result_type Mysql Fetch result Type
|
||||||
|
* @return array Returns an array(object) containing the next line
|
||||||
|
*/
|
||||||
public function next($object = false, $result_type = MYSQL_BOTH){
|
public function next($object = false, $result_type = MYSQL_BOTH){
|
||||||
if($object){
|
if($object){
|
||||||
$this->current = mysqli_fetch_object($this->res);
|
$this->current = mysqli_fetch_object($this->res);
|
||||||
@ -32,6 +72,12 @@ class ResultMysqli extends \SYSTEM\DB\Result{
|
|||||||
return $this->current;
|
return $this->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seeks an amount of lines within the Resultset
|
||||||
|
*
|
||||||
|
* @param int $row_number Lines to seek over
|
||||||
|
* @return bool Returns true or false
|
||||||
|
*/
|
||||||
public function seek($row_number){
|
public function seek($row_number){
|
||||||
return mysqli_data_seek($this->res,$row_number);}
|
return mysqli_data_seek($this->res,$row_number);}
|
||||||
}
|
}
|
||||||
@ -1,15 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result Class provided by System to hold Database Query Result Ressources of MYSQL prepare Querys.
|
||||||
|
*/
|
||||||
class ResultMysqliPrepare extends \SYSTEM\DB\Result{
|
class ResultMysqliPrepare extends \SYSTEM\DB\Result{
|
||||||
|
/** ressource Variable to store Database Result-ressource */
|
||||||
private $res = NULL;
|
private $res = NULL;
|
||||||
|
/** ressource Variable to store Metadata of Colums */
|
||||||
private $meta = NULL;
|
private $meta = NULL;
|
||||||
|
/** ressource Variable to store Binding Variables */
|
||||||
private $binds = array();
|
private $binds = array();
|
||||||
|
/** ressource Variable to store Database Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
|
|
||||||
//Result from mysql_query
|
/**
|
||||||
|
* Construct the Resultset with a database ressource
|
||||||
|
*/
|
||||||
public function __construct($res,$connection){
|
public function __construct($res,$connection){
|
||||||
$this->res = $res;
|
$this->res = $res;
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
@ -30,22 +47,44 @@ class ResultMysqliPrepare extends \SYSTEM\DB\Result{
|
|||||||
$this->res->store_result();
|
$this->res->store_result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Resultset upon destruction
|
||||||
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the Resultset
|
||||||
|
*
|
||||||
|
* @return null Returns null
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
mysqli_stmt_free_result($this->res);
|
mysqli_stmt_free_result($this->res);
|
||||||
mysqli_stmt_close($this->res);
|
return mysqli_stmt_close($this->res);}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the Lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of lines in the result
|
||||||
|
*/
|
||||||
public function count(){
|
public function count(){
|
||||||
return \mysqli_stmt_num_rows($this->res);}
|
return \mysqli_stmt_num_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the affected lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of affected lines in the result
|
||||||
|
*/
|
||||||
public function affectedRows(){
|
public function affectedRows(){
|
||||||
return \mysqli_stmt_affected_rows($this->res);}
|
return \mysqli_stmt_affected_rows($this->res);}
|
||||||
|
|
||||||
//$object not used
|
/**
|
||||||
//$result_type not used!
|
* Returns the next line in the Resultset
|
||||||
|
*
|
||||||
|
* @param bool $object Determines if the result will be an object or array
|
||||||
|
* @param int $result_type Mysql Fetch result Type
|
||||||
|
* @return array Returns an array(object) containing the next line
|
||||||
|
*/
|
||||||
public function next($object = false, $result_type = MYSQL_BOTH){
|
public function next($object = false, $result_type = MYSQL_BOTH){
|
||||||
if(\mysqli_stmt_fetch($this->res)){
|
if(\mysqli_stmt_fetch($this->res)){
|
||||||
foreach( $this->binds as $key=>$value ){
|
foreach( $this->binds as $key=>$value ){
|
||||||
@ -54,6 +93,12 @@ class ResultMysqliPrepare extends \SYSTEM\DB\Result{
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seeks an amount of lines within the Resultset
|
||||||
|
*
|
||||||
|
* @param int $row_number Lines to seek over
|
||||||
|
* @return bool Returns true or false
|
||||||
|
*/
|
||||||
public function seek($row_number){
|
public function seek($row_number){
|
||||||
return \mysqli_stmt_data_seek($this->res,$row_number);}
|
return \mysqli_stmt_data_seek($this->res,$row_number);}
|
||||||
}
|
}
|
||||||
@ -1,30 +1,70 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result Class provided by System to hold Database Query Result Ressources of PostgreSQL Querys.
|
||||||
|
*/
|
||||||
class ResultPostgres extends \SYSTEM\DB\Result{
|
class ResultPostgres extends \SYSTEM\DB\Result{
|
||||||
|
/** ressource Variable to store Database Result-ressource */
|
||||||
private $res = NULL;
|
private $res = NULL;
|
||||||
|
/** ressource Variable to store current Line either as array or object */
|
||||||
private $current = NULL;
|
private $current = NULL;
|
||||||
|
/** ressource Variable to store Database Connection */
|
||||||
private $connection = NULL;
|
private $connection = NULL;
|
||||||
|
|
||||||
//Result from mysql_query
|
/**
|
||||||
|
* Construct the Resultset with a database ressource
|
||||||
|
*/
|
||||||
public function __construct($res,$connection){
|
public function __construct($res,$connection){
|
||||||
$this->res = $res;
|
$this->res = $res;
|
||||||
$this->connection = $connection;}
|
$this->connection = $connection;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Resultset upon destruction
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the Resultset
|
||||||
|
*
|
||||||
|
* @return null Returns null
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
pg_free_result($this->res);}
|
pg_free_result($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the Lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of lines in the result
|
||||||
|
*/
|
||||||
public function count(){
|
public function count(){
|
||||||
return pg_num_rows($this->res);}
|
return pg_num_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the affected lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of affected lines in the result
|
||||||
|
*/
|
||||||
public function affectedRows(){
|
public function affectedRows(){
|
||||||
return pg_affected_rows($this->res);}
|
return pg_affected_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next line in the Resultset
|
||||||
|
*
|
||||||
|
* @param bool $object Determines if the result will be an object or array
|
||||||
|
* @return array Returns an array(object) containing the next line
|
||||||
|
*/
|
||||||
public function next($object = false){
|
public function next($object = false){
|
||||||
if($object){
|
if($object){
|
||||||
$this->current = pg_fetch_object($this->res);
|
$this->current = pg_fetch_object($this->res);
|
||||||
@ -34,6 +74,12 @@ class ResultPostgres extends \SYSTEM\DB\Result{
|
|||||||
return $this->current;
|
return $this->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seeks an amount of lines within the Resultset
|
||||||
|
*
|
||||||
|
* @param int $row_number Lines to seek over
|
||||||
|
* @return bool Returns true or false
|
||||||
|
*/
|
||||||
public function seek($row_number){
|
public function seek($row_number){
|
||||||
return pg_result_seek($this->res,$row_number);}
|
return pg_result_seek($this->res,$row_number);}
|
||||||
}
|
}
|
||||||
@ -1,41 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* System - PHP Framework
|
||||||
|
*
|
||||||
|
* PHP Version 5.6
|
||||||
|
*
|
||||||
|
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link https://github.com/webcraftmedia/system
|
||||||
|
* @package SYSTEM\DB
|
||||||
|
*/
|
||||||
namespace SYSTEM\DB;
|
namespace SYSTEM\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result Class provided by System to hold Database Query Result Ressources of SQLite File Querys.
|
||||||
|
*/
|
||||||
class ResultSQLite extends \SYSTEM\DB\Result{
|
class ResultSQLite extends \SYSTEM\DB\Result{
|
||||||
|
/** ressource Variable to store Database Result-ressource */
|
||||||
private $res = NULL;
|
private $res = NULL;
|
||||||
|
/** ressource Variable to store query statement */
|
||||||
private $stmt = NULL;
|
private $stmt = NULL;
|
||||||
|
/** ressource Variable to store current Line either as array or object */
|
||||||
private $current = NULL;
|
private $current = NULL;
|
||||||
|
|
||||||
//Result from mysql_query
|
/**
|
||||||
|
* Construct the Resultset with a database ressource
|
||||||
|
*/
|
||||||
public function __construct($res,$stmt){
|
public function __construct($res,$stmt){
|
||||||
$this->res = $res;
|
$this->res = $res;
|
||||||
$this->stmt = $stmt;}
|
$this->stmt = $stmt;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close Resultset upon destruction
|
||||||
|
*/
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
$this->close();}
|
$this->close();}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the Resultset
|
||||||
|
*
|
||||||
|
* @return null Returns null
|
||||||
|
*/
|
||||||
public function close(){
|
public function close(){
|
||||||
/*if($this->stmt){
|
/*if($this->stmt){
|
||||||
$this->stmt->close();}*/
|
$this->stmt->close();}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the Lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of lines in the result
|
||||||
|
*/
|
||||||
public function count(){
|
public function count(){
|
||||||
throw new Exception("Problem SQLite");
|
throw new Exception("Problem SQLite");
|
||||||
return mysqli_num_rows($this->res);}
|
return mysqli_num_rows($this->res);}
|
||||||
/*
|
|
||||||
* if ($res->numColumns() && $res->columnType(0) != SQLITE3_NULL) {
|
|
||||||
// have rows
|
|
||||||
} else {
|
|
||||||
// zero rows
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts the affected lines in the Resultset
|
||||||
|
*
|
||||||
|
* @return int Returns number of affected lines in the result
|
||||||
|
*/
|
||||||
public function affectedRows(){
|
public function affectedRows(){
|
||||||
throw new Exception("Problem SQLite");
|
throw new Exception("Problem SQLite");
|
||||||
return mysqli_affected_rows($this->res);}
|
return mysqli_affected_rows($this->res);}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next line in the Resultset
|
||||||
|
*
|
||||||
|
* @param bool $object Determines if the result will be an object or array
|
||||||
|
* @param int $result_type SQLITE Fetch result Type
|
||||||
|
* @return array Returns an array(object) containing the next line
|
||||||
|
*/
|
||||||
public function next($object = false, $result_type = SQLITE3_ASSOC){
|
public function next($object = false, $result_type = SQLITE3_ASSOC){
|
||||||
if($object){
|
if($object){
|
||||||
throw new Exception("Problem SQLite");
|
throw new Exception("Problem SQLite");
|
||||||
@ -45,36 +79,12 @@ class ResultSQLite extends \SYSTEM\DB\Result{
|
|||||||
return $this->current;
|
return $this->current;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* function fetchObject($sqlite3result, $objectType = NULL) {
|
* Seeks an amount of lines within the Resultset
|
||||||
$array = $sqlite3result->fetchArray();
|
*
|
||||||
|
* @param int $row_number Lines to seek over
|
||||||
if(is_null($objectType)) {
|
* @return bool Returns true or false
|
||||||
$object = new stdClass();
|
|
||||||
} else {
|
|
||||||
// does not call this class' constructor
|
|
||||||
$object = unserialize(sprintf('O:%d:"%s":0:{}', strlen($objectType), $objectType));
|
|
||||||
}
|
|
||||||
|
|
||||||
$reflector = new ReflectionObject($object);
|
|
||||||
for($i = 0; $i < $sqlite3result->numColumns(); $i++) {
|
|
||||||
$name = $sqlite3result->columnName($i);
|
|
||||||
$value = $array[$name];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$attribute = $reflector->getProperty($name);
|
|
||||||
|
|
||||||
$attribute->setAccessible(TRUE);
|
|
||||||
$attribute->setValue($object, $value);
|
|
||||||
} catch (ReflectionException $e) {
|
|
||||||
$object->$name = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $object;
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function seek($row_number){
|
public function seek($row_number){
|
||||||
throw new Exception("Problem SQLite");
|
throw new Exception("Problem SQLite");
|
||||||
return mysqli_data_seek($this->res,$row_number);}
|
return mysqli_data_seek($this->res,$row_number);}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user