3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo 'start'; function recuperation_info_product_et_decrementation($reference, $qty, $isDeclinaison){ /* Fonction de récupèration et décrementation produit */ $product_infos = array(); $tables = array('product_attribute'); if($isDeclinaison === false) { array_unshift($tables, 'product'); } foreach($tables as $table) { $query = 'SELECT * FROM `'._DB_PREFIX_.$table.'` WHERE `reference` = "'.$reference.'";'; $result = Db::getInstance()->executeS($query); if($result !== false) { $product_infos = $result[0]; decremente_stock($product_infos['id_product'], $qty, $reference, $table); //break; } } return $product_infos; } /* fonction qui retourne l'IdProduct et l'IdProductAttribute du produit commandé */ function recuperation_idProduct_idProductAttribute($reference){ $product_infos = array(); $query = 'SELECT * FROM `'._DB_PREFIX_.'product` WHERE `reference` = "'.pSQL($reference).'";'; $result = Db::getInstance()->executeS($query); $product_infos['id_product'] = $result[0]['id_product']; $query = 'SELECT * FROM `'._DB_PREFIX_.'product_attribute` WHERE `reference` = "'.pSQL($reference).'";'; $result = Db::getInstance()->executeS($query); $product_infos['id_product_attribute'] = $result[0]['id_product_attribute']; return $product_infos; } function decremente_stock($id_product, $qty, $reference, $table) { global $version_sup_egale_1531; switch ($GLOBALS['versionPourSwitch']){ case '1.5.4.0': // [-] Core: Hook actionUpdateQuantity was not called for product without attributes which depends on the physical stock $query = ' UPDATE `'._DB_PREFIX_.'stock_available` SET quantity = (quantity - "'.$qty.'") WHERE id_product = "'.$id_product.'" AND `reference` = "'.$reference.'";'; Db::getInstance()->execute($query); $query2 = ' UPDATE `'._DB_PREFIX_.'stock` SET physical_quantity = (physical_quantity - "'.$qty.'") WHERE id_product = "'.$id_product.'" AND `reference` = "'.$reference.'";'; Db::getInstance()->execute($query2); break; default: if($version_sup_egale_1531) { $query = ' UPDATE `'._DB_PREFIX_.'stock_available` SET quantity = (quantity - "'.$qty.'") WHERE id_product = "'.$id_product.'" AND `reference` = "'.$reference.'";'; } else { $query = ' UPDATE `'._DB_PREFIX_.$table.'` SET quantity = (quantity - "'.$qty.'") WHERE id_product = "'.$id_product.'" AND `reference` = "'.$reference.'";'; } Db::getInstance()->execute($query); break; } } echo 'done';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R5pi6
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ECHO                                                     'start'
   74     1        ECHO                                                     'done'
          2      > RETURN                                                   1

Function recuperation_info_product_et_decrementation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 39
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 39
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 38
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 38
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 11
filename:       /in/R5pi6
function name:  recuperation_info_product_et_decrementation
number of ops:  42
compiled vars:  !0 = $reference, !1 = $qty, !2 = $isDeclinaison, !3 = $product_infos, !4 = $tables, !5 = $table, !6 = $query, !7 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        ASSIGN                                                   !3, <array>
    5     4        ASSIGN                                                   !4, <array>
    7     5        TYPE_CHECK                                    4          !2
          6      > JMPZ                                                     ~10, ->11
    8     7    >   INIT_FCALL                                               'array_unshift'
          8        SEND_REF                                                 !4
          9        SEND_VAL                                                 'product'
         10        DO_ICALL                                                 
   11    11    > > FE_RESET_R                                       $12     !4, ->39
         12    > > FE_FETCH_R                                               $12, !5, ->39
   12    13    >   FETCH_CONSTANT                                   ~13     '_DB_PREFIX_'
         14        CONCAT                                           ~14     'SELECT+%2A+FROM+%60', ~13
         15        CONCAT                                           ~15     ~14, !5
         16        CONCAT                                           ~16     ~15, '%60+WHERE+%60reference%60+%3D+%22'
         17        CONCAT                                           ~17     ~16, !0
         18        CONCAT                                           ~18     ~17, '%22%3B'
         19        ASSIGN                                                   !6, ~18
   13    20        INIT_STATIC_METHOD_CALL                                  'Db', 'getInstance'
         21        DO_FCALL                                      0  $20     
         22        INIT_METHOD_CALL                                         $20, 'executeS'
         23        SEND_VAR_EX                                              !6
         24        DO_FCALL                                      0  $21     
         25        ASSIGN                                                   !7, $21
   14    26        TYPE_CHECK                                  1018          !7
         27      > JMPZ                                                     ~23, ->38
   15    28    >   FETCH_DIM_R                                      ~24     !7, 0
         29        ASSIGN                                                   !3, ~24
   16    30        INIT_FCALL_BY_NAME                                       'decremente_stock'
         31        CHECK_FUNC_ARG                                           
         32        FETCH_DIM_FUNC_ARG                               $26     !3, 'id_product'
         33        SEND_FUNC_ARG                                            $26
         34        SEND_VAR_EX                                              !1
         35        SEND_VAR_EX                                              !0
         36        SEND_VAR_EX                                              !5
         37        DO_FCALL                                      0          
   11    38    > > JMP                                                      ->12
         39    >   FE_FREE                                                  $12
   21    40      > RETURN                                                   !3
   22    41*     > RETURN                                                   null

End of function recuperation_info_product_et_decrementation

Function recuperation_idproduct_idproductattribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R5pi6
function name:  recuperation_idProduct_idProductAttribute
number of ops:  42
compiled vars:  !0 = $reference, !1 = $product_infos, !2 = $query, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        ASSIGN                                                   !1, <array>
   28     2        FETCH_CONSTANT                                   ~5      '_DB_PREFIX_'
          3        CONCAT                                           ~6      'SELECT+%2A+FROM+%60', ~5
          4        CONCAT                                           ~7      ~6, 'product%60+WHERE+%60reference%60+%3D+%22'
          5        INIT_FCALL_BY_NAME                                       'pSQL'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $8      
          8        CONCAT                                           ~9      ~7, $8
          9        CONCAT                                           ~10     ~9, '%22%3B'
         10        ASSIGN                                                   !2, ~10
   29    11        INIT_STATIC_METHOD_CALL                                  'Db', 'getInstance'
         12        DO_FCALL                                      0  $12     
         13        INIT_METHOD_CALL                                         $12, 'executeS'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !3, $13
   30    17        FETCH_DIM_R                                      ~16     !3, 0
         18        FETCH_DIM_R                                      ~17     ~16, 'id_product'
         19        ASSIGN_DIM                                               !1, 'id_product'
         20        OP_DATA                                                  ~17
   32    21        FETCH_CONSTANT                                   ~18     '_DB_PREFIX_'
         22        CONCAT                                           ~19     'SELECT+%2A+FROM+%60', ~18
         23        CONCAT                                           ~20     ~19, 'product_attribute%60+WHERE+%60reference%60+%3D+%22'
         24        INIT_FCALL_BY_NAME                                       'pSQL'
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0  $21     
         27        CONCAT                                           ~22     ~20, $21
         28        CONCAT                                           ~23     ~22, '%22%3B'
         29        ASSIGN                                                   !2, ~23
   33    30        INIT_STATIC_METHOD_CALL                                  'Db', 'getInstance'
         31        DO_FCALL                                      0  $25     
         32        INIT_METHOD_CALL                                         $25, 'executeS'
         33        SEND_VAR_EX                                              !2
         34        DO_FCALL                                      0  $26     
         35        ASSIGN                                                   !3, $26
   34    36        FETCH_DIM_R                                      ~29     !3, 0
         37        FETCH_DIM_R                                      ~30     ~29, 'id_product_attribute'
         38        ASSIGN_DIM                                               !1, 'id_product_attribute'
         39        OP_DATA                                                  ~30
   36    40      > RETURN                                                   !1
   37    41*     > RETURN                                                   null

End of function recuperation_idproduct_idproductattribute

Function decremente_stock:
Finding entry points
Branch analysis from position: 0
3 jumps found. (Code = 188) Position 1 = 11, Position 2 = 42, Position 3 = 8
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 54
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 11
filename:       /in/R5pi6
function name:  decremente_stock
number of ops:  73
compiled vars:  !0 = $id_product, !1 = $qty, !2 = $reference, !3 = $table, !4 = $version_sup_egale_1531, !5 = $query, !6 = $query2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   40     4        BIND_GLOBAL                                              !4, 'version_sup_egale_1531'
   42     5        FETCH_R                      global              ~7      'GLOBALS'
          6        FETCH_DIM_R                                      ~8      ~7, 'versionPourSwitch'
          7      > SWITCH_STRING                                            ~8, [ '1.5.4.0':->11, ], ->42
   43     8    >   CASE                                                     ~8, '1.5.4.0'
          9      > JMPNZ                                                    ~9, ->11
         10    > > JMP                                                      ->42
   44    11    >   FETCH_CONSTANT                                   ~10     '_DB_PREFIX_'
         12        CONCAT                                           ~11     '%09UPDATE+%60', ~10
         13        CONCAT                                           ~12     ~11, 'stock_available%60+%0A%09%09%09%09%09%09SET+quantity+%3D+%28quantity+-+%22'
   45    14        CONCAT                                           ~13     ~12, !1
         15        CONCAT                                           ~14     ~13, '%22%29+%0A%09%09%09%09%09%09WHERE+id_product+%3D+%22'
   46    16        CONCAT                                           ~15     ~14, !0
         17        CONCAT                                           ~16     ~15, '%22+%0A%09%09%09%09%09%09AND+%60reference%60+%3D+%22'
   47    18        CONCAT                                           ~17     ~16, !2
         19        CONCAT                                           ~18     ~17, '%22%3B'
   44    20        ASSIGN                                                   !5, ~18
   48    21        INIT_STATIC_METHOD_CALL                                  'Db', 'getInstance'
         22        DO_FCALL                                      0  $20     
         23        INIT_METHOD_CALL                                         $20, 'execute'
         24        SEND_VAR_EX                                              !5
         25        DO_FCALL                                      0          
   49    26        FETCH_CONSTANT                                   ~22     '_DB_PREFIX_'
         27        CONCAT                                           ~23     '%09UPDATE+%60', ~22
         28        CONCAT                                           ~24     ~23, 'stock%60+%0A%09%09%09%09%09%09SET+physical_quantity+%3D+%28physical_quantity+-+%22'
   50    29        CONCAT                                           ~25     ~24, !1
         30        CONCAT                                           ~26     ~25, '%22%29+%0A%09%09%09%09%09%09WHERE+id_product+%3D+%22'
   51    31        CONCAT                                           ~27     ~26, !0
         32        CONCAT                                           ~28     ~27, '%22+%0A%09%09%09%09%09%09AND+%60reference%60+%3D+%22'
   52    33        CONCAT                                           ~29     ~28, !2
         34        CONCAT                                           ~30     ~29, '%22%3B'
   49    35        ASSIGN                                                   !6, ~30
   53    36        INIT_STATIC_METHOD_CALL                                  'Db', 'getInstance'
         37        DO_FCALL                                      0  $32     
         38        INIT_METHOD_CALL                                         $32, 'execute'
         39        SEND_VAR_EX                                              !6
         40        DO_FCALL                                      0          
   54    41      > JMP                                                      ->71
   56    42    > > JMPZ                                                     !4, ->54
   57    43    >   FETCH_CONSTANT                                   ~34     '_DB_PREFIX_'
         44        CONCAT                                           ~35     '%09UPDATE+%60', ~34
         45        CONCAT                                           ~36     ~35, 'stock_available%60+%0A%09%09%09%09%09%09%09SET+quantity+%3D+%28quantity+-+%22'
   58    46        CONCAT                                           ~37     ~36, !1
         47        CONCAT                                           ~38     ~37, '%22%29+%0A%09%09%09%09%09%09%09WHERE+id_product+%3D+%22'
   59    48        CONCAT                                           ~39     ~38, !0
         49        CONCAT                                           ~40     ~39, '%22+%0A%09%09%09%09%09%09%09AND+%60reference%60+%3D+%22'
   60    50        CONCAT                                           ~41     ~40, !2
         51        CONCAT                                           ~42     ~41, '%22%3B'
   57    52        ASSIGN                                                   !5, ~42
         53      > JMP                                                      ->65
   63    54    >   FETCH_CONSTANT                                   ~44     '_DB_PREFIX_'
         55        CONCAT                                           ~45     '%09UPDATE+%60', ~44
         56        CONCAT                                           ~46     ~45, !3
         57        CONCAT                                           ~47     ~46, '%60+%0A%09%09%09%09%09%09%09SET+quantity+%3D+%28quantity+-+%22'
   64    58        CONCAT                                           ~48     ~47, !1
         59        CONCAT                                           ~49     ~48, '%22%29+%0A%09%09%09%09%09%09%09WHERE+id_product+%3D+%22'
   65    60        CONCAT                                           ~50     ~49, !0
         61        CONCAT                                           ~51     ~50, '%22+%0A%09%09%09%09%09%09%09AND+%60reference%60+%3D+%22'
   66    62        CONCAT                                           ~52     ~51, !2
         63        CONCAT                                           ~53     ~52, '%22%3B'
   63    64        ASSIGN                                                   !5, ~53
   68    65    >   INIT_STATIC_METHOD_CALL                                  'Db', 'getInstance'
         66        DO_FCALL                                      0  $55     
         67        INIT_METHOD_CALL                                         $55, 'execute'
         68        SEND_VAR_EX                                              !5
         69        DO_FCALL                                      0          
   69    70      > JMP                                                      ->71
         71    >   FREE                                                     ~8
   71    72      > RETURN                                                   null

End of function decremente_stock

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.08 ms | 1412 KiB | 15 Q