How i make a Stream of a MySQL Table

4 years ago

Member | 11

Hello Guys

Ho i make a Stream of a Mysql Table for a JSON Response? This Response should use for a Angular 1.2 loading Bar in Percantage. Because the latency time is up to 10 seconds.

Something like this:

in ItemsModel something like this:

public function getAllItems($active = 1){
    $data = new \stdClass();
        $db = $this->database;
        $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
        $table = $db->query("SELECT * FROM itmes WHERE active = '$active'")->fetchAll();
        $data->items = $table;
        $data->count = $this->database->query("SELECT COUNT(*) AS counter FROM items WHERE active = '$active'")->fetch();
        return $data;
    } catch (\PDOException $ex) {
        $data->message = "Error: ".$ex->getCode();
        $data->error = true;
        return $data;

or like this in ItemsPresenter:

public function actionItems($id){
    $data = new \stdClass();

    $data = $this->items->getAllItems($id);



Is this the Right Way?

Thanks a lot for your Help!

greets thundervoice