Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从数据库中下载的PHP MySQL、MVC中没有记录_Php_Mysql_Oop_Model View Controller - Fatal编程技术网

从数据库中下载的PHP MySQL、MVC中没有记录

从数据库中下载的PHP MySQL、MVC中没有记录,php,mysql,oop,model-view-controller,Php,Mysql,Oop,Model View Controller,我从数据库下载数据时遇到问题,甚至无法将数据捕获到视图中,但我认为我有一个foreach语法错误,但我无法理解这一点 Model/Model.php Model/categoy.php View/categories.php indexCategory.html.php 链接到我在项目中遇到的问题-。您说您试图访问视图中返回的$数据,对吗?那么在视图上,它的category.php?你有一个getAll方法吗?没有,category.php是我的模型,很抱歉这个错误。现在请看我的问题好吧,我开始

我从数据库下载数据时遇到问题,甚至无法将数据捕获到视图中,但我认为我有一个foreach语法错误,但我无法理解这一点

Model/Model.php Model/categoy.php View/categories.php indexCategory.html.php
链接到我在项目中遇到的问题-。

您说您试图访问视图中返回的$数据,对吗?那么在视图上,它的category.php?你有一个getAll方法吗?没有,category.php是我的模型,很抱歉这个错误。现在请看我的问题好吧,我开始错误地思考这个问题,所以问题是第二个模型没有返回预期的结果,但它是var_为您正确地转储它们,对吗?你是如何试图接近他们的,你的话在哪里被打破了??如果可能的话,在你的例子中,它们在标签中看起来更好:-是的,var_dump返回给我很好的结果。我尝试在select方法的第一个模型上使用foreach获取此数据?或者在哪里,一些你还没有共享的代码?哦,好的,在第一次模型破坏时,对。好吧,让我想想,我还没发现有什么问题。。好的,当你说var_dump时,你是说第一个模型中的var_dump,还是说第二个模型工作正常??i、 e.在您的代码示例中,哪个var转储有效,或者哪个有效?
    ...
    public function select($from, $select = '*', $where = NULL, $order = NULL, $limit = NULL) {

        $query = 'SELECT ' . $select . ' FROM ' . $from;
        if ($where != NULL)
             $query = $query.' WHERE '.$where;
        if ($order != NULL)
             $query = $query . ' ORDER BY ' . $order;
        if ($limit != NULL)
            $query = $query . ' LIMIT ' . $limit;

        $select = $this->pdo->query($query);
        foreach ($select as $row) {
            $data[] = $row;
            //var_dump($data);
        }
        $select->closeCursor();

        return $data;
    }
}...
...
    public function getAll() {
    var_dump($this->select('categories'));
    return $this->select('categories');
}
...
<?php

    include 'View/view.php';

    class CategoriesView extends View{
        public function  index() {
            $cat = $this->loadModel('categories');
            $this->set('catsData', $cat->getAll());
            $this->render('indexCategory');
        }
        public function  add() {
            $this->render('addCategory');
        }
    }
    <h1>Lista kategorii</h1>
    <?php foreach($this->get('catsData') as $cats) { ?> <?php } ?>
    <table>
        <tbody>
            <tr>
                <td>Nazwa</td>
                <td></td>
            </tr>
            <tr>
                <td></td>
                <td><a href="?task=categories&action=delete&id=<?php echo $cats['id']; ?>">usun</a></td>
            </tr>
        </tbody>
    </table>