我似乎无法让它返回我想要的选项值。
我希望它运行的SQL查询是:
SELECT `profile_value` FROM `login_profiles` WHERE `pfield_id` = 1 AND `user_id` = 1 LIMIT 1
我试过这个
<?php $profile->getOption('1', false, true, '1'); ?>
并且没有id周围的引号,但它没有用。
/**
* 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;
}
由于
答案 0 :(得分:3)
提供的代码不应该做任何事情:
<?php $profile->getOption('1', false, true, '1'); ?>
基于很难猜测我似乎不能让它返回我想要的选项值,但我看到你返回一个HTML属性,所以你可能想做的是
<?php echo $profile->getOption('1', false, true, '1'); ?>