I can’t seem to get it to return the option value I want.
The sql query which I want it to run is:
SELECT `profile_value` FROM `login_profiles` WHERE `pfield_id` = 1 AND `user_id` = 1 LIMIT 1
I have tried this
<?php $profile->getOption('1', false, true, '1'); ?>
and the same without the quotes around the id’s but it didn’t work.
/**
* Retrieves an option value based on option name.
*
* @param string $option Name of option to retrieve.
* @param bool $check Whether the option is a checkbox.
* @param bool $profile Whether to return a profile field, or an admin setting.
* @param int $id Required if profile is true; the user_id of a user.
* @return string The option value.
*/
public function getOption($option, $check = false, $profile = false, $id = '') {
if (empty($option)) return false;
$option = trim($option);
if ( $profile ) {
$params = array(
':option' => $option,
':id' => $id
);
$sql = "SELECT `profile_value` FROM `login_profiles` WHERE `pfield_id` = :option AND `user_id` = :id LIMIT 1;";
} else {
$params = array( ':option' => $option );
$sql = "SELECT `option_value` FROM `login_settings` WHERE `option_name` = :option LIMIT 1;";
}
$stmt = $this->query($sql, $params);
if(!$stmt) return false;
$result = $stmt->fetch(PDO::FETCH_NUM);
$result = $result ? $result[0] : false;
if($check)
$result = !empty($result) ? 'checked="checked"' : '';
return $result;
}
Thanks
The provided code is not supposed to do anything:
It’s hard to guess based on i cant seem to get it to return the option value i want, but I see you return a HTML attribute, so what you probably want to do is