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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Börni

    #1

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

    Hi, me again ;-)
    So i have this code:

    <?php
    $db = new db();
    $sql = "SELECT id FROM contentobject_a ttribute WHERE contentobject_i d=2
    AND contentclassatt ribute_id=1";
    $result = $db->query($sql);
    while ($row = $result->fetch_assoc( )) {
    $result2 = $db->query("SELEC T * FROM contentclass");
    $version = $result2->fetch_assoc( );
    echo var_dump($versi on)."<br />";
    }

    class db {
    private $mysqli;
    private $result;

    function __construct() {
    $this->mysqli = new mysqli("host", "user", "pass", "db");
    }

    function query($Query_St ring) {
    if ($Query_String == "")
    return 0;

    // New query, discard previous result.
    if ($this->result) {
    $this->free();
    }

    $this->result = $this->mysqli->query($Query_S tring);
    // 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

    #2
    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!

    Comment

    • Börni

      #3
      Re: Another Mysql problem. (This Time it is not so dumb)

      Just forget the whole question.

      Have a nice day

      Comment

      Working...