Show
Ignore:
Timestamp:
01/05/2008 05:45:18 PM (12 months ago)
Author:
zombor
Message:

Add preliminary mysqli prepared statement support

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/drivers/Database_Mysqli.php

    r1677 r1683  
    470470        protected $link = NULL; 
    471471        protected $stmt; 
     472        protected $var_names; 
     473        protected $var_values; 
    472474 
    473475        public function __construct($sql, $link) 
     
    486488 
    487489        // Sets the bind parameters 
    488         public function bind_params() 
    489         { 
    490                 $argv = func_get_args(); 
    491                 return $this; 
    492         } 
    493  
    494         // sets the statement values to the bound parameters 
    495         public function set_vals() 
    496         { 
     490        public function bind_params($param_types, $params) 
     491        { 
     492                $this->var_names = array_keys($params); 
     493                $this->var_values = array_values($params); 
     494                call_user_func_array(array($this->stmt, 'bind_param'), array_merge($param_types, $var_names)); 
     495 
    497496                return $this; 
    498497        } 
     
    501500        public function execute() 
    502501        { 
    503                 return $this; 
     502                foreach ($this->var_names as $key => $name) 
     503                { 
     504                        $$name = $this->var_values[$key]; 
     505                } 
     506                $this->stmt->execute(); 
     507                return $this->stmt; 
    504508        } 
    505509}