Reputation: 517
I Changed my domain and hosting and I moved all the code from the first host to another with a database. Now, I'm getting an error in open-cart 1.5.6
PHP Fatal error: Call to undefined method mysqli::escape() in /home/l/beta4/system/library/db.php on line 24
My hosting is Godaddy.
And here is my db.php code
<?php
class DB {
private $driver;
public function __construct($driver, $hostname, $username, $password, $database) {
$file = DIR_DATABASE . $driver . '.php';
if (file_exists($file)) {
require_once($file);
$class = 'DB' . $driver;
$this->driver = new $driver($hostname, $username, $password, $database);
} else {
exit('Error: Could not load database driver type ' . $driver . '!');
}
}
public function query($sql) {
return $this->driver->query($sql);
}
public function escape($value) {
return $this->driver->escape($value);
}
public function countAffected() {
return $this->driver->countAffected();
}
public function getLastId() {
return $this->driver->getLastId();
}
}
?>
and line number 24 code is
public function escape($value) { return $this->driver->escape($value); }
Upvotes: 1
Views: 3049
Reputation: 1517
It looks like Open Cart 1.5.6 doesn't really support mysqli? Not sure.
I used MySQLiz module to work around that problem:
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=13041
Upvotes: 1
Reputation: 22941
You either updated Opencart, changed your DB driver or both. You should make sure you include details like that in your question.
The DB class has a bug in 1.5.6 - Change the line that reads:
$this->driver = new $driver($hostname, $username, $password, $database);
to
$this->driver = new $class($hostname, $username, $password, $database);
Also, you should replace the mysqli driver system/database/mysqli.php with the version from 1.5.6.4 which can be downloaded here or after:
$this->link->set_charset("utf8");
add
$this->link->query("SET SQL_MODE = ''");
Upvotes: 2