If I try to insert a line to my database, I don't get error or anything, it just simply not working...
Here is my 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 as $value) {
$values .= "?";
if($x < count($fields)) {
$values .= ', ';
}
$x++;
}
$sql = "INSERT INTO {$table} (`" . implode('`, `', $keys) . "`) VALUES ({$values})";
if(!$this->query($sql, $fields)->error()) {
return true;
}
return false;
}
And the 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 as $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 for your help.