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)='2014'" . " AND MONTH(appts.start)='04'" . " AND DAY(appts.start)='1'" . " AND patients.patient_id = appts.patient_id" . " AND appts.type = appt_types.appt_type_id" . " AND (appts.type='4'" . " OR appts.type='5'" . " OR appts.type='6'" . " OR appts.type='7'" . " OR appts.type='8'" . " OR appts.type='9'" . " OR appts.type='10'" . " OR appts.type='11'" . " OR appts.type='12'" . " OR appts.type='13'" . " OR appts.type='15'" . " OR appts.type='16'" . " OR appts.type='17'" . " )" . " ORDER BY appts.start" . " ASC LIMIT 0,6"; $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/4L5uL
function name:  (null)
number of ops:  11
compiled vars:  !0 = $query, !1 = $q2t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                   !0, '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%272014%27+AND+MONTH%28appts.start%29%3D%2704%27+AND+DAY%28appts.start%29%3D%271%27+AND+patients.patient_id+%3D+appts.patient_id+AND+appts.type+%3D+appt_types.appt_type_id+AND+%28appts.type%3D%274%27+%09OR+appts.type%3D%275%27%09%09OR+appts.type%3D%276%27+%09OR+appts.type%3D%277%27+%09OR+appts.type%3D%278%27+%09OR+appts.type%3D%279%27+%09OR+appts.type%3D%2710%27+%09OR+appts.type%3D%2711%27+%09OR+appts.type%3D%2712%27+%09OR+appts.type%3D%2713%27+%09OR+appts.type%3D%2715%27+%09OR+appts.type%3D%2716%27+%09OR+appts.type%3D%2717%27+%29+ORDER+BY+appts.start+ASC+LIMIT+0%2C6'
   57     1        NEW                                              $3      'query2text'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   58     4        INIT_METHOD_CALL                                         !1, 'convert'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $6      
          7        CONCAT                                           ~7      '%3Chr%3E', $6
          8        CONCAT                                           ~8      ~7, '%3Chr%3E%0A'
          9        ECHO                                                     ~8
         10      > RETURN                                                   1

Class query2text:
Function addline:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4L5uL
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/4L5uL
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:
150.8 ms | 1400 KiB | 15 Q