本文整理汇总了PHP中Zend_Db_Table::getDefaultAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table::getDefaultAdapter方法的具体用法?PHP Zend_Db_Table::getDefaultAdapter怎么用?PHP Zend_Db_Table::getDefaultAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table
的用法示例。
在下文中一共展示了Zend_Db_Table::getDefaultAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLanguage
public function getLanguage()
{
$this->db = Zend_Db_Table::getDefaultAdapter();
$sql = "SELECT code from ourbank_language where active = 1";
$result = $this->db->fetchOne($sql);
return $result;
}
示例2: fillgridAction
public function fillgridAction()
{
self::createModel();
$request = $this->getRequest();
$valid = $request->getParam('nd');
if ($request->isXmlHttpRequest() and $valid) {
$this->grid = $this->_helper->grid();
$this->grid->setGridparam($request);
$this->grid->sql = Zend_Db_Table::getDefaultAdapter()->select()->from($this->model->info('name'), array('subject_faculty.subject_code', 'subject_mode_id', 'staff_id', 'subject_department.degree_id', 'department_id', 'department_id', 'subject_department.semester_id'))->joinLeft('subject_department', '(subject_department.subject_code = subject_faculty.subject_code AND subject_department.department_id = subject_faculty.department_id)', array())->where('subject_faculty.department_id = ?', $this->department_id);
$searchOn = $request->getParam('_search');
if ($searchOn != 'false') {
$sarr = $request->getParams();
foreach ($sarr as $key => $value) {
switch ($key) {
case 'staff_id':
$this->grid->sql->where("{$key} LIKE ?", '%' . $value . '%');
break;
case 'subject_code':
$this->grid->sql->where("subject_faculty.subject_code LIKE ?", $value . '%');
break;
case 'subject_mode':
$this->grid->sql->where("subject_faculty.subject_mode_id LIKE ?", $value . '%');
break;
case 'semester_id':
$this->grid->sql->where("subject_department.semester_id = ?", $value);
break;
}
}
}
self::fillgridfinal();
} else {
echo '<b>Oops!! </b><br/>No use of peeping like that... :)';
}
}
示例3: getTableFields
public function getTableFields($tableName)
{
$db = Zend_Db_Table::getDefaultAdapter();
$columns = $db->query("SELECT menufields FROM main_menu WHERE url = '" . $tableName . "'");
$columnData = $columns->fetch();
return $columnData;
}
示例4: GetDadosUsuario
/**
* Helper para pegar as imagens do webservice
*
*/
public function GetDadosUsuario()
{
$auth = Zend_Auth::getInstance();
$db = Zend_Db_Table::getDefaultAdapter();
$chAction = strtolower(Zend_Controller_Front::getInstance()->getRequest()->getActionName());
$chController = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
$sql = 'select ';
$sql .= ' u.*, ';
$sql .= ' a.nm_avatar, ';
$sql .= ' a.tp_avatar, ';
$sql .= ' a.sz_avatar, ';
$sql .= ' a.arquivo ';
$sql .= 'from ';
$sql .= ' sca_usuario u ';
$sql .= ' left join sgg_avatar a on a.id_avatar = u.id_avatar ';
$sql .= 'where u.st_usuario = 1 ';
$sql .= 'and u.id_usuario = ' . $auth->getIdentity()->id_usuario;
$result = $db->fetchRow($sql);
if ($result) {
if ($result['arquivo']) {
$result['arquivo'] = "data:" . $result['tp_avatar'] . ";base64," . base64_encode($result['arquivo']);
}
}
return $result;
}
示例5: getTripPaginatorAdapter
/**
* Get trip paginator adapter
* @param string $filtingField
* @param string $filtingCriteria
* @param string $sortingField
* @return Zend_Paginator_Adapter_DbSelect|Zend_Paginator_Adapter_DbTableSelect
*/
public function getTripPaginatorAdapter($filtingField, $filtingCriteria, $sortingField)
{
$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
if (!empty($filtingField)) {
// switch filting field
switch ($filtingField) {
case 'departure_time':
case 'arrival_time':
if (!empty($filtingCriteria)) {
$dateFormat = new Zend_Date($filtingCriteria, 'dd-MM-y HH:mm:ss');
$filtingCriteria = $dateFormat->toString('y-MM-dd HH:mm:ss');
}
break;
case 'from_city':
case 'to_city':
$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
break;
default:
break;
}
// add filting criteria
$select->where($filtingField . ' = ?', $filtingCriteria);
}
// add sorting criteria
if (!empty($sortingField)) {
$select->order($sortingField);
}
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
return $adapter;
}
示例6: checkduplicaterequestname
public function checkduplicaterequestname($servicedeskid, $requestname)
{
$db = Zend_Db_Table::getDefaultAdapter();
$qry = "select count(*) as count from main_sd_reqtypes sd where sd.service_request_name ='" . $requestname . "' AND sd.service_desk_id='" . $servicedeskid . "' AND sd.isactive=1 ";
$res = $db->query($qry)->fetchAll();
return $res;
}
示例7: _getAuthAdapter
protected function _getAuthAdapter()
{
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('users')->setIdentityColumn('username')->setCredentialColumn('password')->setCredentialTreatment('SHA1(CONCAT(?,salt))');
return $authAdapter;
}
示例8: loginAction
public function loginAction()
{
$this->_helper->layout->disablelayout();
$authorization = Zend_Auth::getInstance();
$identity = $authorization->getIdentity();
if ($authorization->hasIdentity()) {
$this->redirect("categories/list");
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getParams();
$db = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'users', 'username', 'password');
$authAdapter->setIdentity($data['username']);
$authAdapter->setCredential(md5($data['password']));
$result = $authAdapter->authenticate();
if ($result->isValid()) {
$active = (new Application_Model_Users())->getUserByUsername($data['username'])[0]['active'];
if ($active) {
$auth = Zend_Auth::getInstance();
$storage = $auth->getStorage();
$storage->write($authAdapter->getResultRowObject(array('f_name', 'username', 'id', 'user_type')));
$authorization = Zend_Auth::getInstance();
$identity = $authorization->getIdentity();
$this->view->identity = $identity;
$this->redirect('categories/list');
} else {
$this->view->user_msg = "The page not allowed for normal user.";
$this->redirect("users/login");
}
}
}
$form = new Application_Form_Login();
$this->view->form = $form;
}
示例9: getAuthAdapter
/**
* Gets the adapter for authentication against a database table
*
* @return object
*/
protected function getAuthAdapter()
{
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
$authAdapter->setTableName('login')->setIdentityColumn('username')->setCredentialColumn('password')->setCredentialTreatment('MD5(?)');
return $authAdapter;
}
示例10: findForSelect
public function findForSelect()
{
$adapter = Zend_Db_Table::getDefaultAdapter();
$statement = "SELECT DISTINCT p.* FROM province p INNER JOIN city c ON (p.province_id = c.province_id) WHERE c.status = 'A' ORDER BY name";
$results = $adapter->fetchAll($statement);
return $results;
}
示例11: getAllByUser
/**
* Get all possible classroom
*
* @param int $userId
* @return array
*/
public static function getAllByUser($userId)
{
$session = new Zend_Session_Namespace('data');
$db = Zend_Db_Table::getDefaultAdapter();
$cols = array('cr.*', 'c.*', 'c.id as id', 'cr.id as classroom_id', 'cr.name as classroom_name');
$course = array('c' => 'course');
$classroom = array('cr' => 'classroom');
$classUser = array('cu' => 'classroom_user');
$data = array();
//by course or classroom responsible
$select = $db->select()->from($classroom, $cols)->join($course, 'c.id = cr.course_id', array())->where('c.responsible = ? OR cr.responsible = ?', $userId)->where("cr.status = 'active' OR cr.status = 'open'");
$responsibles = $db->fetchAll($select);
//by registration
$select = $db->select()->from($classroom, $cols)->join($course, 'c.id = cr.course_id', array())->join($classUser, 'cr.id = cu.classroom_id', array())->where('cu.user_id = ?', $userId)->where('cu.status = ?', 'registered')->where('cr.begin <= ?', date('Y-m-d'))->where('cr.end >= ? OR end IS NULL', date('Y-m-d'))->where("cr.status = 'active' OR cr.status = 'open'");
$registries = $db->fetchAll($select);
foreach ($responsibles as $responsible) {
$data[] = $responsible;
$session->classrooms[] = $responsible['classroom_id'];
}
foreach ($registries as $registry) {
if (in_array($registry, $data)) {
continue;
}
$data[] = $registry;
$session->classrooms[] = $registry['classroom_id'];
}
return $data;
}
示例12: loadAppData
public function loadAppData()
{
$loggedInUserId = $this->getIdentityId();
$addData = array();
if ($loggedInUserId != null) {
$db = Zend_Db_Table::getDefaultAdapter();
$tagGroupsTable = new Default_Dao_TagGroup();
$tagGroupsRows = $tagGroupsTable->fetchAll('valid is true');
foreach ($tagGroupsRows as $tagGroupsRow) {
$tagGroup = new Default_Dto_TagGroup();
$tagGroup->id = $tagGroupsRow['id'];
$tagGroup->name = $tagGroupsRow['name'];
$tagGroup->tags = new Zend_Amf_Value_Messaging_ArrayCollection();
$tagGroup->tags->source = array();
$tagsTable = new Default_Dao_Tag();
$tagsRows = $tagsTable->fetchAll($db->quoteInto('group_id = ?', $tagGroupsRow['id']));
foreach ($tagsRows as $tagsRow) {
$tag = new Default_Dto_Tag();
$tag->id = $tagsRow['id'];
$tag->name = $tagsRow['name'];
array_push($tagGroup->tags->source, $tag);
}
array_push($addData, $tagGroup);
}
}
$result = new Zend_Amf_Value_Messaging_ArrayCollection();
$result->source = $addData;
return $result;
}
示例13: indexAction
public function indexAction()
{
$db = Zend_Db_Table::getDefaultAdapter();
if (isset($_POST['editForm'])) {
$first_name = $_POST['editForm']['first_name'];
$last_name = $_POST['editForm']['last_name'];
$current_city = $_POST['editForm']['current_city'];
$person_id = $_POST['editForm']['person_id'];
$form = false;
} else {
$person_id = $this->_request->get('id');
$select = $db->select();
$select->from('contacts')->where('person_id = ?', $person_id);
$contacts = $db->fetchAll($select);
$first_name = $contacts[0]['first_name'];
$last_name = $contacts[0]['last_name'];
$current_city = $contacts[0]['current_city'];
$form = true;
}
$this->view->first_name = $first_name;
$this->view->last_name = $last_name;
$this->view->current_city = $current_city;
$this->view->person_id = $person_id;
$this->view->form = $form;
if (isset($_POST['editForm']) && $first_name && $last_name && $current_city) {
$data = array('first_name' => $first_name, 'last_name' => $last_name, 'current_city' => $current_city);
$db->update('contacts', $data, array('person_id=?' => $person_id));
$this->renderScript('index/partials/tableRow.phtml');
}
if ($this->_request->isXmlHttpRequest()) {
$this->view->layout()->setLayout('ajax');
}
}
示例14: populate
public function populate()
{
$db = Zend_Db_Table::getDefaultAdapter();
$dbSelect = $db->select()->from(array('arp' => 'aclRolePrivileges'), array('aclRoleId'))->join(array('ap' => 'aclPrivileges'), 'arp.aclPrivilegeId = ap.aclPrivilegeId', array('aclPrivilegeName'))->join(array('ar' => 'aclResources'), 'ap.aclResourceId = ar.aclResourceId', array('aclResourceName'))->join(array('am' => 'aclModules'), 'ar.aclModuleId = am.aclModuleId', array('aclModuleName'));
$roles = $db->fetchAll($dbSelect);
foreach ($roles as $role) {
if (!$this->has($role['aclModuleName'] . '_' . $role['aclResourceName'])) {
$this->add(new Zend_Acl_Resource($role['aclModuleName'] . '_' . $role['aclResourceName']));
}
if (!$this->hasRole($role['aclRoleId'])) {
$this->addRole(new Zend_Acl_Role($role['aclRoleId']));
}
}
$defaultResources = array('default_error', 'default_login');
// check default resource if exists; add otherwise
foreach ($defaultResources as $def) {
if (!$this->has($def)) {
$this->add(new Zend_Acl_Resource($def));
}
}
$this->deny();
$this->allow(null, $defaultResources);
foreach ($roles as $role) {
$this->allow($role['aclRoleId'], $role['aclModuleName'] . '_' . $role['aclResourceName'], $role['aclPrivilegeName']);
}
}
示例15: collectionsafterinsert
public function collectionsafterinsert()
{
$db = Zend_Db_Table::getDefaultAdapter();
$pageId = !empty($_GET['pages_id']) ? $_GET['pages_id'] : 0;
if ($_POST) {
$id = 0;
$files = $_FILES['preview'];
// var_dump($files);exit;
if (!empty($files)) {
// $lastId = $db->lastInsertId('collections');
// if(strpos($_SERVER['REQUEST_URI'], 'edit') !== FALSE){
// $id = $pageId;
// }
// if(strpos($_SERVER['REQUEST_URI'], 'add') !== FALSE){
// $id = $lastId;
// }
if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/public/uploadimg')) {
mkdir($_SERVER['DOCUMENT_ROOT'] . '/public/uploadimg');
}
// var_dump($img);exit;
if ($_FILES['preview']['name'] != '') {
$db->update('collections', array('img' => $files['name']), 'id=' . $pageId);
move_uploaded_file($files['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/public/uploadimg/' . $files['name']);
}
}
}
if ($pageId != 0) {
$sql = $db->select()->from(array('fc' => 'film_collection'))->join(array('f' => 'films'), 'f.id = fc.film_id', array('f.name'))->where('fc.collection_id =?', $pageId);
$films = $db->query($sql)->fetchAll();
$this->view->films = $films;
return $films;
}
}