You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library show me an sql error:
UPDATE user_accounts SET = 'Perez' WHEREuser_accounts.uacc_id` = '5'
This is because the custom_columns array's keys are numeric instead associative keys (the column names in the user account table):
print_r($user_account_cols);
Array
(
[id] => uacc_id
[group_id] => uacc_group_fk
[email] => uacc_email
[username] => uacc_username
[password] => uacc_password
...
[0] => first_name <-- check the key
[1] => last_name <-- check the key
)
So in the below code
foreach ($this->auth->database_config['user_acc']['custom_columns'] as $column) {
$user_account_cols[] = $column;
}
Change this
foreach ($this->auth->database_config['user_acc']['custom_columns'] as $column) {
$user_account_cols[$column] = $column;
}
Hello again, When i try to update the user's data like this:
// Config Settings
$config['database']['user_acc']['custom_columns'] = array(
'first_name', 'last_name'
);
// Update Code
$user_id = 3;
$user_data = array(
'uacc_password' => 'newpass',
'first_name' => 'Damaso',
'last_name' => 'Pérez'
);
if(!$this->flexi_auth->update_user($user_id, $user_data)){
exit($this->flexi_auth->get_messages());
}
The library show me an sql error:
UPDATE
user_accounts
SET= 'Perez' WHERE
user_accounts.
uacc_id` = '5'This is because the custom_columns array's keys are numeric instead associative keys (the column names in the user account table):
print_r($user_account_cols);
Array
(
[id] => uacc_id
[group_id] => uacc_group_fk
[email] => uacc_email
[username] => uacc_username
[password] => uacc_password
...
[0] => first_name <-- check the key
[1] => last_name <-- check the key
)
So in the below code
foreach ($this->auth->database_config['user_acc']['custom_columns'] as $column) {
$user_account_cols[] = $column;
}
Change this
foreach ($this->auth->database_config['user_acc']['custom_columns'] as $column) {
$user_account_cols[$column] = $column;
}
Now the array keys are
print_r($user_account_cols);
Array
(
[id] => uacc_id
[group_id] => uacc_group_fk
[email] => uacc_email
[username] => uacc_username
[password] => uacc_password
...
[first_name] => first_name
[last_name] => last_name
)
And now change the line
$sql_update[$this->auth->tbl_col_user_account[$key]] = $user_data[$column];
by adding
if(array_key_exists($key, $this->auth->tbl_col_user_account)){
$sql_update[$this->auth->tbl_col_user_account[$key]] = $user_data[$column];
}else{
$sql_update[$key] = $user_data[$column];
}
This works for me!
The text was updated successfully, but these errors were encountered: