3v4l.org

run code in 500+ PHP versions simultaneously
<?php $pdo = new \PDO('sqlite::memory:'); //$pdo = new \Pdo\Sqlite('sqlite::memory:'); $pdo->exec('DROP TABLE IF EXISTS `order`; CREATE TABLE IF NOT EXISTS `order` (`order_id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT);'); $pdo->exec("DROP TABLE IF EXISTS `order_detail`; CREATE TABLE IF NOT EXISTS `order_detail` ( `order_detail_id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, `order_id` INTEGER NOT NULL, `quantity` DECIMAL(18,4) NOT NULL DEFAULT '0.0000', `unit_price` DECIMAL(19,4) NULL DEFAULT '0.0000');"); $pdo->exec('insert into `order` (`order_id`) values (1);'); $pdo->exec('insert into `order_detail` (`order_detail_id`, `order_id`, `quantity`, `unit_price`) values (1, 1, 10, 100);'); runQuery($pdo, 'SELECT * FROM `order` WHERE order_id = 1;'); runQuery($pdo, 'SELECT * FROM `order` WHERE order_id = ?;', 1); runQuery($pdo, 'SELECT * FROM `order` WHERE 1 = order_id;'); runQuery($pdo, 'SELECT * FROM `order` WHERE ? = order_id', 1); runQuery($pdo, 'SELECT * FROM `order` WHERE 1000 >= (SELECT (quantity * unit_price) FROM `order_detail` WHERE order_detail_id = `order`.order_id);'); runQuery($pdo, 'SELECT * FROM `order` WHERE (SELECT (quantity * unit_price) FROM `order_detail` WHERE order_detail_id = `order`.order_id) >= 1000;'); runQuery($pdo, 'SELECT * FROM `order` WHERE 1 >= (SELECT (quantity * unit_price) FROM `order_detail` WHERE order_detail_id = `order`.order_id);', expected:false); runQuery($pdo, 'SELECT * FROM `order` WHERE ? >= (SELECT (quantity * unit_price) FROM `order_detail` WHERE order_detail_id = `order`.order_id);', 1, expected:false); runQuery($pdo, 'SELECT * FROM `order` WHERE ? >= (SELECT (quantity * unit_price) FROM `order_detail` WHERE order_detail_id = `order`.order_id);', 1, expected:false); runQuery($pdo, 'SELECT * FROM `order` WHERE (SELECT (quantity * unit_price) FROM `order_detail` WHERE order_detail_id = `order`.order_id) >= ?;', 1000); function runQuery(\PDO $pdo, string $sql, ?int $input = null, int|bool $expected = 1): void { $statement = $pdo->prepare($sql); if ($statement) { $data = []; if ($input !== null) { $data[] = $input; } if ($statement->execute($data)) { $total = $statement->fetch(\PDO::FETCH_NUM); if ($total === false) { if (is_bool($expected) && ! $expected) { echo "SQLite query worked: "; } else { echo "PDOStatement::fetch returned false: "; } } else if (is_array($total)) { $value = $total[0]; if ($value !== $expected) { echo "PDOStatement::fetch failed and returned {$value}, expecting {$expected}: "; } else { echo "SQLite query worked: "; } } } else { echo "PDOStatement::execute failed: "; } } else { echo "PDO::prepare failed: "; } echo $sql . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1see
function name:  (null)
number of ops:  68
compiled vars:  !0 = $pdo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   NEW                                                  $1      'PDO'
          1        SEND_VAL_EX                                                  'sqlite%3A%3Amemory%3A'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $1
    6     4        INIT_METHOD_CALL                                             !0, 'exec'
          5        SEND_VAL_EX                                                  'DROP+TABLE+IF+EXISTS+%60order%60%3B+CREATE+TABLE+IF+NOT+EXISTS+%60order%60+%28%60order_id%60+INTEGER+NOT+NULL+PRIMARY+KEY+AUTOINCREMENT%29%3B'
          6        DO_FCALL                                          0          
    7     7        INIT_METHOD_CALL                                             !0, 'exec'
          8        SEND_VAL_EX                                                  'DROP+TABLE+IF+EXISTS+%60order_detail%60%3B+CREATE+TABLE+IF+NOT+EXISTS+%60order_detail%60+%28%0A++%60order_detail_id%60+INTEGER+NOT+NULL+PRIMARY+KEY+AUTO_INCREMENT%2C%0A++%60order_id%60+INTEGER+NOT+NULL%2C%0A++%60quantity%60+DECIMAL%2818%2C4%29+NOT+NULL+DEFAULT+%270.0000%27%2C%0A++%60unit_price%60+DECIMAL%2819%2C4%29+NULL+DEFAULT+%270.0000%27%29%3B'
          9        DO_FCALL                                          0          
   13    10        INIT_METHOD_CALL                                             !0, 'exec'
         11        SEND_VAL_EX                                                  'insert+into+%60order%60+%28%60order_id%60%29+values+%281%29%3B'
         12        DO_FCALL                                          0          
   14    13        INIT_METHOD_CALL                                             !0, 'exec'
         14        SEND_VAL_EX                                                  'insert+into+%60order_detail%60+%28%60order_detail_id%60%2C+%60order_id%60%2C+%60quantity%60%2C+%60unit_price%60%29+values+%281%2C+1%2C+10%2C+100%29%3B'
         15        DO_FCALL                                          0          
   16    16        INIT_FCALL_BY_NAME                                           'runQuery'
         17        SEND_VAR_EX                                                  !0
         18        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+order_id+%3D+1%3B'
         19        DO_FCALL                                          0          
   17    20        INIT_FCALL_BY_NAME                                           'runQuery'
         21        SEND_VAR_EX                                                  !0
         22        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+order_id+%3D+%3F%3B'
         23        SEND_VAL_EX                                                  1
         24        DO_FCALL                                          0          
   18    25        INIT_FCALL_BY_NAME                                           'runQuery'
         26        SEND_VAR_EX                                                  !0
         27        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+1+%3D+order_id%3B'
         28        DO_FCALL                                          0          
   19    29        INIT_FCALL_BY_NAME                                           'runQuery'
         30        SEND_VAR_EX                                                  !0
         31        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+%3F+%3D+order_id'
         32        SEND_VAL_EX                                                  1
         33        DO_FCALL                                          0          
   20    34        INIT_FCALL_BY_NAME                                           'runQuery'
         35        SEND_VAR_EX                                                  !0
         36        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+1000+%3E%3D+%28SELECT+%28quantity+%2A+unit_price%29+FROM+%60order_detail%60+WHERE+order_detail_id+%3D+%60order%60.order_id%29%3B'
         37        DO_FCALL                                          0          
   21    38        INIT_FCALL_BY_NAME                                           'runQuery'
         39        SEND_VAR_EX                                                  !0
         40        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+%28SELECT+%28quantity+%2A+unit_price%29+FROM+%60order_detail%60+WHERE+order_detail_id+%3D+%60order%60.order_id%29+%3E%3D+1000%3B'
         41        DO_FCALL                                          0          
   22    42        INIT_FCALL_BY_NAME                                           'runQuery'
         43        SEND_VAR_EX                                                  !0
         44        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+1+%3E%3D+%28SELECT+%28quantity+%2A+unit_price%29+FROM+%60order_detail%60+WHERE+order_detail_id+%3D+%60order%60.order_id%29%3B'
         45        SEND_VAL_EX                                                  <false>, 'expected'
         46        CHECK_UNDEF_ARGS                                             
         47        DO_FCALL                                          1          
   23    48        INIT_FCALL_BY_NAME                                           'runQuery'
         49        SEND_VAR_EX                                                  !0
         50        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+%3F+%3E%3D+%28SELECT+%28quantity+%2A+unit_price%29+FROM+%60order_detail%60+WHERE+order_detail_id+%3D+%60order%60.order_id%29%3B'
         51        SEND_VAL_EX                                                  1
         52        SEND_VAL_EX                                                  <false>, 'expected'
         53        CHECK_UNDEF_ARGS                                             
         54        DO_FCALL                                          1          
   24    55        INIT_FCALL_BY_NAME                                           'runQuery'
         56        SEND_VAR_EX                                                  !0
         57        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+%3F+%3E%3D+%28SELECT+%28quantity+%2A+unit_price%29+FROM+%60order_detail%60+WHERE+order_detail_id+%3D+%60order%60.order_id%29%3B'
         58        SEND_VAL_EX                                                  1
         59        SEND_VAL_EX                                                  <false>, 'expected'
         60        CHECK_UNDEF_ARGS                                             
         61        DO_FCALL                                          1          
   25    62        INIT_FCALL_BY_NAME                                           'runQuery'
         63        SEND_VAR_EX                                                  !0
         64        SEND_VAL_EX                                                  'SELECT+%2A+FROM+%60order%60+WHERE+%28SELECT+%28quantity+%2A+unit_price%29+FROM+%60order_detail%60+WHERE+order_detail_id+%3D+%60order%60.order_id%29+%3E%3D+%3F%3B'
         65        SEND_VAL_EX                                                  1000
         66        DO_FCALL                                          0          
   75    67      > RETURN                                                       1

Function runquery:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 50
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 48
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 33
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 28
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 47
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 46
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 47
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 14
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1see
function name:  runQuery
number of ops:  54
compiled vars:  !0 = $pdo, !1 = $sql, !2 = $input, !3 = $expected, !4 = $statement, !5 = $data, !6 = $total, !7 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV_INIT                                            !2      null
          3        RECV_INIT                                            !3      1
   29     4        INIT_METHOD_CALL                                             !0, 'prepare'
          5        SEND_VAR_EX                                                  !1
          6        DO_FCALL                                          0  $8      
          7        ASSIGN                                                       !4, $8
   30     8      > JMPZ                                                         !4, ->50
   32     9    >   ASSIGN                                                       !5, <array>
   33    10        TYPE_CHECK                                      1020          !2
         11      > JMPZ                                                         ~11, ->14
   35    12    >   ASSIGN_DIM                                                   !5
         13        OP_DATA                                                      !2
   37    14    >   INIT_METHOD_CALL                                             !4, 'execute'
         15        SEND_VAR_EX                                                  !5
         16        DO_FCALL                                          0  $13     
         17      > JMPZ                                                         $13, ->48
   39    18    >   INIT_METHOD_CALL                                             !4, 'fetch'
         19        SEND_VAL_EX                                                  3
         20        DO_FCALL                                          0  $14     
         21        ASSIGN                                                       !6, $14
   40    22        TYPE_CHECK                                        4          !6
         23      > JMPZ                                                         ~16, ->33
   42    24    >   TYPE_CHECK                                       12  ~17     !3
         25      > JMPZ_EX                                              ~17     ~17, ->28
         26    >   BOOL_NOT                                             ~18     !3
         27        BOOL                                                 ~17     ~18
         28    > > JMPZ                                                         ~17, ->31
   44    29    >   ECHO                                                         'SQLite+query+worked%3A+'
   42    30      > JMP                                                          ->32
   48    31    >   ECHO                                                         'PDOStatement%3A%3Afetch+returned+false%3A+'
   40    32    > > JMP                                                          ->47
   51    33    >   TYPE_CHECK                                      128          !6
         34      > JMPZ                                                         ~19, ->47
   53    35    >   FETCH_DIM_R                                          ~20     !6, 0
         36        ASSIGN                                                       !7, ~20
   54    37        IS_NOT_IDENTICAL                                             !7, !3
         38      > JMPZ                                                         ~22, ->46
   56    39    >   ROPE_INIT                                         5  ~24     'PDOStatement%3A%3Afetch+failed+and+returned+'
         40        ROPE_ADD                                          1  ~24     ~24, !7
         41        ROPE_ADD                                          2  ~24     ~24, '%2C+expecting+'
         42        ROPE_ADD                                          3  ~24     ~24, !3
         43        ROPE_END                                          4  ~23     ~24, '%3A+'
         44        ECHO                                                         ~23
   54    45      > JMP                                                          ->47
   60    46    >   ECHO                                                         'SQLite+query+worked%3A+'
   37    47    > > JMP                                                          ->49
   66    48    >   ECHO                                                         'PDOStatement%3A%3Aexecute+failed%3A+'
   30    49    > > JMP                                                          ->51
   71    50    >   ECHO                                                         'PDO%3A%3Aprepare+failed%3A+'
   74    51    >   CONCAT                                               ~27     !1, '%0A'
         52        ECHO                                                         ~27
   75    53      > RETURN                                                       null

End of function runquery

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
145.31 ms | 500 KiB | 10 Q