Hi, me again ;-)
So i have this code:
<?php
$db = new db();
$sql = "SELECT id FROM contentobject_attribute WHERE contentobject_id=2
AND contentclassattribute_id=1";
$result = $db->query($sql);
while ($row = $result->fetch_assoc()) {
$result2 = $db->query("SELECT * FROM contentclass");
$version = $result2->fetch_assoc();
echo var_dump($version)."<br />";
}
class db {
private $mysqli;
private $result;
function __construct() {
$this->mysqli = new mysqli("host", "user", "pass", "db");
}
function query($Query_String) {
if ($Query_String == "")
return 0;
// New query, discard previous result.
if ($this->result) {
$this->free();
}
$this->result = $this->mysqli->query($Query_String);
// Will return nada if it fails. That's fine.
return $this->result;
}
function free() {
$this->result->close();
}
}
?>
Try to run it and you get an warning. Now if i replace the free() method
with the following:
function free() {
$this->result->free;
}
everything works as expected. But if i try to use this in my app, apache
segfaults. Wanted to issue an Bug report, but cant reproduce it in an
small example.
So what can i do? Perhaps a small redesign of the class?