title: Php Error. Notice: Undefined property: mysqliConn::$affected_rows
body: <p>I have this code in OOP Php </p>
  
  <pre><code>include ('connection.php');
  
  
  class NestedSet
  {
  /*Properties*/
  
  /**
   * Mysqli object
   * @var object
   */
  protected $db;
  
  /**
   * Name of the database table
   * @var string
   */
  public $table = 'tree';
  
  /**
   * Primary key of the database table
   * @var string
   */
  public $pk = 'id';
  
  /**
   * Namefield in the database table
   * @var unknown_type
   */
  public $name = 'name';
  
  /*Methods*/
  
  /**
   * Stores a Mysqli object for further use
   * @param object $mysqli Mysqli object
   * @return boolean true
   */
  public function __construct() {
      $this-&gt;db = mysqliConn::init();
      return true;
  }
  
   protected static $instance = NULL;
  
  // public static function get_instance()
  // {
  //     //if ( NULL === self::$instance )
  //      //   self::$instance = new self;
  
  //    // return self::$instance;
  // }
  
  /**
   * Creates the root node
   * @param string $name Name of the new node
   * @return boolean true
   */
  
  
  public function createRootNode($name) {
      $this-&gt;db-&gt;query("LOCK TABLES " . $this-&gt;table . " WRITE");
      $sql = "SELECT rgt FROM " . $this-&gt;table . " ORDER BY rgt DESC LIMIT 1";
      $result = $this-&gt;db-&gt;query($sql);
      if ($this-&gt;db-&gt;affected_rows == 0) {
          $lft = 1;
          $rgt = 2;
      } else {
          $obj = $result-&gt;fetch_object();
          $lft = $obj-&gt;rgt + 1;
          $rgt = $lft + 1;
      }
      $sql = "INSERT INTO " . $this-&gt;table . " (" . $this-&gt;name . ", lft, rgt) VALUES ('" . $name . "', " . $lft . ", " . $rgt . ");";
      $this-&gt;db-&gt;query($sql);
      $this-&gt;db-&gt;query("UNLOCK TABLES");
      return true;
  }
  
  
  
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>I create a new object for the class NestedSet in an other file called index.php </p>
  
  <pre><code>    &lt;?php
  
  
      include("nested_set.php");
  
  
  
  
      $nested = new NestedSet(); //Create a NestedSet object
      $nested-&gt;createRootNode('root');
  
      ?&gt;
  </code></pre>
  
  <p>I can write on db but the $rgt and $lft stays 2 and 1;
  and this error is displayd : </p>
  
  <pre><code>"Notice: Undefined property: mysqliConn::$affected_rows in C:\wamp\www\hr-test\nested_set.php on line 67"
  </code></pre>
  
  <p>Any idea on what im doing wrong? 
  Thank you!!</p>
  
  <p>CODE FOR connection.php</p>
  
  <pre><code>   &lt;?php
  
     define('SERVER', 'localhost');
     define('USERNAME', 'root');
     define('PASSWORD', '');
     define('DATABASE', 'hr_test2');
  
   class mysqliConn
   {
   private static $instance;
   private $connection;
  
   private function __construct()
   {
      $this-&gt;connection = new mysqli(SERVER,USERNAME,PASSWORD,DATABASE);
   }
  
   public static function init()
   {
      if(is_null(self::$instance))
      {
          self::$instance = new mysqliConn();
      }
  
      return self::$instance;
   }
  
  
   public function __call($name, $args)
   {
      if(method_exists($this-&gt;connection, $name))
      {
           return call_user_func_array(array($this-&gt;connection, $name),    $args);
      } else {
           trigger_error('Unknown Method ' . $name . '()', E_USER_WARNING);
           return false;
      }
  }
  </code></pre>
  
  <p>}
  ?></p>