2

I extended the mysqli_result class like this:

class mysqli_Extended extends mysqli {
public function Execute($query) {
    $this->real_query($query);
    return new mysqliResult_Extended($this);
}

public function Insert_Id() {
    return $this->insert_id;
}

public function Affected_Rows() {
    return $this->affected_rows;
}
}

class mysqliResult_Extended extends MySQLi_Result {
public $fields;
public $queryResults;
public $row_count;
public function __construct($opt) {
    parent::__construct($opt);
    $this->queryResults = $this->fetch_all(MYSQLI_BOTH); <-- this is line 28
    $this->fields = $this->queryResults[0];
    $this->row_count = $this->num_rows; <-- this is line 30
    $this->close(); <-- this is line 31
}

public function getrows() {
    return $this->queryResults;
}

public function recordcount() {
    return $this->row_count;
}
}

Everytime I do a query that uses INSERT, I get the following errors:

Warning: mysqli_result::fetch_all() [mysqli-result.fetch-all]: Couldn't fetch mysqliResult_Extended in /home/xxx/xxx/xxx/xxx/dB.class.php on line 28

Warning: mysqliResult_Extended::__construct() [mysqliresult-extended.--construct]: Couldn't fetch mysqliResult_Extended in /home/xxx/xxx/xxx/xxx/dB.class.php on line 30

Warning: mysqli_result::close() [mysqli-result.close]: Couldn't fetch mysqliResult_Extended in /home/xxx/xxx/xxx/xxx/dB.class.php on line 31

Yet no errors if I do a SELECT type of query.

Any ideas what could be causing this?

ReX357
  • 21
  • 1

1 Answers1

1

"I get the following errors:"

Those are not errors - they are warnings.

Try a var_dump($this->queryResults); and see what you get.

My guess is that on one server warnings are suppressed and on the other they aren't.

If you want to suppress warnings you can use the '@' character in front of your function call, or set the error level appropriately as shown in this question.

Community
  • 1
  • 1
barfoon
  • 27,481
  • 26
  • 92
  • 138