php7 compatibility

This commit is contained in:
Ulf Gebhardt 2018-06-01 04:45:32 +02:00
parent 4f285ba9ab
commit 277a5ad1df
8 changed files with 15 additions and 12 deletions

View File

@ -75,7 +75,7 @@ class ConnectionMYS extends ConnectionAbstr {
if(!mysqli_stmt_execute($prepStmt)){ if(!mysqli_stmt_execute($prepStmt)){
throw new \SYSTEM\LOG\ERROR("Could not execute prepare statement: ". \mysqli_stmt_error($prepStmt));} throw new \SYSTEM\LOG\ERROR("Could not execute prepare statement: ". \mysqli_stmt_error($prepStmt));}
return new ResultMysqliPrepare($prepStmt,$this); return new \SYSTEM\DB\ResultMysqliPrepare($prepStmt,$this);
} }
/** /**
@ -88,7 +88,7 @@ class ConnectionMYS extends ConnectionAbstr {
$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); return $result === true ? $result : new \SYSTEM\DB\ResultMysqli($result);
} }
/** /**

View File

@ -65,7 +65,7 @@ class ResultAMQP extends \SYSTEM\DB\Result{ // < maybe not ? check if amqpchanne
* @param int $result_type Mysql Fetch result Type * @param int $result_type Mysql Fetch result Type
* @return array Returns an array(object) containing the next line * @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 = MYSQLI_BOTH){
if($object){ if($object){
$this->current = pg_fetch_object($this->res); $this->current = pg_fetch_object($this->res);
} else { } else {

View File

@ -65,7 +65,7 @@ class ResultMysqli extends \SYSTEM\DB\Result{
* @param int $result_type Mysql Fetch result Type * @param int $result_type Mysql Fetch result Type
* @return array Returns an array(object) containing the next line * @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 = MYSQLI_BOTH){
if($object){ if($object){
$this->current = mysqli_fetch_object($this->res); $this->current = mysqli_fetch_object($this->res);
} else { } else {

View File

@ -41,12 +41,15 @@ class ResultMysqliPrepare extends \SYSTEM\DB\Result{
//throw new \Exception("Could not retrieve meta for prepare statement");} //throw new \Exception("Could not retrieve meta for prepare statement");}
return;} return;}
$ref = [];
while ($field = $this->meta->fetch_field() ) { while ($field = $this->meta->fetch_field() ) {
$this->binds[$field->table.'.'.$field->name] = &$this->binds[$field->table.'.'.$field->name];} //fix for ambiguous fieldnames $this->binds[$field->table.'.'.$field->name] = &$this->binds[$field->table.'.'.$field->name];
$ref[$field->table.'.'.$field->name] = &$this->binds[$field->table.'.'.$field->name];
} //fix for ambiguous fieldnames
\mysqli_free_result($this->meta); \mysqli_free_result($this->meta);
call_user_func_array(array($this->res, 'bind_result'), $this->binds); //you need 2 append the parameters - thats the right way to do that. call_user_func_array(array($this->res, 'bind_result'), $ref); //you need 2 append the parameters - thats the right way to do that.
$this->res->store_result(); $this->res->store_result();
} }
@ -88,7 +91,7 @@ class ResultMysqliPrepare extends \SYSTEM\DB\Result{
* @param int $result_type Mysql Fetch result Type * @param int $result_type Mysql Fetch result Type
* @return array Returns an array(object) containing the next line * @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 = MYSQLI_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 ){
$row[substr($key, strpos($key, '.')+1)] = $value;} //fix for ambiguous fieldnames $row[substr($key, strpos($key, '.')+1)] = $value;} //fix for ambiguous fieldnames

View File

@ -22,5 +22,5 @@ interface error_handler {
* @param bool $thrown Was the Exception thrown? * @param bool $thrown Was the Exception thrown?
* @return bool Returns true or false. * @return bool Returns true or false.
*/ */
static function CALL(\Exception $E, $thrown); static function CALL($E, $thrown);
} }

View File

@ -23,7 +23,7 @@ class error_handler_dbwriter implements \SYSTEM\LOG\error_handler {
* @param bool $thrown Was the Exception thrown? * @param bool $thrown Was the Exception thrown?
* @return bool Returns true or false. * @return bool Returns true or false.
*/ */
public static function CALL(\Exception $E, $thrown){ public static function CALL($E, $thrown){
try{ try{
$result = \SYSTEM\SQL\SYS_LOG_INSERT::QI(array( $result = \SYSTEM\SQL\SYS_LOG_INSERT::QI(array(
get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(), get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(),

View File

@ -23,7 +23,7 @@ class error_handler_jsonoutput implements \SYSTEM\LOG\error_handler {
* @param bool $thrown Was the Exception thrown? * @param bool $thrown Was the Exception thrown?
* @return bool Returns true or false. * @return bool Returns true or false.
*/ */
public static function CALL(\Exception $E, $thrown){ public static function CALL($E, $thrown){
if($thrown){ if($thrown){
try{ try{
echo \SYSTEM\LOG\JsonResult::error($E); echo \SYSTEM\LOG\JsonResult::error($E);

View File

@ -46,7 +46,7 @@ class log {
* @param bool $thrown Was the Exception thrown? * @param bool $thrown Was the Exception thrown?
* @return bool Returns true or false. * @return bool Returns true or false.
*/ */
private static function call_handlers(\Exception $E, $thrown = true){ private static function call_handlers($E, $thrown = true){
foreach(self::$handlers as $handler){ foreach(self::$handlers as $handler){
if( \call_user_func_array(array($handler,self::HANDLER_FUNC_CALL),array($E, $thrown))){ if( \call_user_func_array(array($handler,self::HANDLER_FUNC_CALL),array($E, $thrown))){
return true;}} return true;}}
@ -59,7 +59,7 @@ class log {
* @param bool $thrown Was the Exception thrown? * @param bool $thrown Was the Exception thrown?
* @return bool Returns true or false depending on thrown * @return bool Returns true or false depending on thrown
*/ */
public static function __exception_handler(\Exception $E, $thrown = true){ public static function __exception_handler($E, $thrown = true){
return self::call_handlers($E, $thrown) && $thrown;} return self::call_handlers($E, $thrown) && $thrown;}
/** /**