php - Issues with returning Array from Connection Class -
i having issue returning array.
this part of connection class.
public function createdataset($incomingsql) { $this->stmt = sqlsrv_query($this->conn, $incomingsql); if ($this->stmt) { $this->rows = sqlsrv_has_rows($this->stmt); if ($this->rows) { while($this->row = sqlsrv_fetch_array($this->stmt, sqlsrv_fetch_numeric)) { $this->myarray[] = $this->row; } } return $this->myarray; //$this->result = $this->row; //return $this->result; } }
and how calling on page...
$conn3 = new connectionclass; $mydataset = $conn3->createdataset('select top (100) city, state, postalcode store'); echo $mydataset[0];
i using echo test.
the $mydataset echoing nothing. can see $myarray fill 100 records when debug, not return it..