Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class mysqli_extended extends mysqli
- {
- public function __construct($host, $user, $password, $database)
- {
- parent::__construct($host, $user, $password, $database);
- }
- public function prepare($query)
- {
- $stmt = new mysqli_stmt_extended($this, $query);
- return $stmt;
- }
- }
- class mysqli_stmt_extended extends mysqli_stmt
- {
- protected $vars_bound = false;
- protected $results;
- public function __construct($link, $query)
- {
- parent::__construct($link, $query);
- }
- public function fetch_assoc()
- {
- if($this->error)print_r($this->error);
- if(!$this->vars_bound)
- {
- $this->store_result();
- $meta = $this->result_metadata();
- while($column = $meta->fetch_field())
- {
- $bind_var_array[] = &$this->results[str_replace(' ', '_', $column->name)];
- }
- call_user_func_array(array($this, 'bind_result'), $bind_var_array);
- $this->vars_bound = true;
- }
- if($this->fetch() != null)
- {
- foreach($this->results as $k => $v)
- {
- $results[$k] = $v;
- }
- return $results;
- }
- else
- {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment