mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Añadida la libreria datatables editor a third party
This commit is contained in:
161
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/Db2Query.php.txt
vendored
Normal file
161
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/Db2Query.php.txt
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* DB2 database driver for DataTables libraries.
|
||||
* BETA! Feedback welcome
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\Db2Result;
|
||||
|
||||
/**
|
||||
* DB2 driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class Db2Query extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
private $_editor_pkey_value;
|
||||
|
||||
private $_sql;
|
||||
|
||||
protected $_identifier_limiter = null;
|
||||
|
||||
protected $_field_quote = '"';
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$port = $opts['port'];
|
||||
$host = $opts['host'];
|
||||
$db = $opts['db'];
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
}
|
||||
|
||||
// $connStr = 'DATABASE='.$db.';HOSTNAME='.$host;
|
||||
// if ( $port ) {
|
||||
// $connStr .= ';PORT='.$port;
|
||||
// }
|
||||
// $connStr .= ';UID='.$user.';PWD='.$pass.';AUTHENTICATION=server';
|
||||
$connStr = $db;
|
||||
|
||||
$conn = db2_connect($connStr, $user, $pass);
|
||||
|
||||
if ( ! $conn ) {
|
||||
// If we can't establish a DB connection then we returna DataTables
|
||||
// error.
|
||||
$e = 'Connection failed: '.db2_conn_error().' : '.db2_conn_errormsg();
|
||||
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return $conn;
|
||||
}
|
||||
|
||||
public static function transaction ( $conn )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
public static function commit ( $conn )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
public static function rollback ( $conn )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare($sql)
|
||||
{
|
||||
$this->_sql = $sql;
|
||||
}
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
$resource = $this->database()->resource();
|
||||
$bindings = $this->_bindings;
|
||||
|
||||
$paramSql = preg_replace('/(:[a-zA-Z\-_0-9]*)/', '?', $this->_sql);
|
||||
//echo $paramSql."\n";
|
||||
$this->_stmt = db2_prepare($resource, $paramSql);
|
||||
$stmt = $this->_stmt;
|
||||
|
||||
//echo $this->_sql."\n";
|
||||
|
||||
preg_match_all('/(:[a-zA-Z\-_0-9]*)/', $this->_sql, $matches);
|
||||
|
||||
//print_r( $matches );
|
||||
//print_r( $bindings);
|
||||
|
||||
//$allanTest = 65;
|
||||
//db2_bind_param( $stmt, 1, 'allanTest', DB2_PARAM_IN );
|
||||
|
||||
for ( $i=0, $ien=count($matches[0]) ; $i<$ien ; $i++ ) {
|
||||
for ( $j=0, $jen=count($bindings) ; $j<$jen ; $j++ ) {
|
||||
if ( $bindings[$j]['name'] === $matches[0][$i] ) {
|
||||
$name = str_replace(':', '', $matches[0][$i]);
|
||||
$$name = $bindings[$j]['value'];
|
||||
//$_GLOBALS[ $name ] = $bindings[$j]['value'];
|
||||
|
||||
//echo "bind $name as ".$$name."\n";
|
||||
|
||||
db2_bind_param( $stmt, $i+1, $name, DB2_PARAM_IN );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//print_r( get_defined_vars() );
|
||||
|
||||
$res = db2_execute($stmt);
|
||||
|
||||
if (! $res) {
|
||||
throw new \Exception('DB2 SQL error = '.db2_stmt_error($this->_stmt));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new Db2Result($resource, $this->_stmt, $this->_editor_pkey_value);
|
||||
}
|
||||
|
||||
protected function _build_table()
|
||||
{
|
||||
$out = array();
|
||||
|
||||
for ($i = 0, $ien = count($this->_table); $i < $ien; $i ++) {
|
||||
$t = $this->_table[$i];
|
||||
|
||||
if (strpos($t, ' as ')) {
|
||||
$a = explode(' as ', $t);
|
||||
$out[] = $a[0] . ' ' . $a[1];
|
||||
} else {
|
||||
$out[] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
return ' ' . implode(', ', $out) . ' ';
|
||||
}
|
||||
}
|
||||
82
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/Db2Result.php.txt
vendored
Normal file
82
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/Db2Result.php.txt
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* SQL Server driver for DataTables PHP libraries
|
||||
* BETA! Feedback welcome
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2013 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* SQL Server driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class Db2Result extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt;
|
||||
private $_dbh;
|
||||
private $_allRows = null;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
$all = $this->_fetchAll();
|
||||
return count($all);
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return db2_fetch_assoc( $this->_stmt );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
$all = $this->_fetchAll();
|
||||
return $all;
|
||||
}
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
return db2_last_insert_id( $this->_dbh );
|
||||
}
|
||||
|
||||
private function _fetchAll () {
|
||||
$a = array();
|
||||
while ( $row = db2_fetch_assoc( $this->_stmt ) ) {
|
||||
$a[] = $row;
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
|
||||
137
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/FirebirdQuery.php.txt
vendored
Normal file
137
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/FirebirdQuery.php.txt
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\FirebirdResult;
|
||||
|
||||
|
||||
/**
|
||||
* Firebird driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class FirebirdQuery extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
protected $_identifier_limiter = ['"', '"'];
|
||||
|
||||
protected $_field_quote = '"';
|
||||
|
||||
protected $_supportsAsAlias = false;
|
||||
|
||||
public $_pkeyInsertedTo;
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$port = $opts['port'];
|
||||
$host = $opts['host'];
|
||||
$db = $opts['db'];
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
$pdoAttr = isset( $opts['pdoAttr'] ) ? $opts['pdoAttr'] : array();
|
||||
}
|
||||
|
||||
if ( $host !== "" ) {
|
||||
$host = "{$host}";
|
||||
|
||||
if ( $port !== "" ) {
|
||||
$host .= "/{$port}";
|
||||
}
|
||||
|
||||
$host .= ';';
|
||||
}
|
||||
|
||||
try {
|
||||
$pdoAttr[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_EXCEPTION;
|
||||
|
||||
$pdo = @new PDO(
|
||||
"firebird:{$host}dbname={$db}".self::dsnPostfix( $dsn ),
|
||||
$user,
|
||||
$pass,
|
||||
$pdoAttr
|
||||
);
|
||||
} catch (\PDOException $e) {
|
||||
// If we can't establish a DB connection then we return a DataTables
|
||||
// error.
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e->getMessage()
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare( $sql )
|
||||
{
|
||||
$this->database()->debugInfo( $sql, $this->_bindings );
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
$pkey = $this->pkey();
|
||||
|
||||
// If insert, add the pkey column
|
||||
if ( $this->_type === 'insert' && $pkey ) {
|
||||
$this->_pkeyInsertedTo = (is_array($pkey) ? $pkey[0] : $pkey);
|
||||
$sql .= ' RETURNING "'.$this->_pkeyInsertedTo.'"';
|
||||
}
|
||||
|
||||
$this->_stmt = $resource->prepare( $sql );
|
||||
|
||||
// bind values
|
||||
for ( $i=0 ; $i<count($this->_bindings) ; $i++ ) {
|
||||
$binding = $this->_bindings[$i];
|
||||
|
||||
$this->_stmt->bindValue(
|
||||
$binding['name'],
|
||||
$binding['value'],
|
||||
$binding['type'] ? $binding['type'] : \PDO::PARAM_STR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
try {
|
||||
$this->_stmt->execute();
|
||||
}
|
||||
catch (\PDOException $e) {
|
||||
throw new \Exception( "An SQL error occurred: ".$e->getMessage() );
|
||||
error_log( "An SQL error occurred: ".$e->getMessage() );
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new FirebirdResult( $resource, $this->_stmt, $this->_pkeyInsertedTo );
|
||||
}
|
||||
}
|
||||
|
||||
77
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/FirebirdResult.php.txt
vendored
Normal file
77
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/FirebirdResult.php.txt
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Firebird driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class FirebirdResult extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt, $pkey )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
$this->_pkey = $pkey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt;
|
||||
private $_dbh;
|
||||
private $_pkey;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
return count($this->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetch( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetchAll( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
// Only useful after an insert of course...
|
||||
$rows = $this->_stmt->fetchAll();
|
||||
return $rows[0][$this->_pkey];
|
||||
}
|
||||
}
|
||||
|
||||
121
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/MysqlQuery.php.txt
vendored
Normal file
121
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/MysqlQuery.php.txt
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\MysqlResult;
|
||||
|
||||
|
||||
/**
|
||||
* MySQL driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class MysqlQuery extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$host = $opts['host'];
|
||||
$db = $opts['db'];
|
||||
$port = isset( $opts['port'] ) ? $opts['port'] : '';
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
$pdoAttr = isset( $opts['pdoAttr'] ) ? $opts['pdoAttr'] : array();
|
||||
}
|
||||
|
||||
if ( $port !== "" ) {
|
||||
$port = "port={$port};";
|
||||
}
|
||||
|
||||
try {
|
||||
$pdoAttr[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_EXCEPTION;
|
||||
|
||||
$pdo = @new PDO(
|
||||
"mysql:host={$host};{$port}dbname={$db}".self::dsnPostfix( $dsn ),
|
||||
$user,
|
||||
$pass,
|
||||
$pdoAttr
|
||||
);
|
||||
} catch (\PDOException $e) {
|
||||
// If we can't establish a DB connection then we return a DataTables
|
||||
// error.
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e->getMessage()
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare( $sql )
|
||||
{
|
||||
$this->database()->debugInfo( $sql, $this->_bindings );
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
$this->_stmt = $resource->prepare( $sql );
|
||||
|
||||
// bind values
|
||||
for ( $i=0 ; $i<count($this->_bindings) ; $i++ ) {
|
||||
$binding = $this->_bindings[$i];
|
||||
|
||||
$this->_stmt->bindValue(
|
||||
$binding['name'],
|
||||
$binding['value'],
|
||||
$binding['type'] ? $binding['type'] : \PDO::PARAM_STR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
// $start = hrtime(true);
|
||||
|
||||
try {
|
||||
$this->_stmt->execute();
|
||||
}
|
||||
catch (\PDOException $e) {
|
||||
throw new \Exception( "An SQL error occurred: ".$e->getMessage() );
|
||||
error_log( "An SQL error occurred: ".$e->getMessage() );
|
||||
return false;
|
||||
}
|
||||
|
||||
// $this->database()->debugInfo( 'Execution complete - duration: '. (hrtime(true) - $start) . ' Time: '. microtime(true), [] );
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new MysqlResult( $resource, $this->_stmt );
|
||||
}
|
||||
}
|
||||
|
||||
73
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/MysqlResult.php.txt
vendored
Normal file
73
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/MysqlResult.php.txt
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* MySQL driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class MysqlResult extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt;
|
||||
private $_dbh;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
return count($this->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetch( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetchAll( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
return $this->_dbh->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
203
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/OracleQuery.php.txt
vendored
Normal file
203
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/OracleQuery.php.txt
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/**
|
||||
* Oracle database driver for DataTables libraries.
|
||||
*
|
||||
* Note that this software uses the oci_* methods in PHP and NOT the Oracle PDO
|
||||
* driver, which is poorly supported.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2014 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\OracleResult;
|
||||
|
||||
|
||||
/**
|
||||
* Oracle driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class OracleQuery extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
private $_editor_pkey_value;
|
||||
|
||||
protected $_identifier_limiter = array( '"', '"' );
|
||||
|
||||
protected $_field_quote = '"';
|
||||
|
||||
protected $_supportsAsAlias = false;
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$port = $opts['port'];
|
||||
$host = $opts['host'];
|
||||
$db = $opts['db'];
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
}
|
||||
|
||||
if ( $port !== "" ) {
|
||||
$port = ":{$port}";
|
||||
}
|
||||
|
||||
if ( ! is_callable( 'oci_connect' ) ) {
|
||||
echo json_encode( array(
|
||||
"error" => "oci methods are not available in this PHP install to connect to Oracle"
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$conn = @oci_connect($user, $pass, $host.$port.'/'.$db, 'utf8');
|
||||
|
||||
if ( ! $conn ) {
|
||||
// If we can't establish a DB connection then we return a DataTables
|
||||
// error.
|
||||
$e = oci_error();
|
||||
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e['message']
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Use ISO date and time styles
|
||||
$stmt = oci_parse($conn, "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'" );
|
||||
$res = oci_execute( $stmt );
|
||||
|
||||
$stmt = oci_parse($conn, "ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'" );
|
||||
$res = oci_execute( $stmt );
|
||||
|
||||
return $conn;
|
||||
}
|
||||
|
||||
|
||||
public static function transaction ( $conn )
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
||||
public static function commit ( $conn )
|
||||
{
|
||||
oci_commit( $conn );
|
||||
}
|
||||
|
||||
public static function rollback ( $conn )
|
||||
{
|
||||
oci_rollback( $conn );
|
||||
}
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare( $sql )
|
||||
{
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
$pkey = $this->pkey();
|
||||
|
||||
// If insert, add the pkey column
|
||||
if ( $this->_type === 'insert' && $pkey ) {
|
||||
$sql .= ' RETURNING '.$this->_protect_identifiers(is_array($pkey) ? $pkey[0] : $pkey).' INTO :editor_pkey_value';
|
||||
}
|
||||
else if ( $this->_type === 'select' && $this->_oracle_offset !== null ) {
|
||||
$sql = '
|
||||
select * from (select rownum rnum, a.*
|
||||
from ('.$sql.') a where rownum <= '.($this->_oracle_offset+$this->_oracle_limit).')
|
||||
where rnum > '.$this->_oracle_offset;
|
||||
}
|
||||
|
||||
$this->database()->debugInfo( $sql, $this->_bindings );
|
||||
|
||||
$this->_stmt = oci_parse( $resource, $sql );
|
||||
|
||||
// If insert, add a binding for the returned id
|
||||
if ( $this->_type === 'insert' && $pkey ) {
|
||||
oci_bind_by_name(
|
||||
$this->_stmt,
|
||||
':editor_pkey_value',
|
||||
$this->_editor_pkey_value,
|
||||
36
|
||||
);
|
||||
}
|
||||
|
||||
// Bind values
|
||||
for ( $i=0 ; $i<count($this->_bindings) ; $i++ ) {
|
||||
$binding = $this->_bindings[$i];
|
||||
|
||||
oci_bind_by_name(
|
||||
$this->_stmt,
|
||||
$binding['name'],
|
||||
$binding['value']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
$res = @oci_execute( $this->_stmt, OCI_NO_AUTO_COMMIT );
|
||||
|
||||
if ( ! $res ) {
|
||||
$e = oci_error( $this->_stmt );
|
||||
throw new \Exception( "Oracle SQL error: ".$e['message'] );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new OracleResult( $resource, $this->_stmt, $this->_editor_pkey_value );
|
||||
}
|
||||
|
||||
|
||||
protected function _build_table()
|
||||
{
|
||||
$out = array();
|
||||
|
||||
for ( $i=0, $ien=count($this->_table) ; $i<$ien ; $i++ ) {
|
||||
$t = $this->_table[$i];
|
||||
|
||||
if ( strpos($t, ' as ') ) {
|
||||
$a = explode( ' as ', $t );
|
||||
$out[] = $this->_protect_identifiers($a[0]).' '.$this->_protect_identifiers($a[1]);
|
||||
}
|
||||
else {
|
||||
$out[] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
return ' '.implode(', ', $out).' ';
|
||||
}
|
||||
|
||||
|
||||
private $_oracle_offset = null;
|
||||
private $_oracle_limit = null;
|
||||
|
||||
protected function _build_limit()
|
||||
{
|
||||
$this->_oracle_offset = $this->_offset;
|
||||
$this->_oracle_limit = $this->_limit;
|
||||
|
||||
return ' ';
|
||||
}
|
||||
}
|
||||
82
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/OracleResult.php.txt
vendored
Normal file
82
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/OracleResult.php.txt
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Oracle database driver for Editor
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2014 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* MySQL driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class OracleResult extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt, $pkey_val )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
$this->_pkey_val = $pkey_val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt; // Result from oci_parse
|
||||
private $_dbh; // Result from oci_connect
|
||||
private $_rows = null;
|
||||
private $_pkey_val;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
return count($this->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC /* irrelevant for oci8 */ )
|
||||
{
|
||||
return oci_fetch_assoc( $this->_stmt );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC /* irrelevant for oci8 */ )
|
||||
{
|
||||
if ( ! $this->_rows ) {
|
||||
$out = array();
|
||||
|
||||
oci_fetch_all( $this->_stmt, $out, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC );
|
||||
|
||||
$this->_rows = $out;
|
||||
}
|
||||
|
||||
return $this->_rows;
|
||||
}
|
||||
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
return $this->_pkey_val;
|
||||
}
|
||||
}
|
||||
|
||||
146
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/PostgresQuery.php.txt
vendored
Normal file
146
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/PostgresQuery.php.txt
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\PostgresResult;
|
||||
|
||||
|
||||
/**
|
||||
* Postgres driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class PostgresQuery extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
protected $_identifier_limiter = array('"', '"');
|
||||
|
||||
protected $_field_quote = '"';
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$port = $opts['port'];
|
||||
$host = $opts['host'];
|
||||
$db = $opts['db'];
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
$pdoAttr = isset( $opts['pdoAttr'] ) ? $opts['pdoAttr'] : array();
|
||||
}
|
||||
|
||||
if ( $port !== "" ) {
|
||||
$port = "port={$port};";
|
||||
}
|
||||
|
||||
try {
|
||||
$pdoAttr[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_EXCEPTION;
|
||||
|
||||
$pdo = @new PDO(
|
||||
"pgsql:host={$host};{$port}dbname={$db}".self::dsnPostfix( $dsn ),
|
||||
$user,
|
||||
$pass,
|
||||
$pdoAttr
|
||||
);
|
||||
} catch (\PDOException $e) {
|
||||
// If we can't establish a DB connection then we return a DataTables
|
||||
// error.
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e->getMessage()
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare( $sql )
|
||||
{
|
||||
$this->database()->debugInfo( $sql, $this->_bindings );
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
|
||||
// Add a RETURNING command to postgres insert queries so we can get the
|
||||
// pkey value from the query reliably
|
||||
if ( $this->_type === 'insert' ) {
|
||||
$table = explode( ' as ', $this->_table[0] );
|
||||
|
||||
// Get the pkey field name
|
||||
$pkRes = $resource->prepare(
|
||||
"SELECT
|
||||
pg_attribute.attname,
|
||||
format_type(pg_attribute.atttypid, pg_attribute.atttypmod)
|
||||
FROM pg_index, pg_class, pg_attribute
|
||||
WHERE
|
||||
pg_class.oid = '{$table[0]}'::regclass AND
|
||||
indrelid = pg_class.oid AND
|
||||
pg_attribute.attrelid = pg_class.oid AND
|
||||
pg_attribute.attnum = any(pg_index.indkey)
|
||||
AND indisprimary"
|
||||
);
|
||||
$pkRes->execute();
|
||||
$row = $pkRes->fetch();
|
||||
|
||||
if ( $row && isset($row['attname'] ) ) {
|
||||
$sql .= ' RETURNING '.$row['attname'].' as dt_pkey';
|
||||
}
|
||||
}
|
||||
|
||||
$this->_stmt = $resource->prepare( $sql );
|
||||
|
||||
// bind values
|
||||
for ( $i=0 ; $i<count($this->_bindings) ; $i++ ) {
|
||||
$binding = $this->_bindings[$i];
|
||||
|
||||
$this->_stmt->bindValue(
|
||||
$binding['name'],
|
||||
$binding['value'],
|
||||
$binding['type'] ? $binding['type'] : \PDO::PARAM_STR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
try {
|
||||
$this->_stmt->execute();
|
||||
}
|
||||
catch (\PDOException $e) {
|
||||
throw new \Exception( "An SQL error occurred: ".$e->getMessage() );
|
||||
error_log( "An SQL error occurred: ".$e->getMessage() );
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new PostgresResult( $resource, $this->_stmt );
|
||||
}
|
||||
}
|
||||
|
||||
75
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/PostgresResult.php.txt
vendored
Normal file
75
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/PostgresResult.php.txt
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Postgres driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class PostgresResult extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt;
|
||||
private $_dbh;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
return count($this->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetch( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetchAll( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
// Only useful after an insert of course...
|
||||
$rows = $this->_stmt->fetchAll();
|
||||
return $rows[0]['dt_pkey'];
|
||||
}
|
||||
}
|
||||
|
||||
112
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqliteQuery.php.txt
vendored
Normal file
112
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqliteQuery.php.txt
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\SqliteResult;
|
||||
|
||||
|
||||
/**
|
||||
* SQLite3 driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class SqliteQuery extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
|
||||
protected $_identifier_limiter = null;
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$db = $opts['db'];
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
$pdoAttr = isset( $opts['pdoAttr'] ) ? $opts['pdoAttr'] : array();
|
||||
}
|
||||
|
||||
try {
|
||||
$pdoAttr[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_EXCEPTION;
|
||||
|
||||
$pdo = @new PDO(
|
||||
"sqlite:{$db}".self::dsnPostfix( $dsn ),
|
||||
$user,
|
||||
$pass,
|
||||
$pdoAttr
|
||||
);
|
||||
} catch (\PDOException $e) {
|
||||
// If we can't establish a DB connection then we return a DataTables
|
||||
// error.
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e->getMessage()
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare( $sql )
|
||||
{
|
||||
$this->database()->debugInfo( $sql, $this->_bindings );
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
$this->_stmt = $resource->prepare( $sql );
|
||||
|
||||
// bind values
|
||||
for ( $i=0 ; $i<count($this->_bindings) ; $i++ ) {
|
||||
$binding = $this->_bindings[$i];
|
||||
|
||||
$this->_stmt->bindValue(
|
||||
$binding['name'],
|
||||
$binding['value'],
|
||||
$binding['type'] ? $binding['type'] : \PDO::PARAM_STR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
try {
|
||||
$this->_stmt->execute();
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new \Exception( "An SQL error occurred: ".$e->getMessage() );
|
||||
error_log( "An SQL error occurred: ".$e->getMessage() );
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new SqliteResult( $resource, $this->_stmt );
|
||||
}
|
||||
}
|
||||
|
||||
73
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqliteResult.php.txt
vendored
Normal file
73
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqliteResult.php.txt
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Sqlite driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class SqliteResult extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt;
|
||||
private $_dbh;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
return count($this->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetch( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetchAll( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
return $this->_dbh->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
153
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqlserverQuery.php.txt
vendored
Normal file
153
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqlserverQuery.php.txt
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* SQL Server driver for DataTables PHP libraries
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2013 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Query;
|
||||
use DataTables\Database\Driver\PostgresResult;
|
||||
|
||||
|
||||
/**
|
||||
* SQL Server driver for DataTables Database Query class
|
||||
* @internal
|
||||
*/
|
||||
class SqlserverQuery extends Query {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
private $_stmt;
|
||||
|
||||
|
||||
protected $_identifier_limiter = array( '[', ']' );
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
static function connect( $user, $pass='', $host='', $port='', $db='', $dsn='' )
|
||||
{
|
||||
if ( is_array( $user ) ) {
|
||||
$opts = $user;
|
||||
$user = $opts['user'];
|
||||
$pass = $opts['pass'];
|
||||
$port = $opts['port'];
|
||||
$host = $opts['host'];
|
||||
$db = $opts['db'];
|
||||
$dsn = isset( $opts['dsn'] ) ? $opts['dsn'] : '';
|
||||
$pdoAttr = isset( $opts['pdoAttr'] ) ? $opts['pdoAttr'] : array();
|
||||
}
|
||||
|
||||
try {
|
||||
$pdoAttr[ PDO::ATTR_ERRMODE ] = PDO::ERRMODE_EXCEPTION;
|
||||
|
||||
if ( in_array( 'sqlsrv', PDO::getAvailableDrivers() ) ) {
|
||||
// Windows
|
||||
if ( $port !== "" ) {
|
||||
$port = ",{$port}";
|
||||
}
|
||||
|
||||
$pdo = new PDO(
|
||||
"sqlsrv:Server={$host}{$port};Database={$db}".self::dsnPostfix( $dsn ),
|
||||
$user,
|
||||
$pass,
|
||||
$pdoAttr
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Linux
|
||||
if ( $port !== "" ) {
|
||||
$port = ":{$port}";
|
||||
}
|
||||
|
||||
$pdo = new PDO(
|
||||
"dblib:host={$host}{$port};dbname={$db}".self::dsnPostfix( $dsn ),
|
||||
$user,
|
||||
$pass,
|
||||
$pdoAttr
|
||||
);
|
||||
}
|
||||
|
||||
} catch (\PDOException $e) {
|
||||
// If we can't establish a DB connection then we return a DataTables
|
||||
// error.
|
||||
echo json_encode( array(
|
||||
"error" => "An error occurred while connecting to the database ".
|
||||
"'{$db}'. The error reported by the server was: ".$e->getMessage()
|
||||
) );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Protected methods
|
||||
*/
|
||||
|
||||
protected function _prepare( $sql )
|
||||
{
|
||||
$this->database()->debugInfo( $sql, $this->_bindings );
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
$this->_stmt = $resource->prepare( $sql );
|
||||
|
||||
// bind values
|
||||
for ( $i=0 ; $i<count($this->_bindings) ; $i++ ) {
|
||||
$binding = $this->_bindings[$i];
|
||||
|
||||
$this->_stmt->bindValue(
|
||||
$binding['name'],
|
||||
$binding['value'],
|
||||
$binding['type'] ? $binding['type'] : \PDO::PARAM_STR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _exec()
|
||||
{
|
||||
try {
|
||||
$this->_stmt->execute();
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new \Exception( "An SQL error occurred: ".$e->getMessage() );
|
||||
error_log( "An SQL error occurred: ".$e->getMessage() );
|
||||
return false;
|
||||
}
|
||||
|
||||
$resource = $this->database()->resource();
|
||||
return new SqlserverResult( $resource, $this->_stmt );
|
||||
}
|
||||
|
||||
|
||||
// SQL Server 2012+ only
|
||||
protected function _build_limit()
|
||||
{
|
||||
$out = '';
|
||||
|
||||
if ( $this->_offset ) {
|
||||
$out .= ' OFFSET '.$this->_offset.' ROWS';
|
||||
}
|
||||
|
||||
if ( $this->_limit ) {
|
||||
if ( ! $this->_offset ) {
|
||||
$out .= ' OFFSET 0 ROWS';
|
||||
}
|
||||
$out .= ' FETCH NEXT '.$this->_limit. ' ROWS ONLY';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
71
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqlserverResult.php.txt
vendored
Normal file
71
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Driver/SqlserverResult.php.txt
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* SQL Server driver for DataTables PHP libraries
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2013 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database\Driver;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
use PDO;
|
||||
use DataTables\Database\Result;
|
||||
|
||||
|
||||
/**
|
||||
* SQL Server driver for DataTables Database Result class
|
||||
* @internal
|
||||
*/
|
||||
class SqlserverResult extends Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
function __construct( $dbh, $stmt )
|
||||
{
|
||||
$this->_dbh = $dbh;
|
||||
$this->_stmt = $stmt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Private properties
|
||||
*/
|
||||
|
||||
private $_stmt;
|
||||
private $_dbh;
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
public function count ()
|
||||
{
|
||||
return count($this->fetchAll());
|
||||
}
|
||||
|
||||
|
||||
public function fetch ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetch( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC )
|
||||
{
|
||||
return $this->_stmt->fetchAll( $fetchType );
|
||||
}
|
||||
|
||||
|
||||
public function insertId ()
|
||||
{
|
||||
return $this->_dbh->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
1295
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Query.php.txt
vendored
Normal file
1295
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Query.php.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
68
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Result.php.txt
vendored
Normal file
68
ci4/app/ThirdParty/DatatablesEditor/docs/files/Database/Result.php.txt
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* DataTables PHP libraries.
|
||||
*
|
||||
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
|
||||
*
|
||||
* @author SpryMedia
|
||||
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
|
||||
* @license http://editor.datatables.net/license DataTables Editor
|
||||
* @link http://editor.datatables.net
|
||||
*/
|
||||
|
||||
namespace DataTables\Database;
|
||||
if (!defined('DATATABLES')) exit();
|
||||
|
||||
|
||||
//
|
||||
// This is a stub class that a driver must extend and complete
|
||||
//
|
||||
|
||||
/**
|
||||
* Result object given by a {@see Query} performed on a database.
|
||||
*
|
||||
* The typical pattern for using this class is to receive an instance of it as a
|
||||
* result of using the {@see Database} and {@see Query} class methods that
|
||||
* return a result. This class should not be initialised independently.
|
||||
*
|
||||
* Note that this is a stub class that a driver will extend and complete as
|
||||
* required for individual database types. Individual drivers could add
|
||||
* additional methods, but this is discouraged to ensure that the API is the
|
||||
* same for all database types.
|
||||
*/
|
||||
abstract class Result {
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Count the number of rows in the result set.
|
||||
* @return int
|
||||
*/
|
||||
abstract public function count ();
|
||||
|
||||
|
||||
/**
|
||||
* Get the next row in a result set
|
||||
* @param int PDO row fetch style - PDO::FETCH_ASSOC is the default
|
||||
* @return array
|
||||
*/
|
||||
abstract public function fetch ( $fetchType=\PDO::FETCH_ASSOC );
|
||||
|
||||
|
||||
/**
|
||||
* Get all rows in the result set
|
||||
* @param int PDO row fetch style - PDO::FETCH_ASSOC is the default
|
||||
* @return array
|
||||
*/
|
||||
abstract public function fetchAll ( $fetchType=\PDO::FETCH_ASSOC );
|
||||
|
||||
|
||||
/**
|
||||
* After an INSERT query, get the ID that was inserted.
|
||||
* @return int
|
||||
*/
|
||||
abstract public function insertId ();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user