Ejemplo n.º 1
0
 function __call($fnName, $args)
 {
     if (in_array($fnName, self::$functionExceptions)) {
         return call_user_func_array(array($this, $fnName), $args);
     }
     //get node (since all private functions require it)
     $node = $args[0] = $this->getNode($args[0]);
     if ($this->fkColumn) {
         $this->baseWhere[$this->fkColumn] = $node[$this->fkColumn];
     }
     //get foreign key to localise lock
     $lockName = 'DbTree-' . $this->table;
     if ($this->fkColumn) {
         $lockName .= '-' . $node[$this->fkColumn];
     }
     $this->__methodExists($fnName);
     Lock::req($lockName, 2);
     $this->db->db->beginTransaction();
     try {
         $return = call_user_func_array(array($this, $fnName), $args);
         $this->db->db->commit();
     } catch (Exception $e) {
         Lock::off($lockName);
         $this->db->db->rollBack();
         throw $e;
     }
     Lock::off($lockName);
     return $return;
 }