├── LICENSE
├── README.md
├── images
├── 0.png
├── 1.png
├── 10.png
├── 11.png
├── 12.png
├── 2.png
├── 3.png
├── 4.1.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
└── 9.png
├── mvc0
├── README.md
└── index.php
├── mvc1
├── Controller.php
├── Model.php
├── README.md
├── index.php
└── views
│ └── index.php
├── mvc10
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ └── index.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── Application.php
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc11
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ ├── index.php
│ │ └── search.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── Application.php
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc12
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ ├── index.php
│ │ └── search.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── Application.php
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc2
├── Controller.php
├── Model.php
├── README.md
├── connection.php
├── db.sql
└── index.php
├── mvc3
└── index.php
├── mvc4
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ └── index.php
│ │ └── products
│ │ └── index.php
├── Core
│ ├── Model.php
│ └── README.md
├── README.md
├── composer.json
├── db.sql
├── index.php
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc5
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ └── index.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ ├── Router.php
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc6
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ └── index.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ ├── Router.php
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc7
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ ├── edit.php
│ │ └── index.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ ├── Router.php
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc8
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ ├── edit.php
│ │ └── index.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── Application.php
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvc9
├── .htaccess
├── App
│ ├── Controllers
│ │ ├── ClientController.php
│ │ └── ProductController.php
│ ├── Models
│ │ ├── Client.php
│ │ └── Product.php
│ └── views
│ │ ├── clients
│ │ └── index.php
│ │ ├── error
│ │ └── index.php
│ │ ├── products
│ │ └── index.php
│ │ └── templates
│ │ ├── footer.php
│ │ └── header.php
├── Core
│ ├── Application.php
│ ├── ErrorController.php
│ ├── Model.php
│ ├── README.md
│ └── config.php
├── README.md
├── composer.json
├── db.sql
├── public
│ ├── .htaccess
│ ├── css
│ │ └── style.css
│ ├── img
│ │ └── demo-image.png
│ ├── index.php
│ └── js
│ │ └── application.js
└── vendor
│ ├── autoload.php
│ └── composer
│ ├── ClassLoader.php
│ ├── LICENSE
│ ├── autoload_classmap.php
│ ├── autoload_namespaces.php
│ ├── autoload_psr4.php
│ ├── autoload_real.php
│ └── autoload_static.php
├── mvcx
├── Migrations
│ ├── 20200415153724_produtos.php
│ ├── 20200415153733_pedidos.php
│ ├── ForeignKey
│ ├── Migrations com Phinx
│ ├── MigrationsCake3.pdf
│ ├── ProdutosSeed.php
│ └── seeds
├── README.md
├── pdox
│ ├── .gitignore
│ ├── .travis.yml
│ ├── DOCS.md
│ ├── LICENCE.md
│ ├── README.md
│ ├── composer.json
│ ├── example.php
│ ├── src
│ │ ├── Cache.php
│ │ ├── Pdox.php
│ │ └── PdoxInterface.php
│ └── tests
│ │ ├── DeleteTest.php
│ │ ├── InsertTest.php
│ │ ├── JoinTest.php
│ │ ├── SelectTest.php
│ │ └── UpdateTest.php
└── tracy-debug.md
└── rotas
├── Router.php
├── Router2.php
├── Routes.md
├── mvc-router-inicial
├── README.md
├── mvc_router_inicial
│ ├── .htaccess
│ ├── README.md
│ ├── composer.json
│ ├── namespace.txt
│ ├── projeto.txt
│ ├── public
│ │ ├── .htaccess
│ │ └── index.php
│ ├── src
│ │ ├── Controller
│ │ │ └── ClientesController.php
│ │ ├── Model
│ │ │ └── ClientesModel.php
│ │ ├── View
│ │ │ └── ClientesView.php
│ │ ├── bootstrap.php
│ │ └── config.php
│ └── vendor
│ │ ├── autoload.php
│ │ └── composer
│ │ ├── ClassLoader.php
│ │ ├── LICENSE
│ │ ├── autoload_classmap.php
│ │ ├── autoload_namespaces.php
│ │ ├── autoload_psr4.php
│ │ ├── autoload_real.php
│ │ └── autoload_static.php
├── mvc_router_inicial2
│ ├── .gitignore
│ ├── .htaccess
│ ├── README.md
│ ├── composer.json
│ ├── public
│ │ ├── .htaccess
│ │ ├── css
│ │ │ └── custom.css
│ │ └── index.php
│ └── src
│ │ ├── Controller
│ │ └── ClientesController.php
│ │ ├── Core
│ │ ├── Model.php
│ │ └── Router.php
│ │ ├── Model
│ │ └── ClientesModel.php
│ │ ├── View
│ │ └── ClientesView.php
│ │ ├── bootstrap.php
│ │ └── config.php
└── mvc_router_inicial3
│ ├── .gitignore
│ ├── .htaccess
│ ├── README.md
│ ├── composer.json
│ ├── public
│ ├── .htaccess
│ └── index.php
│ └── src
│ ├── Controller
│ ├── ClientesController.php
│ └── ErrorController.php
│ ├── Core
│ ├── Model.php
│ └── Router.php
│ ├── Model
│ └── ClientesModel.php
│ ├── View
│ └── ClientesView.php
│ ├── bootstrap.php
│ ├── config.php
│ └── templates
│ ├── _includes
│ ├── footer.php
│ └── header.php
│ ├── clientes
│ ├── add.php
│ ├── edit.php
│ └── index.php
│ └── error
│ └── index.php
└── rota-simples
├── index.php
└── views
├── 404.php
├── about.php
└── index.php
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Ribamar FS
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Criação de um aplicativo em PHP com MVC do "zero"
2 |
3 | ## Muito importante
4 |
5 | Requer o mod_rewrite habilitado e com apache funcionando.
6 |
7 | ## O exemplo mais simples que já vi.
8 |
9 | Do mínimo até algo usável para mostrar bons recursos que são utilizadoso nos grandes frameworks
10 |
11 | Em diversas fases, seguindo da inicial e seguindo em frente.
12 |
13 | ## Gratidão ao Panique
14 | Graças ao seu projeto mini3, consegui criar este projeto.
15 | https://github.com/panique/mini3
16 |
17 | ## Em várias fases
18 |
19 | - Faça o download para seu diretório web
20 | - Crie um banco de dados e importe o script db.sql
21 | - Ajuste o Core/config.php para o banco criado. Veja capturas das várias fases abaixo:
22 |
23 | Fase inicial sem banco, apenas com um array
24 |
25 | 
26 |
27 | 
28 |
29 | 
30 |
31 | 
32 |
33 | 
34 |
35 | 
36 |
37 | 
38 |
39 | 
40 |
41 | 
42 |
43 | 
44 |
45 | 
46 |
47 | 
48 |
49 | 
50 |
51 | 
52 |
53 | ## Licença
54 |
55 | MIT
56 |
57 |
--------------------------------------------------------------------------------
/images/0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/0.png
--------------------------------------------------------------------------------
/images/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/1.png
--------------------------------------------------------------------------------
/images/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/10.png
--------------------------------------------------------------------------------
/images/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/11.png
--------------------------------------------------------------------------------
/images/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/12.png
--------------------------------------------------------------------------------
/images/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/2.png
--------------------------------------------------------------------------------
/images/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/3.png
--------------------------------------------------------------------------------
/images/4.1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/4.1.png
--------------------------------------------------------------------------------
/images/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/4.png
--------------------------------------------------------------------------------
/images/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/5.png
--------------------------------------------------------------------------------
/images/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/6.png
--------------------------------------------------------------------------------
/images/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/7.png
--------------------------------------------------------------------------------
/images/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/8.png
--------------------------------------------------------------------------------
/images/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ribafs/simplest-mvc/a55488c1bfd13baf16f55971f409667584c3948b/images/9.png
--------------------------------------------------------------------------------
/mvc0/README.md:
--------------------------------------------------------------------------------
1 | # Aplicativo em PHP usando MVC partindo do "zero"
2 |
3 | Este fase inicial começa com apenas o arquivo index.php, que contém uma classe Model com um array no lugar do banco de dados, uma classe Controller e a view mostrando o retorno do model.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/mvc0/index.php:
--------------------------------------------------------------------------------
1 | clients;
13 | }
14 | }
15 |
16 | class Controller {
17 |
18 | public function index() {
19 | $list = new Model();
20 | $clients = $list->index();
21 |
22 | return $clients;
23 | }
24 | }
25 | //Importante que a view não vá direto ao model, mas que receba dados do model através do controller
26 | // Original em
27 | // https://elias.praciano.com/2014/08/php-mvc-e-hello-world/
28 | ?>
29 |
30 | MVC Olá Mundo - 0
31 | Lista de Clientes
32 |
33 | Código | Nome | Idade |
34 | index();
38 |
39 | for ($lin=0; $lin<4; $lin++) {
40 | print '
';
41 | for ($col=0; $col<3; $col++) {
42 | echo ''.$clients[$lin][$col].' | ';
43 | }
44 | print '
';
45 | }
46 |
47 | ?>
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/mvc1/Controller.php:
--------------------------------------------------------------------------------
1 | index();
11 |
12 | require_once 'views/index.php';
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/mvc1/Model.php:
--------------------------------------------------------------------------------
1 | clients;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/mvc1/README.md:
--------------------------------------------------------------------------------
1 | # MVC Simples em PHP sem banco de dados
2 |
3 | ## Arquivos
4 |
5 | index.php
6 | Controller.php
7 | Model.php
8 | views/index.php
9 |
10 | ## Fluxo das informações
11 |
12 | Quando o index.php é chamado:
13 |
14 | - inclui o Controller.php
15 | - Instancia o Controller
16 | - Chama o método index() do mesmo
17 |
18 | O Controller é chamado:
19 |
20 | - Ele inclui o Model
21 | - Instancia o model
22 | - Chama seu método index(), que retorna o array $clients e armazena na variável $list;
23 | - Então o Controller inclui o index.php da view.
24 |
25 | Quando o Model é chamado
26 |
27 | - Ele define um array multi dimensional na variável $clients e insere 4 clientes, com código, nome e idade
28 | - Retorna em seu método index() este array
29 | - Este array é recebido pelo Controller
30 |
31 | Quando o index.php é chamado
32 |
33 | - Mostra algum texto explicativo na tela
34 | - Cria uma tabela HTML
35 | - Joga na tabela o resultado de um for trazendo o array $list, vindo do Controller, que recebeu do Model
36 |
37 | No caso a View recebe do Controller e não diretamente do Model, o que é uma boa prática.
38 |
39 |
40 |
--------------------------------------------------------------------------------
/mvc1/index.php:
--------------------------------------------------------------------------------
1 | index();
8 |
9 |
10 |
--------------------------------------------------------------------------------
/mvc1/views/index.php:
--------------------------------------------------------------------------------
1 |
2 | MVC Simples em PHP - 1
3 | Sem banco de dados
4 |
5 | Lista de clientes
6 |
7 |
8 | Código | Nome | Idade |
9 | ';
13 | for ($col=0; $col<3; $col++) {
14 | echo ''.$list[$lin][$col].' | ';
15 | }
16 | print '
';
17 | }
18 |
19 | ?>
20 |
21 |
22 |
--------------------------------------------------------------------------------
/mvc10/.htaccess:
--------------------------------------------------------------------------------
1 | # This file is - if you set up MINI correctly - not needed.
2 | # But, for fallback reasons (if you don't route your vhost to /public), it will stay here.
3 | RewriteEngine on
4 | RewriteRule ^(.*) public/$1 [L]
5 |
--------------------------------------------------------------------------------
/mvc10/App/Controllers/ProductController.php:
--------------------------------------------------------------------------------
1 | index();
12 |
13 | require_once APP . 'views/templates/header.php';
14 | require_once APP . 'views/products/index.php';
15 | require_once APP . 'views/templates/footer.php';
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/mvc10/App/Models/Client.php:
--------------------------------------------------------------------------------
1 | pdo->query("SELECT * FROM clients order by id desc");
10 | $executa = $stmte->execute();
11 | $clients = $stmte->fetchall();
12 |
13 | return $clients;
14 | }
15 |
16 | public function add($nome, $idade)
17 | {
18 | $sql = "INSERT INTO clients (nome, idade) VALUES (:nome, :idade)";
19 | $query = $this->pdo->prepare($sql);
20 | $parameters = array(':nome' => $nome, ':idade' => $idade);
21 | $query->execute($parameters);
22 | }
23 |
24 | public function delete($id)
25 | {
26 | $sql = "DELETE FROM clients WHERE id = :id";
27 | $query = $this->pdo->prepare($sql);
28 | $parameters = array(':id' => $id);
29 | $query->execute($parameters);
30 | }
31 |
32 | public function edit($id)
33 | {
34 | $sql = "SELECT id, nome, idade FROM clients WHERE id = :id LIMIT 1";
35 | $query = $this->pdo->prepare($sql);
36 | $parameters = array(':id' => $id);
37 | $query->execute($parameters);
38 | return ($query->rowCount() ? $query->fetch() : false);
39 | }
40 |
41 | public function update($nome, $idade, $id)
42 | {
43 | $sql = "UPDATE clients SET nome = :nome, idade = :idade WHERE id = :id";
44 | $query = $this->pdo->prepare($sql);
45 | $parameters = array(':nome' => $nome, ':idade' => $idade, ':id' => $id);
46 |
47 | $query->execute($parameters);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/mvc10/App/Models/Product.php:
--------------------------------------------------------------------------------
1 | pdo->query("SELECT * FROM products order by id");
10 | $executa = $stmte->execute();
11 | $products = $stmte->fetchall(\PDO::FETCH_ASSOC); // Para recuperar um Objeto utilize PDO::FETCH_OBJ
12 |
13 | return $products;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/mvc10/App/views/error/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Esta é a página de erros. Verifique que seu controller ou method não existem.
5 |
6 |
--------------------------------------------------------------------------------
/mvc10/App/views/products/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Você está na view: App/views/products/index.php
4 |
5 |
6 |
Lista de produtos
7 |
8 |
9 |
10 |
11 |
12 | Id |
13 | Nome |
14 | Preço |
15 |
16 |
17 |
18 |
19 |
20 | =$product['id']?> |
21 | =$product['nome']?> |
22 | =$product['preco']?> |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/mvc10/App/views/templates/footer.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |