I want to populate an array with data coming from the database with PHP and MySQL, the array is being populated, but not in the format that would be most functional for the application. Home Is there any way to change the loop to get the idel format of the array?
This is the ideal format for the application:
Array
(
[0] => survey
[1] => processing
[2] => factoring
[3] => closed
[4] => developing
)
Loop to create array:
public function fillArrayPrStatus() {
try {
$this->conn = parent::getConnection();
$this->pQuery = $this->conn->prepare( 'select status_pr_status '.
'from pr_status '.
'where status_pr_lang=:sessionLanguage'
);
$this->pQuery->execute(array( ':sessionLanguage' => session::sessionLanguage() ));
if($this->pQuery->errorCode() == 0) {
$this->get_rows = $this->pQuery->fetchAll();
foreach($this->get_rows as $this->get_row) {
$this->arrayPrStatus[] = $this->get_row;
}
return;
}
else {
throw new Exception();
}
}
catch (Exception $e) {
$tException = new tException();
$tException -> newException($e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
}
}
Result after loop:
Array
(
[0] => Array
(
[status_pr_status] => processing
)
[1] => Array
(
[status_pr_status] => closed
)
[2] => Array
(
[status_pr_status] => developing
)
[3] => Array
(
[status_pr_status] => survey
)
[4] => Array
(
[status_pr_status] => factoring
)
)