本文整理匯總了PHP中Sql::pSelectRowToObject方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sql::pSelectRowToObject方法的具體用法?PHP Sql::pSelectRowToObject怎麽用?PHP Sql::pSelectRowToObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sql
的用法示例。
在下文中一共展示了Sql::pSelectRowToObject方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getExact
/**
* Used by SessionHandler::login() and others
*/
public static function getExact($type, $id, $name, $pwd)
{
$q = 'SELECT * FROM tblUsers' . ' WHERE id = ? AND name = ? AND type = ? AND time_deleted IS NULL';
$obj = Sql::pSelectRowToObject(__CLASS__, array($q, 'isi', $id, $name, $type));
if (!$obj) {
return false;
}
$x = explode(':', $obj->password);
if (count($x) == 2) {
$algo = $x[0];
$pwd2 = $x[1];
} else {
// auto fallback to old default (sha1)
$algo = 'sha1';
$pwd2 = $obj->password;
}
$session = SessionHandler::getInstance();
$expected = $algo . ":" . $pwd2;
if (Password::encrypt($id, $session->getEncryptKey(), $pwd, $algo) != $expected) {
return false;
}
return $obj;
}
示例2: getByField
public static function getByField($val, $tblname, $classname, $field_name)
{
if (!is_alphanumeric($tblname)) {
throw new \Exception('tblname should be alphanumeric, isnt: ' . $tblname);
}
if (!is_alphanumeric($field_name)) {
throw new \Exception('field_name should be alphanumeric, isnt: ' . $field_name);
}
$form = self::stringForm($val);
$q = 'SELECT * FROM ' . $tblname . ' WHERE ' . $field_name . ' = ?';
return Sql::pSelectRowToObject($classname, array($q, $form, $val));
}