Пример #1
0
function getUserForCode($code)
{
    $rows = DB\simpleSelect('confirmation_codes', 'code = ?', array($code));
    $row = current($rows);
    if ($row == null) {
        throw new InvalidCode("No such confirmation code found ({$code})");
    }
    return User::loadFromID($row['user_id']);
}
Пример #2
0
 public static function loadFromQuery($query, $params)
 {
     $rows = DB\simpleSelect('users', $query, $params);
     if (count($rows) == 0) {
         throw new NoSuchUser("Could not find user for query '{$query}' and parameters " . asString($params));
     }
     $user = new User();
     $user->populateFromRow(current($rows));
     return $user;
 }
Пример #3
0
 function testSignupProcess()
 {
     $this->createHomepageWidgets();
     $this->get('/');
     $this->clickLink("//a[contains(@href, 'signup')]");
     $this->get('/account/signup');
     $this->followRedirects(true);
     $this->submitForm($this->getForm(), array('username' => 'sammy', 'email' => '*****@*****.**', 'password1' => 'luckystars', 'password2' => 'luckystars', 'memorydealers-updates' => 'on'));
     $u = User::loadFromUsername('sammy');
     assertEqual('*****@*****.**', $u->email);
     $subscriptions = current(DB\simpleSelect('subscriptions', 'user_id = ?', array($u->id)));
     assertFalse(empty($subscriptions), 'Expected to find record in subscriptions table for user');
     assertTrue($subscriptions['chipin'] == false || $subscriptions['chipin'] == 0);
     assertTrue($subscriptions['memorydealers'] == true || $subscriptions['memorydealers'] == 1);
     $this->logout();
     $this->login('sammy', 'luckystars');
     $this->get('/dashboard/');
     assertTrue(beginsWith($this->getCurrentPath(), '/dashboard'));
 }
Пример #4
0
function lastPriceForOneBTC($currency)
{
    $rows = DB\simpleSelect('ticker_data', 'currency = ?', array($currency));
    $row = current($rows);
    if (empty($row)) {
        throw new DB\NoMatchingRecords("Could not find exchange-rate (in 'ticker_data' table) " . "for currency '{$currency}''");
    }
    return doubleval($row['last_price']);
}