webuser57
webuser57

Reputation: 171

Who user only DB class from PEAR?

I want to use only PEAR DB class, I try follow:

$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();

But I get this error:

Warning: require_once(PEAR.php): failed to open stream: No such file or directory in /var/www/PEAR/PEAR_DB-1.7.14/DB-1.7.14/DB.php on line 30 Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/PEAR/PEAR_DB-1.7.14/DB-1.7.14/DB.php on line 30

I found here in Stack Overflow this link: PHP-PEAR require_once('DB.php');

I don't want install PEAR on my computer.
I want only user PEAR DB class, is this possible without install PEAR?

Upvotes: 1

Views: 75

Answers (1)

cweiske
cweiske

Reputation: 31137

Yes, but you need to set the include path correctly - in your case, to /full/path/to/PEAR_DB-1.7.14/DB-1.7.14/

Upvotes: 0

Related Questions