谁只使用 PERA 的 DB 类?

问题描述 投票:0回答:1

我只想使用 PEAR DB 类,我尝试遵循:

$pearPfad ="PEAR_DB-1.7.14/DB-1.7.14/DB.php";

error_reporting(E_ALL);
require_once($pearPfad);

$DB_dbType ="mysql";
$DB_user = "myuser";
$DB_pass = "mypassword";
$DB_host = "localhost";
$DB_dbName ="mydatabase";

$dsn = $DB_dbType . "://"       // Build a DSN string (Data Source Name)
        . $DB_user . ":"        // Required by DB::connect()
        . $DB_pass . "@"
        . $DB_host . "/"
        . $DB_dbName;

$db = DB::connect($dsn, TRUE);

if (DB::isError($db)) {
    die("FEHLER: ".$db->getMessage() );
}  
$sql = "SELECT id, title , created FROM h1z4e_content";
$res = $db->query($sql);

if (DB::isError($res)) {
    die($res->getMessage());
}

while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
    if (DB::isError($row)) {
    die($row->getMessage());
    }

    print ("<p>Hey, it s:<br />" . $row->id . " " . $row->title . " ... and their freaky et: " . $row->created. "</p>\n");
}

    $res->free();
    // Similar to: mysql_free_resul

$db->disconnect();

但我收到此错误:

警告:require_once(PEAR.php):无法打开流:第30行的/var/www/PEAR/PEAR_DB-1.7.14/DB-1.7.14/DB.php中没有此类文件或目录致命错误:require_once (): 无法打开 /var/www/PEAR/PEAR_DB-1.7.14/DB-1.7 中所需的“PEAR.php”(include_path='.:/usr/share/php:/usr/share/pear')。 14/DB.php 第 30 行

我在 Stack Overflow 中找到了这个链接:PHP-PEAR require_once('DB.php');

我不想在我的计算机上安装 PEAR。
我只想要用户 PEAR DB 类,这可以在不安装 PEAR 的情况下实现吗?

database pear
1个回答
0
投票

是的,但您需要正确设置包含路径 - 根据您的情况,设置为

/full/path/to/PEAR_DB-1.7.14/DB-1.7.14/

© www.soinside.com 2019 - 2024. All rights reserved.