0

I have a Laravel application where I have two PHP files, one of which is basically a wrapper with text lines and a call to a function in the other file.

When I go into powershell and run php refresh.php, it runs the below file but only prints out the lines, it doesn't execute the classes function, it only prints the lines out.

How can I run this refresh file so that it properly executes the refresh function in Q_Temp.php?

Refresh.php

    <? php require_once ('Q_temp.php');


    echo "start \n\n";
    echo Q::refresh();
    echo "\n done \n";
    ?>

Q_temp.php

    Class Q {
      function refresh()
        {
            $sql = "select C, S, P, Q FROM tbl1";
            $result_set = Iseries::runQuery_simple($sql);
            $log = "";
            foreach ($rr as $row) {
                $log .= "EXECUTING: $sql -- ";
                $res = $this->add_new($row['S'], $row['P'], $row['Q'], $row['C']);
                $log .= "$res \n";
            }
            return $log;
          }
        }
1
  • I think that the "correct way" to do this is creating a new Artisan Command. Then run it as php artisan mycommand Commented Jan 28, 2020 at 14:39

1 Answer 1

1

$rr in your foreach loop is undefined.

It should be something like this:

Class Q {
  static function refresh()
    {
        $sql = "select C, S, P, Q FROM tbl1";
        $result_set = Iseries::runQuery_simple($sql);
        $log = "";
        foreach ($result_set as $row) {
            $log .= "EXECUTING: $sql -- ";
            $res = $this->add_new($row['S'], $row['P'], $row['Q'], $row['C']);
            $log .= "$res \n";
        }
        return $log;
      }
    }
Sign up to request clarification or add additional context in comments.

2 Comments

Ah I see that now! So fixing that would allow this to run with my original command?
Ok I did fix that but now it's telling me that on line 6 of the refresh file it can't find class 'Q'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.