本文整理汇总了PHP中Zend_Db_Table::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table::select方法的具体用法?PHP Zend_Db_Table::select怎么用?PHP Zend_Db_Table::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table
的用法示例。
在下文中一共展示了Zend_Db_Table::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
/**
* Returns id by name($value) from table
*
* @param string $value
* @return string
*/
public function filter($value)
{
if ($value === null) {
return null;
}
$select = $this->_table->select()->where($this->_field . ' = ?', $value);
$row = $this->_table->fetchRow($select);
if ($row !== null) {
return $row[reset($this->_table->info(Zend_Db_Table::PRIMARY))];
} else {
return null;
}
}
示例2: setup
/**
* (non-PHPdoc)
* @see models/Sahara/Auth/Sahara_Auth_Session::setup()
*/
public function setup()
{
$table = new Zend_Db_Table('users');
$record = $table->fetchRow($table->select()->where('name = ?', $this->_authType->getUsername())->where('namespace = ?', $this->_config->institution));
/* User name exists, so no need to create account. */
if ($record) {
return;
}
$table->insert(array('name' => $this->_authType->getUsername(), 'namespace' => $this->_config->institution, 'persona' => 'USER'));
}
示例3: getLastAccess
public static function getLastAccess($classroomId, $data)
{
$access = new Zend_Db_Table('content_access');
$select = $access->select()->where('classroom_id = ?', $classroomId)->order('content_access.id DESC');
$row = $access->fetchRow($select);
if ($row) {
return self::getPositionById($row->content_id, $data);
}
return 0;
}
示例4: getReceivers
public function getReceivers($pairs = false)
{
$triggersTable = new Zend_Db_Table('email_triggers_recipient');
if ($pairs) {
$select = $triggersTable->select();
return $triggersTable->getAdapter()->fetchPairs($select);
} else {
return $triggersTable->fetchAll()->toArray();
}
}
示例5: indexAction
public function indexAction()
{
$page = Zend_Filter::filterStatic($this->_getParam('page'), 'int');
$query = Zend_Filter::filterStatic($this->_getParam('query'), 'alnum');
$table = new Zend_Db_Table('course');
$select = $table->select()->order('status');
if ($query) {
$select->where('name LIKE (?)', "%{$query}%");
}
$paginator = new Tri_Paginator($select, $page);
$this->view->data = $paginator->getResult();
}
示例6: addSite
/**
* Stores information about trusted/untrusted site for given user
*
* @param string $id user identity URL
* @param string $site site URL
* @param mixed $trusted trust data from extensions or just a boolean value
* @return bool
*/
public function addSite($id, $site, $trusted)
{
if (is_null($trusted)) {
$this->_sitesTable->select()->where('site = ?', $site);
$this->_sitesTable->delete($where);
return true;
}
$row = $this->_sitesTable->createRow();
$row->openid = $id;
$row->site = $site;
$row->time = date('Y-m-d H:i:s O');
$row->trusted = serialize($trusted);
$row->save();
return true;
}
示例7: _init
private function _init()
{
global $logger;
$oTable = new Zend_Db_Table('path');
foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
$this->_path[] = $xt['name'];
}
$oTable = new Zend_Db_Table('container');
$t = array();
foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
$t[] = $xt['name'];
}
$this->_extensions = implode(',', $t);
$logger->log('Valid extensions are : ' . $this->_extensions, Zend_Log::DEBUG);
}
示例8: indexAction
/**
* Action index.
*
* @return void
*/
public function indexAction()
{
$page = Zend_Filter::filterStatic($this->_getParam('page'), 'int');
$query = $this->_getParam('query');
$table = new Zend_Db_Table('user');
$select = $table->select()->order('name');
if ($query) {
$parts = explode(' ', $query);
foreach ($parts as $part) {
$select->where('name LIKE ?', "%{$part}%");
}
$select->orWhere('email LIKE ?', "%{$query}%");
}
$paginator = new Tri_Paginator($select, $page);
$this->view->data = $paginator->getResult();
}
示例9: indexAction
/**
* Action index.
*
* @return void
*/
public function indexAction()
{
$user = Zend_Auth::getInstance()->getIdentity();
if ('student' == $user->role) {
$this->_redirect('selection-process/index/view/user/' . $user->id);
}
$page = Zend_Filter::filterStatic($this->_getParam('page'), 'int');
$query = Zend_Filter::filterStatic($this->_getParam('query'), 'alnum');
$table = new Zend_Db_Table('selection_process');
$select = $table->select()->order('end DESC');
if ($query) {
$select->where('name LIKE (?)', "%{$query}%");
}
$paginator = new Tri_Paginator($select, $page);
$this->view->data = $paginator->getResult();
}
示例10: load
/**
* retourne tous les parametres
*
* @return Settings
*/
public function load()
{
global $logger;
$this->_init();
foreach ($this->_tables as $holder => $table) {
$oTable = new Zend_Db_Table($table);
$xt = array();
foreach ($oTable->fetchAll($oTable->select()->order('id ASC'))->toArray() as $o) {
$xsetting = new Setting();
$xsetting->name = $o['name'];
$xsetting->id = $o['id'];
$xt[] = $xsetting;
}
$t[$holder] = $xt;
}
$s = new Settings($this->_description, $t[0], $t[1], $t[2], $t[3], $t[4], $t[5], $t[6], $t[7], $t[8]);
return $s;
}
示例11: getSection
/**
* Получаем информацию о разделе
*
* @param int $item_id
* @param int $menu_id
*
* @return array
*/
public function getSection($item_id, $menu_id)
{
$menu = $this->getMenu($menu_id);
if ($menu->type == 'router') {
// получаем разделы меню привязонного к маршруту
$item = $this->_modelItems->fetchRow($this->_modelItems->select()->where('route_id = ?', $item_id)->where('menu_id = ?', $menu->menu_id));
$itemRoute = Modules_Router_Model_Router::getInstance()->getItem($item_id);
$return = $item ? $item->toArray() + $itemRoute : $itemRoute;
$return['type'] = 'router';
$return['parent_id'] = $itemRoute['parent_route_id'];
$return['name_route'] = $itemRoute['name'];
$return['name'] = $item['name'] ? $item['name'] : $itemRoute['name'];
unset($return['parent_route_id'], $return['childs']);
} else {
$return = $this->_modelItems->fetchRow($this->_modelItems->select()->where('item_id = ?', $item_id))->toArray();
}
return $return;
}
示例12: authenticate
/**
* Returns true if the user can be authenticaed using the
* supplied credential. The tests for success with this authentication
* type are:
* <ol>
* <li>The user must exist.</li>
* <li>The user must have database authorisation enabled
* (auth_allowed = true).</li>
* <li>The password must match the record password.</li>
* </ol>
*
* @return boolean true if the user is authenticated
* @see models/Sahara/Auth/Sahara_Auth_Type::authenticate()
*/
public function authenticate()
{
$table = new Zend_Db_Table('users');
$this->_record = $table->fetchRow($table->select()->where('name = ?', $this->_user)->where('namespace = ?', $this->_config->institution));
/* 1) User must exist. */
if ($this->_record == null) {
return false;
}
$allowed = (int) $this->_record->auth_allowed;
if (is_string($allowed)) {
$allowed = (int) $allowed && true;
}
/* 2) Authorisation must be enabled. */
if (!$allowed) {
return false;
}
/* 3) Passwords must match. */
return $this->_record->password == sha1($this->_pass);
}
示例13: getCommentsForPage
/**
* Get comments for a page
*
* @param string $bookName
* @param string $pageName
* @param boolean $approvedOnly
* @return array
*/
public static function getCommentsForPage($bookName, $pageName, $approvedOnly = true)
{
$table = new Zend_Db_Table('comments');
$select = $table->select()->where('page = ?', $pageName)->where('book = ?', $bookName)->order('created_at DESC');
if ($approvedOnly) {
$select->where('flags & ?', self::FLAG_APPROVED);
}
$stmt = $select->query();
$comments = array();
while ($cData = $stmt->fetch(Zend_Db::FETCH_ASSOC)) {
$comment = new self($cData);
$comment->_id = $cData['id'];
$comments[] = $comment;
}
return $comments;
}
示例14: fetchUserFriends
public function fetchUserFriends($id)
{
$id = (int) $id;
$table = new Zend_Db_Table('friends');
$select = $table->select()->setIntegrityCheck(false);
$select->from(array('f' => 'friends'), array('f.id_friend'));
$select->where('f.id_user = ?', $id);
$select->joinInner(array('u' => 'users'), 'f.id_friend = u.id', array('u.username'));
return $table->fetchAll($select)->toArray();
}
示例15: accountAction
public function accountAction()
{
// Leave if not ready
if (empty($this->_session->mysql)) {
return $this->_helper->redirector->gotoRoute(array('action' => 'db-info'));
}
$this->view->form = $form = new Install_Form_Account();
if (!$this->getRequest()->isPost()) {
return;
}
if (!$form->isValid($this->getRequest()->getPost())) {
return;
}
// Check passwords match
$values = $form->getValues();
if ($values['password'] != $values['password_conf']) {
$form->addError('Passwords must match.');
return;
}
// Create account
// Connect again
try {
$config = $this->dbFormToConfig($this->_session->mysql);
// Connect!
$adapter = Zend_Db::factory($config['adapter'], $config['params']);
$adapter->getServerVersion();
} catch (Exception $e) {
$form->addError('Adapter Error: ' . $e->getMessage());
//$this->view->code = 1;
//$this->view->error = 'Adapter Error: ' . $e->getMessage();
return;
}
// attempt to disable strict mode
try {
$adapter->query("SET SQL_MODE = ''");
} catch (Exception $e) {
}
try {
// Preprocess
$settingsTable = new Zend_Db_Table(array('db' => $adapter, 'name' => 'engine4_core_settings'));
$usersTable = new Zend_Db_Table(array('db' => $adapter, 'name' => 'engine4_users'));
$levelTable = new Zend_Db_Table(array('db' => $adapter, 'name' => 'engine4_authorization_levels'));
// Get static salt
$staticSalt = $settingsTable->find('core.secret')->current();
if (is_object($staticSalt)) {
$staticSalt = $staticSalt->value;
} else {
if (!is_string($staticSalt)) {
$staticSalt = '';
}
}
// Get superadmin level
$superAdminLevel = $levelTable->fetchRow($levelTable->select()->where('flag = ?', 'superadmin'));
if (is_object($superAdminLevel)) {
$superAdminLevel = $superAdminLevel->level_id;
} else {
$superAdminLevel = 1;
}
// Temporarily save pw
$originalPassword = $values['password'];
// Adjust values
$values['salt'] = (string) rand(1000000, 9999999);
$values['password'] = md5($staticSalt . $values['password'] . $values['salt']);
$values['level_id'] = $superAdminLevel;
$values['enabled'] = 1;
$values['verified'] = 1;
$values['creation_date'] = date('Y-m-d H:i:s');
$values['creation_ip'] = ip2long($_SERVER['REMOTE_ADDR']);
$values['displayname'] = $values['username'];
// Try to write info to config/auth.php
if (!$this->_writeAuthToFile($values['email'], 'seiran', $originalPassword)) {
throw new Exception('Unable to write Auth to File');
}
// Insert
$row = $usersTable->createRow();
$row->setFromArray($values);
$row->save();
// First Signup Increment
// Engine_Api::_()->getDbtable('statistics', 'core')->increment('user.creations');
// Validate password
if ($row->password != md5($staticSalt . $originalPassword . $row->salt)) {
throw new Engine_Exception('Error creating password');
}
// Log the user into the intaller
$auth = Zend_Registry::get('Zend_Auth');
$auth->getStorage()->write($row->user_id);
// Try to log the user into socialengine
// Note: nasty hack
try {
$mainSessionName = 'PHPSESSID';
if (empty($_COOKIE[$mainSessionName])) {
$mainSessionId = md5(mt_rand(0, time()) . serialize($_SERVER));
setcookie($mainSessionName, $mainSessionId, null, dirname($this->view->baseUrl()), $_SERVER['HTTP_HOST'], false, false);
} else {
$mainSessionId = $_COOKIE[$mainSessionName];
}
$adapter->insert('engine4_core_session', array('id' => $mainSessionId, 'modified' => time(), 'lifetime' => 86400, 'data' => 'Zend_Auth|' . serialize(array('storage' => $row->user_id))));
} catch (Exception $e) {
// Silence
if (APPLICATION_ENV == 'development') {
//.........这里部分代码省略.........