Connecting Tech Pros Worldwide Help | Site Map

Another Mysql problem. (This Time it is not so dumb)

Börni
Guest
 
Posts: n/a
#1: Jul 17 '05
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?
Börni
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Another Mysql problem. (This Time it is not so dumb)


[color=blue]
> 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.[/color]
Just forget that crap!
Börni
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Another Mysql problem. (This Time it is not so dumb)


Just forget the whole question.

Have a nice day
Closed Thread