I have written the following class to expediate my use of the MySQLi extension. On winxp, apache2, php5, mysql5 there are no problems, however on fedora 4, apache2, php5, mysql4.1 Whenever I try to create an object of this class I get an error PHP Fatal error: Trying to clone an uncloneable object of class Data in Data.class.php on line 49
What is it about this class that makes it unclonable? Is there something not correct with the constructor?
<?php
class Data extends mysqli {
function __construct($host, $user, $password, $db = null)
{
@parent::__construct($host, $user, $password, $db);
if (mysqli_connect_errno()) {
printf("There was an error (id: %d) connecting to the database:
<b>%s</b><br />", mysqli_connect_errno(), mysqli_connect_error());
}
}
function query($query)
{
$result = parent::query($query);
if ($this->errno) {
printf("There was an error (id: %d) performing your query:
<b>%s</b></br />",
$this->errno, $this->error);
return false;
} else {
return $result;
}
}
function lquery($ary_list, $table, $where = null)
{
$s = null; $list = null;
while ($f = each($ary_list)) {
$list .= $s . $f['key'] . "='" . $f['value'] . "'";
$s = ", ";
}
$type = ($where == null) ? "INSERT INTO" : "UPDATE";
if(!$this->query("$type $table SET $list WHERE $where")) {
return false;
} else {
return true;
}
}
}
$link = new Data("localhost", "root", "password", "database");
?>