implement insert_id for mysqli prepare

This commit is contained in:
Ulf Gebhardt 2018-06-14 15:38:01 +02:00
parent 277a5ad1df
commit 1f26360289
8 changed files with 25 additions and 4 deletions

View File

@ -98,4 +98,7 @@ class Connection extends ConnectionAbstr{
*/
public function commit(){
return $this->connection->commit();}
public function insert_id(){
return $this->connection->insert_id();}
}

View File

@ -130,4 +130,7 @@ class ConnectionAMQP extends ConnectionAbstr {
*/
public function trans(){
throw new \Exception('Could not start Transaction: not implemented');}
public function insert_id(){
throw new \Exception('Not implemented');}
}

View File

@ -119,4 +119,8 @@ class ConnectionMYS extends ConnectionAbstr {
if(!\mysqli_begin_transaction($this->connection,MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT)){
throw new \Exception('Could not start Transaction: '.\mysqli_error($this->connection));}
return true;}
public function insert_id(){
return \mysqli_insert_id($this->connection);
}
}

View File

@ -119,4 +119,7 @@ class ConnectionPG extends ConnectionAbstr {
*/
public function exec($query) {
throw new \Exception('Could not start Transaction: not implemented');}
public function insert_id(){
throw new \Exception('Not implemented');}
}

View File

@ -107,4 +107,7 @@ class ConnectionSQLite extends ConnectionAbstr {
*/
public function trans(){
throw new \Exception('Could not start Transaction: not implemented');}
public function insert_id(){
throw new \Exception('Not implemented');}
}

View File

@ -82,7 +82,7 @@ class QP {
* @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,$return_id = false,$dbinfo = null){
$qq = self::QQ($params,$dbinfo);
return $qq->affectedRows() != (0||null);}
return $return_id ? $qq->insert_id() : $qq->affectedRows() != (0||null);}
}

View File

@ -80,6 +80,7 @@ class QQ {
* @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){
return self::QQ($dbinfo);}
public static function QI($return_id = false,$dbinfo = null){
$qq = self::QQ($dbinfo);
return $return_id ? $qq->insert_id() : $qq->affectedRows() != (0||null);}
}

View File

@ -107,4 +107,8 @@ class ResultMysqliPrepare extends \SYSTEM\DB\Result{
*/
public function seek($row_number){
return \mysqli_stmt_data_seek($this->res,$row_number);}
public function insert_id(){
return $this->connection->insert_id();
}
}