php - PDO insert not working with OOP -


if try insert line database, don't error or anything, not working...

here codes:

the insert line:

$inserted = $user->create(array(     'fb_id' => $userid,     'name' => $userdata->getname(),     'mail' => input::get('first-time-email'),     'password' => hash::make(input::get('first-time-pattern')),     'img' => $userpicture,     'last_ip' => $_server['remote_addr'],     'code' => $salt )); 

the user class:

public function create($fields = array()) {     return $this->_db->insert('users', $fields); } 

the db class:

public function insert($table, $fields = array()) {         $keys   = array_keys($fields);         $values = null;         $x      = 1;          foreach($fields $value) {             $values .= "?";             if($x < count($fields)) {                 $values .= ', ';             }             $x++;         }          $sql = "insert {$table} (`" . implode('`, `', $keys) . "`) values ({$values})";         if(!$this->query($sql, $fields)->error()) {             return true;         }          return false;     } 

and db class's query part:

    public function query($sql, $params = array()) {      $this->_error = false;      if($this->_query = $this->_pdo->prepare($sql)) {         $x = 1;         if(count($params)) {             foreach($params $param) {                 $this->_query->bindvalue($x, $param);                 $x++;             }         }          if($this->_query->execute()) {             $this->_results = $this->_query->fetchall(pdo::fetch_obj);             $this->_count = $this->_query->rowcount();         } else {             $this->_error = true;         }     }      return $this; } 

thanks help.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -