本文整理汇总了PHP中DAO::queryOK方法的典型用法代码示例。如果您正苦于以下问题:PHP DAO::queryOK方法的具体用法?PHP DAO::queryOK怎么用?PHP DAO::queryOK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAO
的用法示例。
在下文中一共展示了DAO::queryOK方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeIndex
/**
* Performs the logic for logging into the LWS backend CMS.
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->setLayout('login');
if ($request->isMethod('POST')) {
$dao = new DAO();
$pw = md5($dao->getEscapedSQLString(trim($request->getPostParameter('pw'))));
$email = $dao->getEscapedSQLString(trim(strtolower($request->getPostParameter('email'))));
$dao->query("\n \t\t\tSELECT be_user.*, role \n \t\t\tFROM be_user INNER JOIN be_role USING(role_id) \n \t\t\tWHERE email='{$email}' AND password='{$pw}' LIMIT 1\n \t\t");
if ($dao->queryOK()) {
$user = $dao->next();
$dao->query("SELECT last_login_ts FROM be_user WHERE email='{$user['email']}'");
// I know that there is a record in the DB with this email, so no need to check
$ts_row = $dao->next();
$last_login = is_null($ts_row['last_login_ts']) ? 'N/A' : date('M jS Y @ g:i A', $ts_row['last_login_ts']);
$dao->query("UPDATE be_user SET last_login_ts=UNIX_TIMESTAMP() WHERE email='{$user['email']}'");
$this->getUser()->setAttribute('be_user', array('first_name' => $user['first_name'], 'last_name' => $user['last_name'], 'full_name' => "{$user['first_name']} {$user['last_name']}", 'email' => $user['email'], 'role' => $user['role'], 'phone' => $user['phone'], 'phone_ext' => $user['phone_ext'], 'last_login' => $last_login, 'password' => $user['password']));
$this->getUser()->setAuthenticated(true);
$this->getUser()->addCredential($user['role']);
} else {
if ($this->getUser()->hasAttribute('be_user')) {
$this->getUser()->getAttributeHolder()->remove('be_user');
}
$this->getUser()->setAuthenticated(false);
$this->getUser()->setFlash('login_error', 'Invalid email and/or password!');
}
// allows users to go directly to requested page after login
$uri = $this->getContext()->getRouting()->getCurrentInternalUri(true);
$this->redirect($uri);
}
return sfView::SUCCESS;
}
示例2: createSections
public function createSections(DAO $dao)
{
if ($dao->queryOK()) {
$sections = array();
$row = $dao->next();
$count = $row['cnt'];
$letter = $row[$this->_subcat_field][0];
$first_section = $last_section = $row[$this->_subcat_field];
while ($row = $dao->next()) {
if ($row[$this->_subcat_field][0] == $letter) {
// aggregating mode
$count += $row['cnt'];
$last_section = $row[$this->_subcat_field];
} else {
// section assignment mode
$section = $first_section == $last_section ? $first_section : "{$first_section}-{$last_section}";
$sections[] = array('section' => $section, 'section_slug' => LWS::slugify($section), 'count' => $count);
// update loop values for next section
$count = $row['cnt'];
$letter = $row[$this->_subcat_field][0];
$first_section = $last_section = $row[$this->_subcat_field];
}
}
// end while()
// add last section aggregated
$section = $first_section == $last_section ? $first_section : "{$first_section}-{$last_section}";
$sections[] = array('section' => $section, 'section_slug' => LWS::slugify($section), 'count' => $count);
} else {
$sections = NULL;
}
return $sections;
}