src/Fimsi/DBAL/Mysqli.php
function id_insert($table,$query,$bind_arr = null){
    $stmt = $this->mysqli->prepare($query);
    if(!$stmt){
     throw new Exception("can't prepare query:[$query] because [".$this->mysqli->error."]");
    }
    if(isset($bind_arr) && $bind_arr != null){
      call_user_func_array(array($stmt,'bind_param'),$this->makeValuesReferenced($bind_arr));
    }
    if(!$stmt->execute()){
       throw new Exception( $this->mysqli->error );
    }
    if(!$id = $stmt->insert_id){
       throw new Exception("no id returned for insert $query");
    }

    /* close statement and connection */
    $stmt->close();

    $rows = $this->query("select * from $table where id = ?",array("i",$id));
    return $rows[0];
  }
function id_insert($table,$query,$bind_arr = null){
    $stmt = $this->mysqli->prepare($query);
    if(!$stmt){
     throw new Exception("can't prepare query:[$query] because [".$this->mysqli->error."]");
    }
    if(isset($bind_arr) && $bind_arr != null){
      call_user_func_array(array($stmt,'bind_param'),$this->makeValuesReferenced($bind_arr));
    }
    if(!$stmt->execute()){
       throw new Exception( $this->mysqli->error );
    }
    if(!$id = $stmt->insert_id){
       throw new Exception("no id returned for insert $query");
    }

    /* close statement and connection */
    $stmt->close();

    $rows = $this->query("select * from $table where id = ?",array("i",$id));
    return $rows[0];
  }
function id_insert ( $ table , $ query , $ bind_arr = null ) { $ stmt = $ this -> mysqli -> prepare ( $ query ) ; if ( ! $ stmt ) { throw new Exception ( "can't prepare query:[$query] because [" . $ this -> mysqli -> error . "]" ) ; } if ( isset ( $ bind_arr ) && $ bind_arr != null ) { call_user_func_array ( array ( $ stmt , 'bind_param' ) , $ this -> makeValuesReferenced ( $ bind_arr ) ) ; } if ( ! $ stmt -> execute ( ) ) { throw new Exception ( $ this -> mysqli -> error ) ; } if ( ! $ id = $ stmt -> insert_id ) { throw new Exception ( "no id returned for insert $query" ) ; } /* close statement and connection */ $ stmt -> close ( ) ; $ rows = $ this -> query ( "select * from $table where id = ?" , array ( "i" , $ id ) ) ; return $ rows [ 0 ] ; }
insert a row of data and return it back
insert a row of data and return it back