3v4l.org

run code in 300+ PHP versions simultaneously
<?php // This library is to rewrite MSYQL queries into formatted text class query2text { private $key_arr; public function addline ($query,$keyword) { $fixed = str_ireplace(" ".$keyword,"<br>&nbsp;".$keyword,$query); return $fixed; } public function convert($query) { $key_arr = array("FROM","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","WHERE","AND","OR","ORDER","GROUP"); foreach($key_arr AS $key) { $query = $this->addline($query,$key); } $query .= "<br><br>\n"; return $query; } } $query = "SELECT patients.patient_id,patients.last_name,patients.first_name,appts.*,appt_types.type,appt_types.color,appt_types.bgcolor" . ",DATE_FORMAT(appts.start,'%m/%d/%Y') AS date" . ",DATE_FORMAT(appts.start,'%h:%i %p') AS time" . ",TIMEDIFF(appts.end,appts.start) AS duration" . " FROM patients,appts,appt_types" . " WHERE appts.cancelled IS NULL" . " AND YEAR(appts.start)='" . $year . "'" . " AND MONTH(appts.start)='" . $month . "'" . " AND DAY(appts.start)='" . $day . "'" . " AND patients.patient_id = appts.patient_id" . " AND appts.type = appt_types.appt_type_id"; $q2t = new query2text(); echo "<hr>" . $q2t->convert($query) . "<hr>\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3TqDc
function name:  (null)
number of ops:  21
compiled vars:  !0 = $query, !1 = $year, !2 = $month, !3 = $day, !4 = $q2t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   CONCAT                                           ~5      'SELECT+patients.patient_id%2Cpatients.last_name%2Cpatients.first_name%2Cappts.%2A%2Cappt_types.type%2Cappt_types.color%2Cappt_types.bgcolor%2CDATE_FORMAT%28appts.start%2C%27%25m%2F%25d%2F%25Y%27%29+AS+date%2CDATE_FORMAT%28appts.start%2C%27%25h%3A%25i+%25p%27%29+AS+time%2CTIMEDIFF%28appts.end%2Cappts.start%29+AS+duration+FROM+patients%2Cappts%2Cappt_types+WHERE+appts.cancelled+IS+NULL+AND+YEAR%28appts.start%29%3D%27', !1
          1        CONCAT                                           ~6      ~5, '%27'
   35     2        CONCAT                                           ~7      ~6, '+AND+MONTH%28appts.start%29%3D%27'
          3        CONCAT                                           ~8      ~7, !2
          4        CONCAT                                           ~9      ~8, '%27'
   36     5        CONCAT                                           ~10     ~9, '+AND+DAY%28appts.start%29%3D%27'
          6        CONCAT                                           ~11     ~10, !3
          7        CONCAT                                           ~12     ~11, '%27'
   37     8        CONCAT                                           ~13     ~12, '+AND+patients.patient_id+%3D+appts.patient_id'
   38     9        CONCAT                                           ~14     ~13, '+AND+appts.type+%3D+appt_types.appt_type_id'
   28    10        ASSIGN                                                   !0, ~14
   41    11        NEW                                              $16     'query2text'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !4, $16
   42    14        INIT_METHOD_CALL                                         !4, 'convert'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $19     
         17        CONCAT                                           ~20     '%3Chr%3E', $19
         18        CONCAT                                           ~21     ~20, '%3Chr%3E%0A'
         19        ECHO                                                     ~21
         20      > RETURN                                                   1

Class query2text:
Function addline:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3TqDc
function name:  addline
number of ops:  12
compiled vars:  !0 = $query, !1 = $keyword, !2 = $fixed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        INIT_FCALL                                               'str_ireplace'
          3        CONCAT                                           ~3      '+', !1
          4        SEND_VAL                                                 ~3
          5        CONCAT                                           ~4      '%3Cbr%3E%26nbsp%3B', !1
          6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !2, $5
   12    10      > RETURN                                                   !2
   13    11*     > RETURN                                                   null

End of function addline

Function convert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/3TqDc
function name:  convert
number of ops:  14
compiled vars:  !0 = $query, !1 = $key_arr, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $4      !1, ->10
          3    > > FE_FETCH_R                                               $4, !2, ->10
   20     4    >   INIT_METHOD_CALL                                         'addline'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $5      
          8        ASSIGN                                                   !0, $5
   18     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $4
   22    11        ASSIGN_OP                                     8          !0, '%3Cbr%3E%3Cbr%3E%0A'
   23    12      > RETURN                                                   !0
   24    13*     > RETURN                                                   null

End of function convert

End of class query2text.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.08 ms | 1400 KiB | 15 Q