Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere is $row defined?
    text
    copied!<p>In the code below, can someone tell me where the variable $row is coming from in the foreach statement?</p> <pre><code>public function getProcResultSet($cmd) { try { $meta = $cmd-&gt;result_metadata(); while ($field = $meta-&gt;fetch_field()) { $params[] = &amp;$row[$field-&gt;name]; } call_user_func_array(array( $cmd, 'bind_result'), $params); while ($cmd-&gt;fetch()) { foreach ($row as $key =&gt; $val) { $c[$key] = $val; } $results[] = $c; } return $results; } catch (Exception $e) { logToFile("Exception: " . $e); return resultFailedUnknown(); } } </code></pre> <p>Edit, here is the caller of this function:</p> <pre><code>public static function getPlayerUnits($playerId, $unitTypeId) { $mysqli = new mysqli(GDB_HOST, GDB_USERNAME, GDB_PASSWORD, GDB_NAME); if ($mysqli-&gt;connect_errno) { throw new Exception('DB Connection Failed. Error Code: ' . $mysqli-&gt;connect_errno); } $cmd = $mysqli-&gt;prepare('CALL sp_get_player_units(?, ?)'); if (!$cmd) { throw new Exception($mysqli-&gt;error); } $cmd-&gt;bind_param('ii', $playerId, $unitTypeId); $cmd-&gt;execute(); $results = parent::getProcResultSet($cmd); $cmd-&gt;close(); $mysqli-&gt;close(); return $results; } </code></pre> <p>Here is the result array which all I did was receive on a client and JSON.stringify(..):</p> <pre><code>[{"Id":1,"Name":"Machine Gunner","Quantity":0},{"Id":2,"Name":"Rocket Soldier","Quantity":0},{"Id":3,"Name":"Paratrooper","Quantity":0},{"Id":4,"Name":"Demolition Soldier","Quantity":0}] </code></pre> <p>As you can see, the result is showing the columns per row as expected.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload