找不到驱动程序 - PDO - AMPPS


Driver not found - PDO - AMPPS

我已经使用 MAMP 几个月了,但今天我安装了 AMPPS。

我将使用数据库,但它不起作用。我收到以下错误:

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /Applications/AMPPS/www/functions.php:13 Stack trace: #0 /Applications/AMPPS/www/functions.php(13): PDO->__construct('mysql:host=loca...', 'root', 'usbw') #1 /Applications/AMPPS/www/functions.php(22): dbConn() #2 /Applications/AMPPS/www/test.php(18): imageDropdown('s') #3 {main} thrown in /Applications/AMPPS/www/functions.php on line 13

法典:

// database connection
function dbConn() {
    $username = "root";
    $password = "usbw";
    $dbh = new PDO(
        'mysql:host=localhost; port=3306; dbname=webshop',
        $username,
        $password
    );
    return $dbh;
}
// dropdown met afbeeldingen
function imageDropdown($zoek) {
    $dbh = dbConn();
    $sth = $dbh -> prepare("
        SELECT afbeelding
        FROM Afbeelding
        WHERE afbeelding LIKE '%:zoek%'
        ORDER BY afbeelding
    ");
    $sth -> bindValue(":zoek", $zoek, PDO::PARAM_STR);
    $sth -> execute();
    $result = $sth -> fetchAll(PDO::FETCH_ASSOC);
    print("<pre>");
    print_r($result);
    print("</pre>");
}

?>

(功能.php)

        <?php
        include "functions.php";
        imageDropdown("s");
    ?>

(测试.php)

缺少

驱动程序,但如何安装它?

我在 Mac 上。

在用户界面中 - PHP 选项卡 - php 扩展。检查是否启用了所需的扩展。喜欢pdo_mysql和PDO