Olá, enfrento o seguinte erro:
C:\php\php.exe C:\Users\victor.bier\Desktop\Alura\php-pdo\lista-alunos.php
PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1 no such table: students in C:\Users\victor.bier\Desktop\Alura\php-pdo\lista-alunos.php:8
Stack trace:
#0 C:\Users\victor.bier\Desktop\Alura\php-pdo\lista-alunos.php(8): PDO->query()
#1 {main}
thrown in C:\Users\victor.bier\Desktop\Alura\php-pdo\lista-alunos.php on line 8
Process finished with exit code 255
lista-alunos.php:
<?php
require_once 'vendor/autoload.php';
$databasePath = __DIR__ . '/banco.sqlite';
$pdo = new PDO('sqlite:' . $databasePath);
$statement = $pdo->query('SELECT * FROM students;');
var_dump($statement->fetchAll());
conexao.php:
<?php
require_once 'vendor/autoload.php';
$databasePath = __DIR__ . '/banco.sqlite';
$pdo = new PDO('sqlite:' . $databasePath);
$statement = $pdo->query('SELECT * FROM students;');
var_dump($statement->fetchAll());
inserir-aluno.php:
<?php
use Alura\Pdo\Domain\Model\Student;
require_once 'vendor/autoload.php';
$databasePath = __DIR__ . '/banco.sqlite';
$pdo = new PDO('sqlite:' . $databasePath);
$student = new Student(null, 'Victor Hugo', new \DateTimeImmutable('2001-06-10'));
$sqlInsert = "INSERT INTO students (name, birth_date) VALUES ('{$student->name()}', '{$student->birthDate()->format('Y-m-d')}');";
var_dump($pdo->exec($sqlInsert));
projeto-inicial.php:
<?php
use Alura\Pdo\Domain\Model\Student;
require_once 'vendor/autoload.php';
$student = new Student(
null,
'Victor Hugo',
new \DateTimeImmutable('2001-06-10')
);
echo $student->age();
Pesquisei algumas coisas na internet mas não encontrei uma solução, podem me ajudar ?