3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*-------------------------------------------------------- クラス --------------------------------------------------------*/ // fetch, fetchAll で実行される abstract class DataModel { const BOOLEAN = 'boolean' , INTEGER = 'integer' , DOUBLE = 'double' , FLOAT = 'double' , STRING = 'string' , DATETIME = 'dateTime'; const BIND_TYPE = array( 'boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT, 'double' => PDO::PARAM_STR, 'string' => PDO::PARAM_STR, 'dateTime' => PDO::PARAM_STR, ); protected array $data = array(); // 拡張クラスで宣言される protected static string $primaryKeyName; protected static array $omit = array(); protected static array $schema = array(); function __get($prop) { if (property_exists($this, $prop)) { return static::$$prop; } elseif (isset($this->data[$prop])) { return $this->data[$prop]; } elseif (isset(static::$schema[$prop])) { return null; } else { throw new InvalidArgumentException($prop . 'は存在しません'); } } function __isset($prop) { return isset($this->data[$prop]); } /** * @throws Exception */ function __set($prop, $val) { if (!isset(static::$schema[$prop])) { throw new InvalidArgumentException($prop . 'はセットできません'); } $schema = static::$schema[$prop]; if ($schema === static::DATETIME) { if ($val instanceof DateTime) { $this->data[$prop] = $val; } else { $this->data[$prop] = new DateTime($val); } return $this->data[$prop]; } else { return match ($schema) { static::BOOLEAN => $this->data[$prop] = (bool)$val, static::INTEGER => $this->data[$prop] = (int)$val, static::DOUBLE => $this->data[$prop] = (double)$val, default => $this->data[$prop] = (string)$val, }; } } function toArray(): array { return $this->data; } /** * @throws Exception */ function fromArray(array $arr): void { foreach ($arr as $key => $val) { $this->__set($key, $val); } } abstract function isValid(string $save_type); // TIMESTAMP のオブジェクトを探し DATETIME の値に変換する public function convertTimestampToDatetime(){ $result = $this; $data = []; foreach ($this->data as $key => $value) { if ($value instanceof DateTime) { $data[$key] = $value->format('Y-m-d H:i:s'); } else { $data[$key] = $value; } } $result->data = $data; return $result; } } abstract class DataMapper { const MODEL_CLASS = ''; const TABLE_NAME = ''; protected PDO $pdo; function __construct() { // 拡張クラスで宣言される値を確認 if (!class_exists(static::MODEL_CLASS)) { throw new InvalidArgumentException('MODEL_CLASSが存在しません'); } assert(!empty(static::TABLE_NAME), 'TABLE_NAMEが存在しません'); // pdo if (empty($pdo)) { $pdo = new PDO ('mysql:host=host.docker.internal;dbname=test', 'test', 'pass'); } $this->pdo = $pdo; } protected function decorate(PDOStatement $stmt) { $stmt->setFetchMode(PDO::FETCH_CLASS|PDO::FETCH_PROPS_LATE, static::MODEL_CLASS); return $stmt; } public function insert(DataModel $data, array $omit = []) { // isValid $valided = $data->isValid('insert'); if ($valided !== true) { throw new InvalidArgumentException($valided.'の値が不正です'); } $schema = $data->schema; $pk = $data->primaryKeyName; $omitCols = array_merge($omit, $data->omit); $cols = array_diff(array_keys($schema), array_merge(array($pk), $omitCols)); $colsClause = implode(',', $cols); $valsClause = rtrim(str_repeat('?,', count($cols)), ','); $sql = 'INSERT INTO ' . static::TABLE_NAME . ' (' . $colsClause . ')' . ' VALUES(' . $valsClause . ')'; echo '<h4>【$sql】</h4>'; var_dump($sql); $sth = $this->pdo->prepare($sql); $this->decorate($sth); $n = 1; foreach($cols as $col) { $val = $data->$col; $schemaType = $schema[$col]; if ($schemaType == DataModel::DATETIME) { /** @var DateTime $val */ $val = $val->format('Y-m-d H:i:s'); } $sth->bindValue($n++, $val, DataModel::BIND_TYPE[$schemaType]); } $sth->execute(); $data->$pk = $this->pdo->lastInsertId(); // var_dump($omitCols); // 'author' を含んでいる foreach($omitCols as $omitCol) { unset($data->$omitCol); // 削除されない } } } class Entry extends DataModel { protected static string $primaryKeyName = 'entryId'; protected static array $omit = array('created_at', 'updated_at'); // CREATE TABLE でのデフォ値を使用 protected static array $schema = array( 'entryId' => parent::INTEGER , 'author' => parent::STRING , 'title' => parent::STRING , 'content' => parent::STRING , 'published' => parent::DATETIME ); function isValid(string $save_type) { // authorは100文字まで、insertで必須 $val = $this->author; if ( ($save_type === 'insert' && empty($val)) || (!mb_check_encoding($val) || mb_strlen($val) > 100) ) { return 'author'; } // titleは100文字まで、必須 $val = $this->title; if (empty($val) || !mb_check_encoding($val) || mb_strlen($val) > 100) { return 'title'; } // contentは10000字まで、必須 $val = $this->content; if (empty($val) || !mb_check_encoding($val) || mb_strlen($val) > 10000) { return 'content'; } // publishedは型があっていれば問題ない $val = $this->published; if (empty($val)) { return 'published'; } return true; } } class EntryMapper extends DataMapper { const MODEL_CLASS = 'Entry'; const TABLE_NAME = 'entries'; } /*-------------------------------------------------------- 実行 --------------------------------------------------------*/ $entry = new Entry(); $entryMapper = new EntryMapper(); $new_info = [ 'author' => '太郎', 'title' => '今日の天気', 'content' => '雨です', 'published' => new DateTime ]; $entry->fromArray($new_info); $entryMapper->insert($entry, ['author']); echo '<h4>【$entry】</h4>'; var_export($entry); echo '<h4>【$entryArr】</h4>'; $entryArr = $entry->convertTimestampToDatetime()->toArray(); var_export($entryArr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mULe0
function name:  (null)
number of ops:  34
compiled vars:  !0 = $entry, !1 = $entryMapper, !2 = $new_info, !3 = $entryArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  241     0  E >   NEW                                              $4      'Entry'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
  242     3        NEW                                              $7      'EntryMapper'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $7
  244     6        INIT_ARRAY                                       ~10     '%E5%A4%AA%E9%83%8E', 'author'
  245     7        ADD_ARRAY_ELEMENT                                ~10     '%E4%BB%8A%E6%97%A5%E3%81%AE%E5%A4%A9%E6%B0%97', 'title'
  246     8        ADD_ARRAY_ELEMENT                                ~10     '%E9%9B%A8%E3%81%A7%E3%81%99', 'content'
  247     9        NEW                                              $11     'DateTime'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~10     $11, 'published'
  243    12        ASSIGN                                                   !2, ~10
  249    13        INIT_METHOD_CALL                                         !0, 'fromArray'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
  250    16        INIT_METHOD_CALL                                         !1, 'insert'
         17        SEND_VAR_EX                                              !0
         18        SEND_VAL_EX                                              <array>
         19        DO_FCALL                                      0          
  252    20        ECHO                                                     '%3Ch4%3E%E3%80%90%24entry%E3%80%91%3C%2Fh4%3E'
  253    21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                                 
  255    24        ECHO                                                     '%3Ch4%3E%E3%80%90%24entryArr%E3%80%91%3C%2Fh4%3E'
  256    25        INIT_METHOD_CALL                                         !0, 'convertTimestampToDatetime'
         26        DO_FCALL                                      0  $17     
         27        INIT_METHOD_CALL                                         $17, 'toArray'
         28        DO_FCALL                                      0  $18     
         29        ASSIGN                                                   !3, $18
  257    30        INIT_FCALL                                               'var_export'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Class DataModel:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/mULe0
function name:  __get
number of ops:  28
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'property_exists'
          2        FETCH_THIS                                       ~1      
          3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > JMPZ                                                     $2, ->10
   37     7    >   FETCH_STATIC_PROP_R          unknown             ~3      !0
          8      > RETURN                                                   ~3
   36     9*       JMP                                                      ->27
   38    10    >   FETCH_OBJ_IS                                     ~4      'data'
         11        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, !0
         12      > JMPZ                                                     ~5, ->17
   39    13    >   FETCH_OBJ_R                                      ~6      'data'
         14        FETCH_DIM_R                                      ~7      ~6, !0
         15      > RETURN                                                   ~7
   38    16*       JMP                                                      ->27
   40    17    >   FETCH_STATIC_PROP_IS                             ~8      'schema'
         18        ISSET_ISEMPTY_DIM_OBJ                         0          ~8, !0
         19      > JMPZ                                                     ~9, ->22
   41    20    > > RETURN                                                   null
   40    21*       JMP                                                      ->27
   43    22    >   NEW                                              $10     'InvalidArgumentException'
         23        CONCAT                                           ~11     !0, '%E3%81%AF%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%BE%E3%81%9B%E3%82%93'
         24        SEND_VAL_EX                                              ~11
         25        DO_FCALL                                      0          
         26      > THROW                                         0          $10
   45    27*     > RETURN                                                   null

End of function __get

Function __isset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mULe0
function name:  __isset
number of ops:  5
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   49     1        FETCH_OBJ_IS                                     ~1      'data'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3      > RETURN                                                   ~2
   50     4*     > RETURN                                                   null

End of function __isset

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 43
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 49
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 55
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
filename:       /in/mULe0
function name:  __set
number of ops:  69
compiled vars:  !0 = $prop, !1 = $val, !2 = $schema
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   57     2        FETCH_STATIC_PROP_IS                             ~3      'schema'
          3        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      ~3, !0
          4        BOOL_NOT                                         ~5      ~4
          5      > JMPZ                                                     ~5, ->11
   58     6    >   NEW                                              $6      'InvalidArgumentException'
          7        CONCAT                                           ~7      !0, '%E3%81%AF%E3%82%BB%E3%83%83%E3%83%88%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%9B%E3%82%93'
          8        SEND_VAL_EX                                              ~7
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $6
   61    11    >   FETCH_STATIC_PROP_R          unknown             ~9      'schema'
         12        FETCH_DIM_R                                      ~10     ~9, !0
         13        ASSIGN                                                   !2, ~10
   63    14        FETCH_CLASS_CONSTANT                             ~12     'DATETIME'
         15        IS_IDENTICAL                                             !2, ~12
         16      > JMPZ                                                     ~13, ->33
   64    17    >   INSTANCEOF                                               !1, 'DateTime'
         18      > JMPZ                                                     ~14, ->23
   65    19    >   FETCH_OBJ_W                                      $15     'data'
         20        ASSIGN_DIM                                               $15, !0
         21        OP_DATA                                                  !1
   64    22      > JMP                                                      ->29
   67    23    >   NEW                                              $19     'DateTime'
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0          
         26        FETCH_OBJ_W                                      $17     'data'
         27        ASSIGN_DIM                                               $17, !0
         28        OP_DATA                                                  $19
   69    29    >   FETCH_OBJ_R                                      ~21     'data'
         30        FETCH_DIM_R                                      ~22     ~21, !0
         31      > RETURN                                                   ~22
   63    32*       JMP                                                      ->68
   72    33    >   FETCH_CLASS_CONSTANT                             ~24     'BOOLEAN'
         34        IS_IDENTICAL                                             !2, ~24
         35      > JMPNZ                                                    ~23, ->43
   73    36    >   FETCH_CLASS_CONSTANT                             ~25     'INTEGER'
         37        IS_IDENTICAL                                             !2, ~25
         38      > JMPNZ                                                    ~23, ->49
   74    39    >   FETCH_CLASS_CONSTANT                             ~26     'DOUBLE'
         40        IS_IDENTICAL                                             !2, ~26
         41      > JMPNZ                                                    ~23, ->55
         42    > > JMP                                                      ->61
   72    43    >   BOOL                                             ~29     !1
         44        FETCH_OBJ_W                                      $27     'data'
         45        ASSIGN_DIM                                       ~28     $27, !0
         46        OP_DATA                                                  ~29
         47        QM_ASSIGN                                        ~30     ~28
         48      > JMP                                                      ->67
   73    49    >   CAST                                          4  ~33     !1
         50        FETCH_OBJ_W                                      $31     'data'
         51        ASSIGN_DIM                                       ~32     $31, !0
         52        OP_DATA                                                  ~33
         53        QM_ASSIGN                                        ~30     ~32
         54      > JMP                                                      ->67
   74    55    >   CAST                                          5  ~36     !1
         56        FETCH_OBJ_W                                      $34     'data'
         57        ASSIGN_DIM                                       ~35     $34, !0
         58        OP_DATA                                                  ~36
         59        QM_ASSIGN                                        ~30     ~35
         60      > JMP                                                      ->67
   75    61    >   CAST                                          6  ~39     !1
         62        FETCH_OBJ_W                                      $37     'data'
         63        ASSIGN_DIM                                       ~38     $37, !0
         64        OP_DATA                                                  ~39
         65        QM_ASSIGN                                        ~30     ~38
         66      > JMP                                                      ->67
         67    > > RETURN                                                   ~30
   78    68*     > RETURN                                                   null

End of function __set

Function toarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mULe0
function name:  toArray
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   82     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   83     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function toarray

Function fromarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/mULe0
function name:  fromArray
number of ops:  11
compiled vars:  !0 = $arr, !1 = $val, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   RECV                                             !0      
   90     1      > FE_RESET_R                                       $3      !0, ->9
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->9
          3    >   ASSIGN                                                   !2, ~4
   91     4        INIT_METHOD_CALL                                         '__set'
          5        SEND_VAR_EX                                              !2
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   90     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $3
   93    10      > RETURN                                                   null

End of function fromarray

Function isvalid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mULe0
function name:  isValid
number of ops:  2
compiled vars:  !0 = $save_type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   95     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function isvalid

Function converttimestamptodatetime:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/mULe0
function name:  convertTimestampToDatetime
number of ops:  23
compiled vars:  !0 = $result, !1 = $data, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   FETCH_THIS                                       ~4      
          1        ASSIGN                                                   !0, ~4
  100     2        ASSIGN                                                   !1, <array>
  101     3        FETCH_OBJ_R                                      ~7      'data'
          4      > FE_RESET_R                                       $8      ~7, ->18
          5    > > FE_FETCH_R                                       ~9      $8, !2, ->18
          6    >   ASSIGN                                                   !3, ~9
  102     7        INSTANCEOF                                               !2, 'DateTime'
          8      > JMPZ                                                     ~11, ->15
  103     9    >   INIT_METHOD_CALL                                         !2, 'format'
         10        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         11        DO_FCALL                                      0  $13     
         12        ASSIGN_DIM                                               !1, !3
         13        OP_DATA                                                  $13
  102    14      > JMP                                                      ->17
  105    15    >   ASSIGN_DIM                                               !1, !3
         16        OP_DATA                                                  !2
  101    17    > > JMP                                                      ->5
         18    >   FE_FREE                                                  $8
  108    19        ASSIGN_OBJ                                               !0, 'data'
         20        OP_DATA                                                  !1
  109    21      > RETURN                                                   !0
  110    22*     > RETURN                                                   null

End of function converttimestamptodatetime

End of class DataModel.

Class DataMapper:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/mULe0
function name:  __construct
number of ops:  29
compiled vars:  !0 = $pdo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  122     0  E >   INIT_FCALL                                               'class_exists'
          1        FETCH_CLASS_CONSTANT                             ~1      'MODEL_CLASS'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        BOOL_NOT                                         ~3      $2
          5      > JMPZ                                                     ~3, ->10
  123     6    >   NEW                                              $4      'InvalidArgumentException'
          7        SEND_VAL_EX                                              'MODEL_CLASS%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%BE%E3%81%9B%E3%82%93'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $4
  125    10    >   ASSERT_CHECK                                             
         11        INIT_FCALL                                               'assert'
         12        FETCH_CLASS_CONSTANT                             ~6      'TABLE_NAME'
         13        BOOL_NOT                                         ~7      ~6
         14        BOOL_NOT                                         ~8      ~7
         15        SEND_VAL                                                 ~8
         16        SEND_VAL                                                 'TABLE_NAME%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%BE%E3%81%9B%E3%82%93'
         17        DO_ICALL                                                 
  128    18        ISSET_ISEMPTY_CV                                         !0
         19      > JMPZ                                                     ~10, ->26
  129    20    >   NEW                                              $11     'PDO'
         21        SEND_VAL_EX                                              'mysql%3Ahost%3Dhost.docker.internal%3Bdbname%3Dtest'
         22        SEND_VAL_EX                                              'test'
         23        SEND_VAL_EX                                              'pass'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !0, $11
  131    26    >   ASSIGN_OBJ                                               'pdo'
         27        OP_DATA                                                  !0
  132    28      > RETURN                                                   null

End of function __construct

Function decorate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mULe0
function name:  decorate
number of ops:  8
compiled vars:  !0 = $stmt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  134     0  E >   RECV                                             !0      
  136     1        INIT_METHOD_CALL                                         !0, 'setFetchMode'
          2        SEND_VAL_EX                                              1048584
          3        FETCH_CLASS_CONSTANT                             ~1      'MODEL_CLASS'
          4        SEND_VAL_EX                                              ~1
          5        DO_FCALL                                      0          
  137     6      > RETURN                                                   !0
  138     7*     > RETURN                                                   null

End of function decorate

Function insert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 74, Position 2 = 94
Branch analysis from position: 74
2 jumps found. (Code = 78) Position 1 = 75, Position 2 = 94
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 85
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
Branch analysis from position: 85
Branch analysis from position: 94
2 jumps found. (Code = 77) Position 1 = 103, Position 2 = 106
Branch analysis from position: 103
2 jumps found. (Code = 78) Position 1 = 104, Position 2 = 106
Branch analysis from position: 104
1 jumps found. (Code = 42) Position 1 = 103
Branch analysis from position: 103
Branch analysis from position: 106
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 106
Branch analysis from position: 94
filename:       /in/mULe0
function name:  insert
number of ops:  108
compiled vars:  !0 = $data, !1 = $omit, !2 = $valided, !3 = $schema, !4 = $pk, !5 = $omitCols, !6 = $cols, !7 = $colsClause, !8 = $valsClause, !9 = $sql, !10 = $sth, !11 = $n, !12 = $col, !13 = $val, !14 = $schemaType, !15 = $omitCol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  140     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
  143     2        INIT_METHOD_CALL                                         !0, 'isValid'
          3        SEND_VAL_EX                                              'insert'
          4        DO_FCALL                                      0  $16     
          5        ASSIGN                                                   !2, $16
  144     6        TYPE_CHECK                                  1014          !2
          7      > JMPZ                                                     ~18, ->13
  145     8    >   NEW                                              $19     'InvalidArgumentException'
          9        CONCAT                                           ~20     !2, '%E3%81%AE%E5%80%A4%E3%81%8C%E4%B8%8D%E6%AD%A3%E3%81%A7%E3%81%99'
         10        SEND_VAL_EX                                              ~20
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $19
  148    13    >   FETCH_OBJ_R                                      ~22     !0, 'schema'
         14        ASSIGN                                                   !3, ~22
  149    15        FETCH_OBJ_R                                      ~24     !0, 'primaryKeyName'
         16        ASSIGN                                                   !4, ~24
  150    17        INIT_FCALL                                               'array_merge'
         18        SEND_VAR                                                 !1
         19        FETCH_OBJ_R                                      ~26     !0, 'omit'
         20        SEND_VAL                                                 ~26
         21        DO_ICALL                                         $27     
         22        ASSIGN                                                   !5, $27
  151    23        INIT_FCALL                                               'array_diff'
         24        INIT_FCALL                                               'array_keys'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $29     
         27        SEND_VAR                                                 $29
         28        INIT_FCALL                                               'array_merge'
         29        INIT_ARRAY                                       ~30     !4
         30        SEND_VAL                                                 ~30
         31        SEND_VAR                                                 !5
         32        DO_ICALL                                         $31     
         33        SEND_VAR                                                 $31
         34        DO_ICALL                                         $32     
         35        ASSIGN                                                   !6, $32
  152    36        INIT_FCALL                                               'implode'
         37        SEND_VAL                                                 '%2C'
         38        SEND_VAR                                                 !6
         39        DO_ICALL                                         $34     
         40        ASSIGN                                                   !7, $34
  153    41        INIT_FCALL                                               'rtrim'
         42        INIT_FCALL                                               'str_repeat'
         43        SEND_VAL                                                 '%3F%2C'
         44        COUNT                                            ~36     !6
         45        SEND_VAL                                                 ~36
         46        DO_ICALL                                         $37     
         47        SEND_VAR                                                 $37
         48        SEND_VAL                                                 '%2C'
         49        DO_ICALL                                         $38     
         50        ASSIGN                                                   !8, $38
  154    51        FETCH_CLASS_CONSTANT                             ~40     'TABLE_NAME'
         52        CONCAT                                           ~41     'INSERT+INTO+', ~40
         53        CONCAT                                           ~42     ~41, '+%28'
         54        CONCAT                                           ~43     ~42, !7
         55        CONCAT                                           ~44     ~43, '%29'
         56        CONCAT                                           ~45     ~44, '+VALUES%28'
         57        CONCAT                                           ~46     ~45, !8
         58        CONCAT                                           ~47     ~46, '%29'
         59        ASSIGN                                                   !9, ~47
  156    60        ECHO                                                     '%3Ch4%3E%E3%80%90%24sql%E3%80%91%3C%2Fh4%3E'
  157    61        INIT_FCALL                                               'var_dump'
         62        SEND_VAR                                                 !9
         63        DO_ICALL                                                 
  159    64        FETCH_OBJ_R                                      ~50     'pdo'
         65        INIT_METHOD_CALL                                         ~50, 'prepare'
         66        SEND_VAR_EX                                           

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
256.21 ms | 1054 KiB | 25 Q