當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Settings::errorInfo方法代碼示例

本文整理匯總了PHP中nzedb\db\Settings::errorInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Settings::errorInfo方法的具體用法?PHP Settings::errorInfo怎麽用?PHP Settings::errorInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nzedb\db\Settings的用法示例。


在下文中一共展示了Settings::errorInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dirname

 * Hopefully that will allow admin access to fix any further problems.
 */
require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\Users;
use nzedb\db\Settings;
$pdo = new Settings();
if ($argc < 3) {
    exit($pdo->log->error('Not enough parameters!' . PHP_EOL . 'Argument 1: New password.' . PHP_EOL . 'Argument 2: ID or username of the user.' . PHP_EOL));
}
$password = $argv[1];
$identifier = $argv[2];
if (is_numeric($password)) {
    exit($pdo->log->error('Password cannot be numbers only!'));
}
$field = is_numeric($identifier) ? 'id' : 'username';
$user = $pdo->queryOneRow(sprintf("SELECT id, username FROM users WHERE %s = %s", $field, is_numeric($identifier) ? $identifier : $pdo->escapeString($identifier)));
if ($user !== false) {
    $users = new Users(['Settings' => $pdo]);
    $hash = $users->hashPassword($password);
    $result = false;
    if ($hash !== false) {
        $hash = $pdo->queryExec(sprintf('UPDATE users SET password = %s WHERE id = %d', $hash, $user['id']));
    }
    if ($result === false || $hash === false) {
        echo $pdo->log->error('An error occured during update attempt.' . PHP_EOL . $pdo->errorInfo());
    } else {
        echo $pdo->log->headerOver("Updated {$user['username']}'s password hash to: ") . $pdo->log->primary("{$hash}");
    }
} else {
    echo $pdo->log->error("Unable to find {$field} '{$identifier}' in the users. Cannot change password.");
}
開發者ID:sebst3r,項目名稱:nZEDb,代碼行數:31,代碼來源:setUserPasswordHash.php


注:本文中的nzedb\db\Settings::errorInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。