Skip to content
Snippets Groups Projects
class.orm.php 33.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jared Hancock's avatar
    Jared Hancock committed
            elseif ($status === null) {
                $this->close();
                return false;
            }
            return true;
        }
    
        function getArray() {
            $output = array();
            $variables = array();
    
            if (!isset($this->stmt))
                $this->_prepare();
    
            foreach ($this->fields as $f)
                $variables[] = &$output[$f->name]; // pass by reference
    
            call_user_func_array(array($this->stmt, 'bind_result'), $variables);
            if (!$this->next())
                return false;
            return $output;
        }
    
    
        function getRow() {
            $output = array();
            $variables = array();
    
            if (!isset($this->stmt))
                $this->_prepare();
    
            foreach ($this->fields as $f)
                $variables[] = &$output[]; // pass by reference
    
            call_user_func_array(array($this->stmt, 'bind_result'), $variables);
            if (!$this->next())
                return false;
            return $output;
        }
    
        function getStruct() {
            $output = array();
            $variables = array();
    
            if (!isset($this->stmt))
                $this->_prepare();
    
            foreach ($this->fields as $f)
                $variables[] = &$output[$f->table][$f->name]; // pass by reference
    
            // TODO: Figure out what the table alias for the root model will be
            call_user_func_array(array($this->stmt, 'bind_result'), $variables);
            if (!$this->next())
                return false;
            return $output;
        }
    
    
    Jared Hancock's avatar
    Jared Hancock committed
        function close() {
            if (!$this->stmt)
                return;
    
            $this->stmt->close();
            $this->stmt = null;
        }
    
    
        function affected_rows() {
            return $this->stmt->affected_rows;
        }
    
        function insert_id() {
            return $this->stmt->insert_id;
        }
    
    
    Jared Hancock's avatar
    Jared Hancock committed
        function __toString() {
            return $this->sql;
        }
    }
    ?>