3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pdo = new pdo('sqlite::memory:', null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); $pdo->exec('create table foo(id int primary key, letter text)'); $ids = insert($pdo, 'insert into foo(letter) values(?), (?), (?)', ['a', 'b', 'c']); var_dump($ids, $pdo->query('select * from foo')->fetchAll(PDO::FETCH_ASSOC)); function insert($pdo, string $sql, array $params = []) : array { if (stripos($sql, 'INSERT') !== 0) { throw new InvalidArgumentException('##LG_NOT_AN_INSERT_STATEMENT##'); } //$pdo = $this->getAdapter()->getConnection(); $stmt = $pdo->prepare($sql); $stmt->execute($params); $count = $stmt->rowCount(); $last = $pdo->lastInsertId(); return range($last - $count, $last); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eLHO8
function name:  (null)
number of ops:  27
compiled vars:  !0 = $pdo, !1 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'pdo'
          1        SEND_VAL_EX                                              'sqlite%3A%3Amemory%3A'
          2        SEND_VAL_EX                                              null
          3        SEND_VAL_EX                                              null
          4        SEND_VAL_EX                                              <array>
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $2
    4     7        INIT_METHOD_CALL                                         !0, 'exec'
          8        SEND_VAL_EX                                              'create+table+foo%28id+int+primary+key%2C+letter+text%29'
          9        DO_FCALL                                      0          
    6    10        INIT_FCALL_BY_NAME                                       'insert'
         11        SEND_VAR_EX                                              !0
         12        SEND_VAL_EX                                              'insert+into+foo%28letter%29+values%28%3F%29%2C+%28%3F%29%2C+%28%3F%29'
         13        SEND_VAL_EX                                              <array>
         14        DO_FCALL                                      0  $6      
         15        ASSIGN                                                   !1, $6
    8    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !1
         18        INIT_METHOD_CALL                                         !0, 'query'
         19        SEND_VAL_EX                                              'select+%2A+from+foo'
         20        DO_FCALL                                      0  $8      
         21        INIT_METHOD_CALL                                         $8, 'fetchAll'
         22        SEND_VAL_EX                                              2
         23        DO_FCALL                                      0  $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
   21    26      > RETURN                                                   1

Function insert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eLHO8
function name:  insert
number of ops:  35
compiled vars:  !0 = $pdo, !1 = $sql, !2 = $params, !3 = $stmt, !4 = $count, !5 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
   11     3        INIT_FCALL                                               'stripos'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 'INSERT'
          6        DO_ICALL                                         $6      
          7        IS_NOT_IDENTICAL                                         $6, 0
          8      > JMPZ                                                     ~7, ->13
   12     9    >   NEW                                              $8      'InvalidArgumentException'
         10        SEND_VAL_EX                                              '%23%23LG_NOT_AN_INSERT_STATEMENT%23%23'
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $8
   16    13    >   INIT_METHOD_CALL                                         !0, 'prepare'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $10     
         16        ASSIGN                                                   !3, $10
   17    17        INIT_METHOD_CALL                                         !3, 'execute'
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0          
   18    20        INIT_METHOD_CALL                                         !3, 'rowCount'
         21        DO_FCALL                                      0  $13     
         22        ASSIGN                                                   !4, $13
   19    23        INIT_METHOD_CALL                                         !0, 'lastInsertId'
         24        DO_FCALL                                      0  $15     
         25        ASSIGN                                                   !5, $15
   20    26        INIT_FCALL                                               'range'
         27        SUB                                              ~17     !5, !4
         28        SEND_VAL                                                 ~17
         29        SEND_VAR                                                 !5
         30        DO_ICALL                                         $18     
         31        VERIFY_RETURN_TYPE                                       $18
         32      > RETURN                                                   $18
   21    33*       VERIFY_RETURN_TYPE                                       
         34*     > RETURN                                                   null

End of function insert

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.3 ms | 1400 KiB | 19 Q