当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Table::getAdapter方法代码示例

本文整理汇总了PHP中Zend_Db_Table::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table::getAdapter方法的具体用法?PHP Zend_Db_Table::getAdapter怎么用?PHP Zend_Db_Table::getAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Db_Table的用法示例。


在下文中一共展示了Zend_Db_Table::getAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: aclconfigAction

 public function aclconfigAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $methods = get_class_methods('StudentController');
     $actions = array();
     foreach ($methods as $value) {
         $actions[] = substr("{$value}", 0, strpos($value, 'Action'));
     }
     foreach ($actions as $key => $value) {
         if ($value == null) {
             unset($actions[$key]);
         }
     }
     $db = new Zend_Db_Table();
     $delete2 = 'DELETE FROM `tnp`.`mod_role_resource` WHERE `module_id`=? AND `controller_id`=?';
     $db->getAdapter()->query($delete2, array('tnp', 'student'));
     $delete1 = 'DELETE FROM `tnp`.`mod_action` WHERE `module_id`=? AND `controller_id`=?';
     $db->getAdapter()->query($delete1, array('tnp', 'student'));
     print_r(sizeof($actions));
     $sql = 'INSERT INTO `tnp`.`mod_action`(`module_id`,`controller_id`,`action_id`) VALUES (?,?,?)';
     foreach ($actions as $action) {
         $bind = array('tnp', 'student', $action);
         $db->getAdapter()->query($sql, $bind);
     }
     $sql = 'INSERT INTO `tnp`.`mod_role_resource`(`role_id`,`module_id`,`controller_id`,`action_id`) VALUES (?,?,?,?)';
     foreach ($actions as $action) {
         $bind = array('student', 'tnp', 'student', $action);
         $db->getAdapter()->query($sql, $bind);
     }
 }
开发者ID:sivarajankumar,项目名称:eduis,代码行数:31,代码来源:StudentController.php

示例2: save

 /**
  * Save object in DB
  * 
  * @return HumanHelp_Model_Comment
  */
 public function save()
 {
     $table = new Zend_Db_Table('comments');
     if (isset($this->_id)) {
         // Update
         $table->update($this->_data, $table->getAdapter()->quoteInto('id = ?', $this->_id));
     } else {
         // Insert
         $table->insert($this->_data);
         $this->_id = $table->getAdapter()->lastInsertId('comments', 'id');
     }
     return $this;
 }
开发者ID:shevron,项目名称:HumanHelp,代码行数:18,代码来源:Comment.php

示例3: reorder

 /**
  * Move down/up setting into the table
  */
 public function reorder($setting, $table, $sens)
 {
     global $logger;
     $cur_id = $setting->id;
     $other_id = $sens == 'up' ? $cur_id - 1 : $cur_id + 1;
     $oTable = new Zend_Db_Table($table);
     $where_cur = $oTable->getAdapter()->quoteInto('id = ?', $cur_id);
     $where_other = $oTable->getAdapter()->quoteInto('id = ?', $other_id);
     $where_tmp = $oTable->getAdapter()->quoteInto('id = ?', 999);
     $oTable->update(array('id' => 999), $where_cur);
     $oTable->update(array('id' => $cur_id), $where_other);
     $result = $oTable->update(array('id' => $other_id), $where_tmp);
     $logger->log("Reorder setting {$table}={$setting->id} {$sens}", Zend_Log::INFO);
     return $result;
 }
开发者ID:ka2er,项目名称:mmc-flex,代码行数:18,代码来源:SettingsMapper.php

示例4: updateCommentsAd

 public function updateCommentsAd($id, $count)
 {
     $id = (int) $id;
     $table = new Zend_Db_Table('commentsAdCount');
     $sql = "INSERT INTO commentsAdCount   ( id_comment, count ) VALUES  ( ?,? )\n                            ON DUPLICATE KEY UPDATE id_comment = ?, count = ?";
     $values = array("id_comment" => $id, "count" => $count);
     $result = $table->getAdapter()->query($sql, array_merge(array_values($values), array_values($values)));
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:8,代码来源:Comment.php

示例5: __construct

 /**
  * @param string $prefix для формирования имен tmp таблиц
  * @param string $jobidHash хэш-индекс для массива jobid
  */
 public function __construct($jobidhash, $ttl_restore_session)
 {
     $this->db_adapter = Zend_Registry::get('DB_ADAPTER');
     $this->jobidhash = $jobidhash;
     $this->ttl_restore_session = $ttl_restore_session;
     // формируем имена временных таблиц
     $this->tmp_file = self::_PREFIX . 'file_' . $this->jobidhash;
     $config['db'] = Zend_Registry::get('db_bacula');
     // database
     $config['name'] = $this->_name;
     // name table
     $config['primary'] = $this->_primary;
     // primary key
     $config['sequence'] = true;
     parent::__construct($config);
     // setup DB adapter
     $this->_db = Zend_Db_Table::getAdapter('db_bacula');
     // существует ли таблица ?
     try {
         $this->_db->query('SELECT tmpId FROM ' . $this->_name . ' LIMIT 1');
     } catch (Zend_Exception $e) {
         // создаем таблицу
         switch ($this->db_adapter) {
             case 'PDO_MYSQL':
                 $sql = 'CREATE TABLE ' . $this->_name . ' (
                     tmpId    INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
                     tmpName  CHAR(64) UNIQUE NOT NULL,
                     tmpJobIdHash CHAR(64) NOT NULL,
                     tmpCreate   TIMESTAMP NOT NULL,
                     tmpIsCloneOk INTEGER DEFAULT 0,
                     PRIMARY KEY(tmpId)
                     )';
                 break;
             case 'PDO_PGSQL':
                 $sql = 'CREATE TABLE ' . $this->_name . ' (
                     tmpId    SERIAL NOT NULL,
                     tmpName  CHAR(64) UNIQUE NOT NULL,
                     tmpJobIdHash CHAR(64) NOT NULL,
                     tmpCreate   timestamp without time zone NOT NULL,
                     tmpIsCloneOk SMALLINT DEFAULT 0,
                     PRIMARY KEY(tmpId))';
                 break;
             case 'PDO_SQLITE':
                 $sql = 'CREATE TABLE ' . $this->_name . ' (
                    tmpId    INTEGER,
                    tmpName  CHAR(64) UNIQUE NOT NULL,
                    tmpJobIdHash CHAR(64) NOT NULL,
                    tmpCreate   TIMESTAMP NOT NULL,
                    tmpIsCloneOk INTEGER DEFAULT 0,
                    PRIMARY KEY(tmpId))';
                 break;
         }
         $this->_db->query($sql);
     }
 }
开发者ID:neverstoplwy,项目名称:contrib-webacula,代码行数:59,代码来源:WbTmpTable.php

示例6: getTable

 function getTable($name)
 {
     if (!($result = $this->_cache->load($this->_options[$name]['table']))) {
         $table = new Zend_Db_Table($this->_options[$name]['table']);
         if ($name == 'privilege') {
             $sql = new Zend_Db_Select($table->getDefaultAdapter());
             $sql->from(array('acl' => $this->_options['privilege']['table']), array('acl.ID_PERFIL'))->join(array('r' => $this->_options['resource']['table']), 'acl.ID_MENU=r.ID_MENU', array('r.URL_MENU', 'acl.PERMISO'));
             $result = $table->getAdapter()->fetchAll($sql);
         } else {
             $result = $table->fetchAll();
         }
         $this->_cache->save($result, $this->_options[$name]['table']);
     }
     return $result;
 }
开发者ID:josmel,项目名称:DevelEntretenimientoEntel,代码行数:15,代码来源:Acl.php

示例7: deleteThread

 /**
  * Deletes a new thread, by marking it as deleted. If both users deleted it
  * it is phisically deleted as well
  *
  * @param array $data: thread_id and user_id who is deleting
  */
 public function deleteThread(array $data)
 {
     /* Fetch thread */
     $threads_table = new Zend_Db_Table('threads');
     $select = $threads_table->select()->where('id = ?', $data['thread_id']);
     $thread = $threads_table->fetchRow($select);
     /* Update flags */
     if ($thread->user_from == $data['user_id']) {
         $thread->deleted_from = 1;
     } elseif ($thread->user_to == $data['user_id']) {
         $thread->deleted_to = 1;
     } else {
         return null;
     }
     $thread->save();
     /* If both deleted, delete physically */
     if ($thread->deleted_from && $thread->deleted_to) {
         $messages_table = new Zend_Db_Table('messages');
         $whereM = $messages_table->getAdapter()->quoteInto('id = ?', $data['thread_id']);
         $messages_table->delete($whereM);
         $thread->delete();
     }
     return;
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:30,代码来源:Message.php

示例8: findLogBookByText

 /**
  * LogBook full text search
  *
  */
 function findLogBookByText($id_text, $sort_order)
 {
     if (!isset($id_text)) {
         return;
     }
     $id_text = trim($id_text);
     $db = Zend_Db_Table::getAdapter('db_bacula');
     $select = new Zend_Db_Select($db);
     switch ($this->db_adapter) {
         case 'PDO_MYSQL':
             $select->distinct();
             $select->from(array('l' => 'webacula_logbook'), array('logId', 'logDateCreate', 'logDateLast', 'logTxt', 'logTypeId', 'logIsDel'));
             $select->joinLeft(array('t' => 'webacula_logtype'), 'l.logTypeId = t.typeId', array('typeId', 'typeDesc'));
             $select->where(' MATCH(logTxt) AGAINST ("' . $id_text . '" WITH QUERY EXPANSION)');
             break;
         case 'PDO_PGSQL':
             $select->distinct();
             $select->from(array('l' => 'webacula_logbook'), array('logId', 'logDateCreate', 'logDateLast', 'logTxt', 'logTypeId', 'logIsDel'));
             $select->joinLeft(array('t' => 'webacula_logtype'), 'l.logTypeId = t.typeId', array('typeId', 'typeDesc'));
             $str = preg_replace('/\\s+/', ' & ', $id_text);
             $select->where(" to_tsvector(logtxt) @@ to_tsquery(" . $db->quote($str) . ")");
             break;
         case 'PDO_SQLITE':
             // see also http://www.sqlite.org/cvstrac/wiki?p=FtsOne "FTS1 module is available in SQLite version 3.3.8 and later
             $select->distinct();
             $select->from(array('l' => 'webacula_logbook'), array('logid' => 'logId', 'logdatecreate' => 'logDateCreate', 'logdatelast' => 'logDateLast', 'logtxt' => 'logTxt', 'logtypeid' => 'logTypeId', 'logisdel' => 'logIsDel'));
             $select->joinLeft(array('t' => 'webacula_logtype'), 'l.logTypeId = t.typeId', array('typeid' => 'typeId', 'typedesc' => 'typeDesc'));
             $select->where(' logTxt LIKE  "%' . $id_text . '%"');
             break;
     }
     //$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!!
     $result = $select->query();
     return $result;
 }
开发者ID:neverstoplwy,项目名称:contrib-webacula,代码行数:38,代码来源:Wblogbook.php

示例9: init

 public function init()
 {
     $db = Zend_Db_Table::getAdapter('db_bacula');
 }
开发者ID:staser,项目名称:webacula,代码行数:4,代码来源:Wbjobdesc.php

示例10: addUserFriend

 public function addUserFriend($id_user, $id_friend)
 {
     $id_user = (int) $id_user;
     $id_friend = (int) $id_friend;
     $table = new Zend_Db_Table('friends');
     $sql = "INSERT INTO friends   ( id_user, id_friend ) VALUES  ( {$id_user} , {$id_friend} )\n                            ON DUPLICATE KEY UPDATE  id_user=id_user";
     return $table->getAdapter()->query($sql)->fetch();
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:8,代码来源:User.php

示例11: manageAction

 public function manageAction()
 {
     $userForm = new Application_Form_User();
     $userForm->getElement('password')->setRequired(false);
     if ($this->getRequest()->isPost()) {
         //if we are updating
         $userId = $this->getRequest()->getParam('id');
         if ($userId) {
             $userForm->setId($userId);
         }
         if ($userForm->isValid($this->getRequest()->getParams())) {
             $data = $userForm->getValues();
             $user = new Application_Model_Models_User($data);
             Application_Model_Mappers_UserMapper::getInstance()->save($user);
             $this->_helper->response->success($this->_helper->language->translate('Saved'));
             exit;
         } else {
             $this->_helper->response->fail(Tools_Content_Tools::proccessFormMessages($userForm->getMessages()));
             exit;
         }
     }
     $pnum = (int) filter_var($this->getParam('pnum'), FILTER_SANITIZE_NUMBER_INT);
     $offset = 0;
     if ($pnum) {
         $offset = 10 * ($pnum - 1);
     }
     $select = $this->_zendDbTable->getAdapter()->select()->from('user');
     $by = filter_var($this->getParam('by', 'last_login'), FILTER_SANITIZE_STRING);
     $order = filter_var($this->getParam('order', 'desc'), FILTER_SANITIZE_STRING);
     $searchKey = filter_var($this->getParam('key'), FILTER_SANITIZE_STRING);
     if (!in_array($order, array('asc', 'desc'))) {
         $order = 'desc';
     }
     $select = $select->order($by . ' ' . $order);
     $paginatorOrderLink = '/by/' . $by . '/order/' . $order;
     if (!empty($searchKey)) {
         $select->where('email LIKE ?', '%' . $searchKey . '%')->orWhere('full_name LIKE ?', '%' . $searchKey . '%')->orWhere('role_id LIKE ?', '%' . $searchKey . '%')->orWhere('last_login LIKE ?', '%' . date("Y-m-d", strtotime($searchKey)) . '%')->orWhere('ipaddress LIKE ?', '%' . $searchKey . '%');
         $paginatorOrderLink .= '/key/' . $searchKey;
     }
     $adapter = new Zend_Paginator_Adapter_DbSelect($select);
     $users = $adapter->getItems($offset, 10);
     $userPaginator = new Zend_Paginator($adapter);
     $userPaginator->setCurrentPageNumber($pnum);
     $userPaginator->setItemCountPerPage(10);
     $pager = $this->view->paginationControl($userPaginator, 'Sliding', 'backend/user/pager.phtml', array('urlData' => $this->_websiteUrl . 'backend/backend_user/manage', 'order' => $paginatorOrderLink));
     if ($order === 'desc') {
         $order = 'asc';
     } else {
         $order = 'desc';
     }
     if (!empty($searchKey)) {
         $this->view->orderParam = $order . '/key/' . $searchKey;
     } else {
         $this->view->orderParam = $order;
     }
     $this->view->by = $by;
     $this->view->order = $order;
     $this->view->key = $searchKey;
     $this->view->pager = $pager;
     $this->view->users = $users;
     $this->view->helpSection = 'users';
     $this->view->userForm = $userForm;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:63,代码来源:UserController.php

示例12: _updateContractsFields

 /**
  * adds "start_date", "end_date" to contract and removes "status", "cleared", "cleared_in"
  */
 protected function _updateContractsFields()
 {
     $adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
     $groupMembers = Tinebase_Group::getInstance()->getGroupMembers($adminGroup->getId());
     if (count($groupMembers) > 0) {
         $user = Tinebase_User::getInstance()->getUserById($groupMembers[0]);
         if ($user->hasRight('Sales', Sales_Acl_Rights::ADMIN)) {
             $this->_updateContractsWithUser($user);
         }
     }
     // remove deprecated sales contract fields
     foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
         try {
             $this->_backend->dropCol('sales_contracts', $colToDrop);
         } catch (Zend_Db_Statement_Exception $zdse) {
             Tinebase_Exception::log($zdse);
         }
     }
     // add new sales contract fields
     $fields = array('<field>
         <name>start_date</name>
         <type>datetime</type>
     </field>', '
     <field>
         <name>end_date</name>
         <type>datetime</type>
     </field>');
     foreach ($fields as $field) {
         try {
             $declaration = new Setup_Backend_Schema_Field_Xml($field);
             $this->_backend->addCol('sales_contracts', $declaration);
         } catch (Zend_Db_Statement_Exception $zdse) {
             Tinebase_Exception::log($zdse);
         }
     }
     $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'last_modified_time' => array('name' => 'last_modified_time'), 'end_date' => array('name' => 'end_date'), 'start_date' => array('name' => 'start_date'))));
     $db = $table->getAdapter();
     $values = array_keys($setEndDate);
     if (!empty($values)) {
         $sql = 'UPDATE ' . $db->quoteIdentifier(SQL_TABLE_PREFIX . 'sales_contracts') . ' SET ' . $db->quoteIdentifier('start_date') . ' = ' . $db->quoteIdentifier('last_modified_time') . ', ' . $db->quoteIdentifier('end_date') . ' = ' . $db->quoteIdentifier('last_modified_time') . ' WHERE ' . $db->quoteIdentifier('id') . $db->quoteInto(' IN (?)', $values);
         $db->query($sql);
     }
     if ($this->getTableVersion('sales_contracts') == 5) {
         $this->setTableVersion('sales_contracts', 6);
     } else {
         $this->setTableVersion('sales_contracts', 7);
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:51,代码来源:Release8.php

示例13: deleteItem

 /**
  * Удаляем элемент меню
  *
  * @param int $item_id
  */
 public function deleteItem($item_id)
 {
     $where = $this->_modelItems->getAdapter()->quoteInto('item_id = ?', $item_id);
     $this->_modelItems->delete($where);
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:10,代码来源:Menu.php

示例14: _updateContractsFields


//.........这里部分代码省略.........
         $config = Sales_Config::getInstance()->get('contractStatus');
         foreach ($config['records'] as $cfg) {
             $statusConfig[$cfg['id']] = $cfg['value'];
         }
         $config = Sales_Config::getInstance()->get('contractCleared');
         foreach ($config['records'] as $cfg) {
             $clearedConfig[$cfg['id']] = $cfg['value'];
         }
         while ($more) {
             $results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
             foreach ($results as $row) {
                 if ($row['status'] == 'CLOSED') {
                     $setEndDate[$row['id']] = $row['last_modified_time'];
                 }
                 $desc = $row['description'];
                 $desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
                 $contents = FALSE;
                 if (!empty($row['status'])) {
                     $desc .= $t->_('Status') . ': ';
                     $desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
                     $desc .= PHP_EOL;
                     $contents = TRUE;
                 }
                 if (!empty($row['cleared'])) {
                     $desc .= $t->_('Cleared') . ': ';
                     $desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
                     $desc .= PHP_EOL;
                     $contents = TRUE;
                 }
                 if (!empty($row['cleared_in'])) {
                     $desc .= $t->_('Cleared In') . ': ';
                     $desc .= $row['cleared_in'];
                     $desc .= PHP_EOL;
                     $contents = TRUE;
                 }
                 if ($contents) {
                     $updateDescription[$row['id']] = $desc . PHP_EOL;
                 }
             }
             if (count($updateDescription) > 50) {
                 foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
                     $contr->description = $updateDescription[$contr->getId()];
                     $controller->update($contr, FALSE);
                 }
                 $updateDescription = array();
             }
             if (count($results) < $count) {
                 $more = FALSE;
             } else {
                 $offset = $offset + $count;
             }
         }
         try {
             foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
                 $contr->description = $updateDescription[$contr->getId()];
                 $controller->update($contr, FALSE);
             }
         } catch (Tinebase_Exception_AccessDenied $tead) {
             // could not update contracts ...
             Tinebase_Exception::log($tead);
         }
     }
     // remove deprecated sales contract fields
     foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
         try {
             $this->_backend->dropCol('sales_contracts', $colToDrop);
         } catch (Zend_Db_Statement_Exception $zdse) {
             Tinebase_Exception::log($zdse);
         }
     }
     // add new sales contract fields
     $fields = array('<field>
         <name>start_date</name>
         <type>datetime</type>
     </field>', '
     <field>
         <name>end_date</name>
         <type>datetime</type>
     </field>');
     foreach ($fields as $field) {
         try {
             $declaration = new Setup_Backend_Schema_Field_Xml($field);
             $this->_backend->addCol('sales_contracts', $declaration);
         } catch (Zend_Db_Statement_Exception $zdse) {
             Tinebase_Exception::log($zdse);
         }
     }
     $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'last_modified_time' => array('name' => 'last_modified_time'), 'end_date' => array('name' => 'end_date'), 'start_date' => array('name' => 'start_date'))));
     $db = $table->getAdapter();
     $values = array_keys($setEndDate);
     if (!empty($values)) {
         $sql = 'UPDATE ' . $db->quoteIdentifier(SQL_TABLE_PREFIX . 'sales_contracts') . ' SET ' . $db->quoteIdentifier('start_date') . ' = ' . $db->quoteIdentifier('last_modified_time') . ', ' . $db->quoteIdentifier('end_date') . ' = ' . $db->quoteIdentifier('last_modified_time') . ' WHERE ' . $db->quoteIdentifier('id') . $db->quoteInto(' IN (?)', $values);
         $db->query($sql);
     }
     if ($this->getTableVersion('sales_contracts') == 5) {
         $this->setTableVersion('sales_contracts', 6);
     } else {
         $this->setTableVersion('sales_contracts', 7);
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:101,代码来源:Release8.php

示例15: updateReadedAd

 public function updateReadedAd($id)
 {
     $table = new Zend_Db_Table('readedAdCount');
     $id = (int) $id;
     $sql = "INSERT INTO readedAdCount   ( id_ad, counter ) VALUES  ( {$id} , 1 )\n                            ON DUPLICATE KEY UPDATE  counter=counter+1";
     $table->getAdapter()->query($sql)->fetch();
 }
开发者ID:Arteaga2k,项目名称:nolotiro,代码行数:7,代码来源:Ad.php


注:本文中的Zend_Db_Table::getAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。