3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** session_set_cookie_params(3600 * 24 * 7); session_save_path('../tmp/'); ini_set('session.gc_maxlifetime', '604800'); ini_set('session.gc_probability',1); ini_set('session.gc_divisor',1); session_start(); // Initialize Session data ob_start(); // Turn on output buffering * MySQL Database Connection Class * @access public * @package SPLIB */ class MySQL { /** * MySQL server hostname * @access private * @var string */ var $host; /** * MySQL username * @access private * @var string */ var $dbUser; /** * MySQL user's password * @access private * @var string */ var $dbPass; /** * Name of database to use * @access private * @var string */ var $dbName; /** * MySQL Resource link identifier stored here * @access private * @var string */ var $dbConn; /** * Stores error messages for connection errors * @access private * @var string */ var $connectError; /** * MySQL constructor * @param string host (MySQL server hostname) * @param string dbUser (MySQL User Name) * @param string dbPass (MySQL User Password) * @param string dbName (Database to select) * @access public */ function MySQL ($host,$dbUser,$dbPass,$dbName) { $this->host=$host; $this->dbUser=$dbUser; $this->dbPass=$dbPass; $this->dbName=$dbName; $this->connectToDb(); } /** * Establishes connection to MySQL and selects a database * @return void * @access private */ function connectToDb () { $this->dbConn=@mysqli_connect($this->host,$this->dbUser,$this->dbPass,$this->dbName); // Check connection if (mysqli_connect_errno($this->dbConn)) { trigger_error("Failed to connect to MySQL: " . mysqli_connect_error()); } /* // Make connection to MySQL server if (!$this->dbConn = @mysqli_connect($this->host, $this->dbUser, $this->dbPass,$this->dbName)) { // trigger_error('Could not connect to server'); $this->connectError=true; // Select database } else if ( !@mysqli_select_db($this->dbName,$this->dbConn) ) { // trigger_error('Could not select database'); $this->connectError=true; }*/ } /** * Checks for MySQL errors * @return boolean * @access public */ function isError () { if ( $this->connectError ) return true; $error=mysqli_error ($this->dbConn); if ( empty ($error) ) return false; else return true; } /** * Returns an instance of MySQLResult to fetch rows with * @param $sql string the database query to run * @return MySQLResult * @access public */ function query($sql) { if (!$queryResource=mysqli_query($this->dbConn,$sql)) trigger_error ('Query failed: '.mysqli_error($this->dbConn).' SQL: '.$sql); return new MySQLResult($this,$queryResource); } function multi_query($sql) { $result =""; if (!$queryResource=mysqli_multi_query($this->dbConn,$sql)) trigger_error ('Query failed: '.mysqli_error($this->dbConn).' SQL: '.$sql); do { /* store first result set */ $result = mysqli_store_result($this->dbConn); if (mysqli_more_results($this->dbConn)) { if(is_object($result) && get_class($result) == 'mysqli')mysqli_free_result($result); } } while (mysqli_next_result($this->dbConn)); return $result; } function real_escape_string($txt) { return $this->dbConn->real_escape_string($txt); } function closeConn() { if(isset($this->dbConn)) { mysqli_close($this->dbConn); unset($this->dbConn); } } function new_id() { return mysqli_insert_id($this->dbConn); // if (!$idResource=insertID()) // trigger_error ('Query failed: '.mysql_error($this->dbConn).' SQL: '); // return new MySQLResult($this,$idResource); } function num_rows($rs) { return mysqli_num_rows($rs); } } /** * MySQLResult Data Fetching Class * @access public * @package SPLIB */ class MySQLResult { /** * Instance of MySQL providing database connection * @access private * @var MySQL */ var $mysql; /** * Query resource * @access private * @var resource */ var $query; /** * MySQLResult constructor * @param object mysql (instance of MySQL class) * @param resource query (MySQL query resource) * @access public */ function MySQLResult(& $mysql,$query) { $this->mysql=& $mysql; $this->query=$query; } /** * Fetches a row from the result * @return array * @access public */ function fetch () { if ( $row=mysqli_fetch_array($this->query,MYSQLI_ASSOC) ) { return $row; } else if ( $this->size() > 0 ) { mysqli_data_seek($this->query,0); return false; } else { return false; } } /** * Returns the number of rows selected * @return int * @access public */ function size () { return mysqli_num_rows($this->query); } /** * Returns the ID of the last row inserted * @return int * @access public */ function insertID() { return mysqli_insert_id($this->mysql->dbConn); } /** * Checks for MySQL errors * @return boolean * @access public */ function isError () { return $this->mysql->isError(); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  250     0  E > > RETURN                                                   1

Class MySQL:
Function mysql:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  MySQL
number of ops:  15
compiled vars:  !0 = $host, !1 = $dbUser, !2 = $dbPass, !3 = $dbName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   70     4        ASSIGN_OBJ                                               'host'
          5        OP_DATA                                                  !0
   71     6        ASSIGN_OBJ                                               'dbUser'
          7        OP_DATA                                                  !1
   72     8        ASSIGN_OBJ                                               'dbPass'
          9        OP_DATA                                                  !2
   73    10        ASSIGN_OBJ                                               'dbName'
         11        OP_DATA                                                  !3
   74    12        INIT_METHOD_CALL                                         'connectToDb'
         13        DO_FCALL                                      0          
   75    14      > RETURN                                                   null

End of function mysql

Function connecttodb:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/leb4P
function name:  connectToDb
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   BEGIN_SILENCE                                    ~1      
          1        INIT_FCALL_BY_NAME                                       'mysqli_connect'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $2      'host'
          4        SEND_FUNC_ARG                                            $2
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $3      'dbUser'
          7        SEND_FUNC_ARG                                            $3
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $4      'dbPass'
         10        SEND_FUNC_ARG                                            $4
         11        CHECK_FUNC_ARG                                           
         12        FETCH_OBJ_FUNC_ARG                               $5      'dbName'
         13        SEND_FUNC_ARG                                            $5
         14        DO_FCALL                                      0  $6      
         15        END_SILENCE                                              ~1
         16        ASSIGN_OBJ                                               'dbConn'
         17        OP_DATA                                                  $6
   87    18        INIT_FCALL_BY_NAME                                       'mysqli_connect_errno'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_OBJ_FUNC_ARG                               $7      'dbConn'
         21        SEND_FUNC_ARG                                            $7
         22        DO_FCALL                                      0  $8      
         23      > JMPZ                                                     $8, ->30
   89    24    >   INIT_FCALL                                               'trigger_error'
         25        INIT_FCALL_BY_NAME                                       'mysqli_connect_error'
         26        DO_FCALL                                      0  $9      
         27        CONCAT                                           ~10     'Failed+to+connect+to+MySQL%3A+', $9
         28        SEND_VAL                                                 ~10
         29        DO_ICALL                                                 
  104    30    > > RETURN                                                   null

End of function connecttodb

Function iserror:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 3
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  isError
number of ops:  15
compiled vars:  !0 = $error
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  112     0  E >   FETCH_OBJ_R                                      ~1      'connectError'
          1      > JMPZ                                                     ~1, ->3
  113     2    > > RETURN                                                   <true>
  114     3    >   INIT_FCALL_BY_NAME                                       'mysqli_error'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $2      'dbConn'
          6        SEND_FUNC_ARG                                            $2
          7        DO_FCALL                                      0  $3      
          8        ASSIGN                                                   !0, $3
  115     9        ISSET_ISEMPTY_CV                                         !0
         10      > JMPZ                                                     ~5, ->13
  116    11    > > RETURN                                                   <false>
         12*       JMP                                                      ->14
  118    13    > > RETURN                                                   <true>
  119    14*     > RETURN                                                   null

End of function iserror

Function query:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/leb4P
function name:  query
number of ops:  28
compiled vars:  !0 = $sql, !1 = $queryResource
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  127     0  E >   RECV                                             !0      
  128     1        INIT_FCALL_BY_NAME                                       'mysqli_query'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $2      'dbConn'
          4        SEND_FUNC_ARG                                            $2
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $3      
          7        ASSIGN                                           ~4      !1, $3
          8        BOOL_NOT                                         ~5      ~4
          9      > JMPZ                                                     ~5, ->21
  129    10    >   INIT_FCALL                                               'trigger_error'
         11        INIT_FCALL_BY_NAME                                       'mysqli_error'
         12        CHECK_FUNC_ARG                                           
         13        FETCH_OBJ_FUNC_ARG                               $6      'dbConn'
         14        SEND_FUNC_ARG                                            $6
         15        DO_FCALL                                      0  $7      
         16        CONCAT                                           ~8      'Query+failed%3A+', $7
         17        CONCAT                                           ~9      ~8, '+SQL%3A+'
         18        CONCAT                                           ~10     ~9, !0
         19        SEND_VAL                                                 ~10
         20        DO_ICALL                                                 
  130    21    >   NEW                                              $12     'MySQLResult'
         22        FETCH_THIS                                       $13     
         23        SEND_VAR_EX                                              $13
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0          
         26      > RETURN                                                   $12
  131    27*     > RETURN                                                   null

End of function query

Function multi_query:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 43
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 22
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 43
Branch analysis from position: 39
Branch analysis from position: 43
Branch analysis from position: 22
filename:       /in/leb4P
function name:  multi_query
number of ops:  51
compiled vars:  !0 = $sql, !1 = $result, !2 = $queryResource
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  133     0  E >   RECV                                             !0      
  134     1        ASSIGN                                                   !1, ''
  135     2        INIT_FCALL_BY_NAME                                       'mysqli_multi_query'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $4      'dbConn'
          5        SEND_FUNC_ARG                                            $4
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                           ~6      !2, $5
          9        BOOL_NOT                                         ~7      ~6
         10      > JMPZ                                                     ~7, ->22
  136    11    >   INIT_FCALL                                               'trigger_error'
         12        INIT_FCALL_BY_NAME                                       'mysqli_error'
         13        CHECK_FUNC_ARG                                           
         14        FETCH_OBJ_FUNC_ARG                               $8      'dbConn'
         15        SEND_FUNC_ARG                                            $8
         16        DO_FCALL                                      0  $9      
         17        CONCAT                                           ~10     'Query+failed%3A+', $9
         18        CONCAT                                           ~11     ~10, '+SQL%3A+'
         19        CONCAT                                           ~12     ~11, !0
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
  140    22    >   INIT_FCALL_BY_NAME                                       'mysqli_store_result'
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $14     'dbConn'
         25        SEND_FUNC_ARG                                            $14
         26        DO_FCALL                                      0  $15     
         27        ASSIGN                                                   !1, $15
  142    28        INIT_FCALL_BY_NAME                                       'mysqli_more_results'
         29        CHECK_FUNC_ARG                                           
         30        FETCH_OBJ_FUNC_ARG                               $17     'dbConn'
         31        SEND_FUNC_ARG                                            $17
         32        DO_FCALL                                      0  $18     
         33      > JMPZ                                                     $18, ->43
  143    34    >   TYPE_CHECK                                  256  ~19     !1
         35      > JMPZ_EX                                          ~19     ~19, ->39
         36    >   GET_CLASS                                        ~20     !1
         37        IS_EQUAL                                         ~21     ~20, 'mysqli'
         38        BOOL                                             ~19     ~21
         39    > > JMPZ                                                     ~19, ->43
         40    >   INIT_FCALL_BY_NAME                                       'mysqli_free_result'
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0          
  146    43    >   INIT_FCALL_BY_NAME                                       'mysqli_next_result'
         44        CHECK_FUNC_ARG                                           
         45        FETCH_OBJ_FUNC_ARG                               $23     'dbConn'
         46        SEND_FUNC_ARG                                            $23
         47        DO_FCALL                                      0  $24     
         48      > JMPNZ                                                    $24, ->22
  150    49    > > RETURN                                                   !1
  151    50*     > RETURN                                                   null

End of function multi_query

Function real_escape_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  real_escape_string
number of ops:  7
compiled vars:  !0 = $txt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  152     0  E >   RECV                                             !0      
  154     1        FETCH_OBJ_R                                      ~1      'dbConn'
          2        INIT_METHOD_CALL                                         ~1, 'real_escape_string'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
  155     6*     > RETURN                                                   null

End of function real_escape_string

Function closeconn:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/leb4P
function name:  closeConn
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  157     0  E >   ISSET_ISEMPTY_PROP_OBJ                                   'dbConn'
          1      > JMPZ                                                     ~0, ->8
  158     2    >   INIT_FCALL_BY_NAME                                       'mysqli_close'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $1      'dbConn'
          5        SEND_FUNC_ARG                                            $1
          6        DO_FCALL                                      0          
  159     7        UNSET_OBJ                                                'dbConn'
  161     8    > > RETURN                                                   null

End of function closeconn

Function new_id:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  new_id
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  163     0  E >   INIT_FCALL_BY_NAME                                       'mysqli_insert_id'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      'dbConn'
          3        SEND_FUNC_ARG                                            $0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
  167     6*     > RETURN                                                   null

End of function new_id

Function num_rows:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  num_rows
number of ops:  6
compiled vars:  !0 = $rs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  168     0  E >   RECV                                             !0      
  170     1        INIT_FCALL_BY_NAME                                       'mysqli_num_rows'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
  171     5*     > RETURN                                                   null

End of function num_rows

End of class MySQL.

Class MySQLResult:
Function mysqlresult:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  MySQLResult
number of ops:  7
compiled vars:  !0 = $mysql, !1 = $query
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  202     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  203     2        ASSIGN_OBJ_REF                                           'mysql'
          3        OP_DATA                                                  !0
  204     4        ASSIGN_OBJ                                               'query'
          5        OP_DATA                                                  !1
  205     6      > RETURN                                                   null

End of function mysqlresult

Function fetch:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  fetch
number of ops:  25
compiled vars:  !0 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  213     0  E >   INIT_FCALL_BY_NAME                                       'mysqli_fetch_array'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'query'
          3        SEND_FUNC_ARG                                            $1
          4        FETCH_CONSTANT                                   ~2      'MYSQLI_ASSOC'
          5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0  $3      
          7        ASSIGN                                           ~4      !0, $3
          8      > JMPZ                                                     ~4, ->11
  214     9    > > RETURN                                                   !0
         10*       JMP                                                      ->24
  215    11    >   INIT_METHOD_CALL                                         'size'
         12        DO_FCALL                                      0  $5      
         13        IS_SMALLER                                               0, $5
         14      > JMPZ                                                     ~6, ->23
  216    15    >   INIT_FCALL_BY_NAME                                       'mysqli_data_seek'
         16        CHECK_FUNC_ARG                                           
         17        FETCH_OBJ_FUNC_ARG                               $7      'query'
         18        SEND_FUNC_ARG                                            $7
         19        SEND_VAL_EX                                              0
         20        DO_FCALL                                      0          
  217    21      > RETURN                                                   <false>
         22*       JMP                                                      ->24
  219    23    > > RETURN                                                   <false>
  221    24*     > RETURN                                                   null

End of function fetch

Function size:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  size
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  229     0  E >   INIT_FCALL_BY_NAME                                       'mysqli_num_rows'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      'query'
          3        SEND_FUNC_ARG                                            $0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
  230     6*     > RETURN                                                   null

End of function size

Function insertid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  insertID
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  238     0  E >   INIT_FCALL_BY_NAME                                       'mysqli_insert_id'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      'mysql'
          3        FETCH_OBJ_FUNC_ARG                               $1      $0, 'dbConn'
          4        SEND_FUNC_ARG                                            $1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
  239     7*     > RETURN                                                   null

End of function insertid

Function iserror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leb4P
function name:  isError
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  247     0  E >   FETCH_OBJ_R                                      ~0      'mysql'
          1        INIT_METHOD_CALL                                         ~0, 'isError'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
  248     4*     > RETURN                                                   null

End of function iserror

End of class MySQLResult.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.2 ms | 1420 KiB | 15 Q