/ php

pdo

http://php.net/manual/zh/book.pdo.php

$db = new PDO('sqlite:dinner.db');

$meals = ['breakfast', 'lunch', 'dinner'];
if (in_array($_POST['meal'], $meals)) {
    $stmt = $db->prepare('SELECT dish,price FROM meals WHERE meal LIKE ?');
    $stmt->execute([$_POST['meal']]);
    $rows = $stmt->fetchAll();// 返回数组
}

使用 new PDO() 连接数据库,然后依次使用 prepare() execute() fetchAll() 来执行 sql 并获取数据。