我在旧版本中有一个opencart扩展工作,因为现在我更新opencart到新版本,这个停止工作。有谁能帮我修一下吗?
$table = DB_PREFIX . $table;
$result = mysql_query("SHOW COLUMNS FROM $table");
if ($result) {
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$field_array[] = $row['Field'];
}
}
}
if (!in_array($field, $field_array)){
$query = 'ALTER TABLE ' . $table . ' ADD ' . $field . ' ' . $def;
if ($after != NULL){ $query .= " AFTER " . $after;}
$result = $this->db->query($query);
}
}
我得到的错误是:
Unknown: mysql_query(): mysql扩展名已弃用,将来会被删除:请使用mysqli或PDO代替/Applications/XAMPP/xamppfiles/htdocs/opencart/
注意:未定义变量:field_array在/Applications/XAMPP/xamppfiles/htdocs/
警告:in_array()期望参数2为array, null在/Applications/XAMPP/xamppfiles/htdocs/
我正试图修复,从过去的4天,但不能修复。如果我使用:
$result = mysqli_query("SHOW COLUMNS FROM $table");
I got error below
警告:mysqli_query()需要至少2个参数,其中1个在/
中给出
如果我使用:
$result = $this->db->query("SHOW COLUMNS FROM $table");
I got error:
警告:mysql_num_rows()期望参数1是
中给出的resource, object
使用$this->db->query
在openart中运行查询,如下所示:
$result = $this->db->query("SHOW COLUMNS FROM $table");
用$result->num_rows
代替mysql_num_rows
检查Understanding the database object
如何成为一个OpenCart大师?了解更多关于openart数据库对象的信息。