Wenn ich versuche, print_r ($ Ergebnis) das Array bekommen. Array ([0] => Array ([id] => 6 [0] => 6 [ref] => GSO 646 & 647 [1] => GSO 646 & 647) [1] => Array ([id ] => 7 [0] => 7 [ref] => GSO 962 [1] => GSO 962) [2] => Array ([id] => 8 [0] => 8 [ref] => GSO ASTM F 1923 [1] => GSO ASTM F 1923)Fehler beim Abrufen meines Array MVC
aber ich habe einen Fehler, vielleicht ist das Falsche in der foreach, da es ungültige Lieferungen für foreach() sagt. Jeder kann mir helfen pls? Danke
Modell
require_once("DatabaseManager.php");
class Model
{
public $connection;
public function __construct(){
$connection = new DatabaseManager();
$this->connection = $connection->getConnection();
}
public function getAllRecords()
{
$sql = "SELECT * FROM reference";
$query = $this->connection->query($sql);
$result = $query->fetchAll();
//print_r($result);
}
}
-Controller
require_once("../model/Model.php");
class Controller
{
private $model;
public function __construct()
{
$this->model = new Model();
}
public function displayAllRecords()
{
$result = $this->model->getAllRecords();
return $result;
}
}
VIEW
require '../controller/Controller.php';
$controller = new Controller();
foreach($controller->displayAllRecords() as $records) {
.
.
}
Sie haben etwas von der Steuerung zu machen oder werfen zu können. –
Was bedeutet @SaugatBhattarai? Ich habe versucht, das Ergebnis $ result zu setzen; habe immer noch einen Fehler –
Array ([0] => Array ([id] => 6 [0] => 6 [ref] => GSO 646 & 647 [1] => GSO 646 & 647) [1] => Array ([id ] => 7 [0] => 7 [ref] => GSO 962 [1] => GSO 962) [2] => Array ([id] => 8 [0] => 8 [ref] => GSO ASTM F 1923 [1] => GSO ASTM F 1923) wenn ich print_r ($ result); –