當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Db_Table_Abstract類代碼示例

本文整理匯總了PHP中Zend_Db_Table_Abstract的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Db_Table_Abstract類的具體用法?PHP Zend_Db_Table_Abstract怎麽用?PHP Zend_Db_Table_Abstract使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Zend_Db_Table_Abstract類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: analyzeTable

 /**
  * Start analyzer
  *
  * @param Zend_Db_Table_Abstract $table
  *
  * @return array
  */
 public function analyzeTable(Zend_Db_Table_Abstract $table)
 {
     $info = $table->info();
     $info['uniques'] = array();
     unset($info['sequence'], $info['schema'], $info['rowClass'], $info['rowsetClass'], $info['dependentTables'], $info['referenceMap']);
     $adapter = $table->getAdapter();
     foreach ($info['metadata'] as $property => $details) {
         // match php types
         $info['phptypes'][$property] = $this->convertMysqlTypeToPhp($details['DATA_TYPE']);
         // find uniques
         $tmp = $adapter->fetchRow('DESCRIBE `' . $info['name'] . '` `' . $property . '`;');
         if (!empty($tmp['Key']) && $tmp['Key'] != 'MUL') {
             $info['uniques'][$property] = $property;
         }
     }
     // get f-keys
     $result = $adapter->fetchAll('SHOW CREATE TABLE `' . $info['name'] . '`');
     $query = $result[0]['Create Table'];
     $lines = explode("\n", $query);
     $tblinfo = array();
     $keys = array();
     foreach ($lines as $line) {
         preg_match('/^\\s*CONSTRAINT `(\\w+)` FOREIGN KEY \\(`(\\w+)`\\) REFERENCES `(\\w+)` \\(`(\\w+)`\\)/', $line, $tblinfo);
         if (sizeof($tblinfo) > 0) {
             $keys[] = $tmp = array('key' => $tblinfo[1], 'column' => $tblinfo[2], 'fk_table' => $tblinfo[3], 'fk_column' => $tblinfo[4]);
             $this->getDependencyChecker()->isChild($info['name'], $tmp['column'], $tmp['key'], $tmp['fk_table'], $tmp['fk_column']);
         }
     }
     $info['foreign_keys'] = $keys;
     return $info;
 }
開發者ID:redpmorg,項目名稱:Zend-Model-Generator,代碼行數:38,代碼來源:Analyser.php

示例2: setModel

 public function setModel(Zend_Db_Table_Abstract $model)
 {
     $this->_model = $model;
     $this->_setPrimaryIndex($this->_model->getPrimaryIndex());
     $info = $model->info();
     $this->_columns = $info['cols'];
 }
開發者ID:laiello,項目名稱:digitalus-cms,代碼行數:7,代碼來源:Form.php

示例3: __construct

 /**
  * Creating a query using a Model.
  *
  * @param Zend_Db_Table_Abstract $model
  * @param array                  $relationmap Relation map for joins
  *
  * @return $this
  */
 public function __construct(Zend_Db_Table_Abstract $model, array $relationMap = array())
 {
     $this->_model = $model;
     $this->_relationMap = $relationMap;
     $info = $model->info();
     $select = $model->select();
     $map = $info['referenceMap'];
     $map = array_merge_recursive($map, $this->_relationMap);
     if (is_array($map) && count($map) > 0) {
         $select->setIntegrityCheck(false);
         $columnsToRemove = array();
         foreach ($map as $sel) {
             if (is_array($sel['columns'])) {
                 $columnsToRemove = array_merge($columnsToRemove, $sel['columns']);
             } else {
                 $columnsToRemove[] = $sel['columns'];
             }
         }
         $columnsMainTable = array_diff($info['cols'], $columnsToRemove);
         $select->from($info['name'], $columnsMainTable, $info['schema']);
         $tAlias = array($info['name'] => 1);
         $this->_setJoins($info['name'], $map, $select, $tAlias);
     } else {
         $select->from($info['name'], $info['cols'], $info['schema']);
     }
     parent::__construct($select);
     return $this;
 }
開發者ID:robjacoby,項目名稱:xlr8u,代碼行數:36,代碼來源:Table.php

示例4: dispatchLoopStartup

 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $result = $auth->getStorage();
     $identity = $auth->getIdentity();
     $registry = Zend_Registry::getInstance();
     $config = Zend_Registry::get('config');
     $module = strtolower($this->_request->getModuleName());
     $controller = strtolower($this->_request->getControllerName());
     $action = strtolower($this->_request->getActionName());
     if ($identity && $identity != "") {
         $layout = Zend_Layout::getMvcInstance();
         $view = $layout->getView();
         $view->login = $identity;
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $id = $siteInfoNamespace->userId;
         $view->firstname = $siteInfoNamespace->Firstname;
         $username = $siteInfoNamespace->username;
         $password = $siteInfoNamespace->password;
         $db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $config->resources->db->params->host, 'username' => $username, 'password' => $password, 'dbname' => $config->resources->db->params->dbname));
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
         return;
     } else {
         $siteInfoNamespace = new Zend_Session_Namespace('siteInfoNamespace');
         $siteInfoNamespace->requestURL = $this->_request->getParams();
         $this->_request->setModuleName('default');
         $this->_request->setControllerName('Auth');
         $this->_request->setActionName('login');
     }
 }
開發者ID:papoteur-mga,項目名稱:phpip,代碼行數:30,代碼來源:AuthPlugin.php

示例5: editarAction

 public function editarAction()
 {
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $ok = true;
         // disativa todos os precos do salao
         $modelEspecialidadePreco = new Model_DbTable_EspecialidadePreco();
         $modelEspecialidadePreco->update(array('especialidade_preco_ativo' => 0), "salao_id = {$this->_auth->salao_id}");
         Zend_Db_Table_Abstract::getDefaultAdapter()->beginTransaction();
         foreach ($data['especialidade_preco'] as $key => $value) {
             if (!empty($value)) {
                 try {
                     $value = str_replace('.', '', $value);
                     $value = str_replace(',', '.', $value);
                     $data_insert = array('especialidade_id' => $key, 'salao_id' => $this->_auth->salao_id, 'especialidade_preco_preco' => $value);
                     $modelEspecialidadePreco->insert($data_insert);
                 } catch (Exception $ex) {
                     $ok = false;
                     $this->_helper->flashMessenger->addMessage(array('danger' => 'Houve um problema ao editar os preços. ' . $ex->getMessage()));
                     Zend_Db_Table_Abstract::getDefaultAdapter()->rollBack();
                 }
             }
         }
         Zend_Db_Table_Abstract::getDefaultAdapter()->commit();
         if ($ok) {
             $this->_helper->flashMessenger->addMessage(array('success' => 'Preços alterados com sucesso'));
         }
         $this->_redirect("/salao/preco");
     }
 }
開發者ID:nandorodpires2,項目名稱:homemakes,代碼行數:30,代碼來源:PrecoController.php

示例6: save

 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkCeop($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('CEOP iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_dec'])) {
             $history = 'INSERE CEOP-DEC: %s- INSERIDO NOVO CEOP-DEC COM SUCESSO';
             $this->_data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $this->_data['registry_date'] = Zend_Date::now()->toString('yyyy-MM-dd');
         } else {
             $history = 'ALTERA CEOP-DEC: %s DADUS PRINCIPAL - ALTERA CEOP-DEC';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
開發者ID:fredcido,項目名稱:simuweb,代碼行數:32,代碼來源:Dec.php

示例7: __construct

 public function __construct()
 {
     //set country
     //lookup country from subdomain
     // must be format like http://country.site.org
     $parts = explode('.', $_SERVER['HTTP_HOST']);
     self::$COUNTRY = $parts[0];
     require_once 'settings.php';
     $countryLoaded = false;
     if ($parts[1] == 'trainingdata') {
         Settings::$DB_DATABASE = Globals::$DB_TABLE_PREFIX . $parts[0];
         self::$COUNTRY = $parts[0];
         Settings::$COUNTRY_BASE_URL = 'http://' . $parts[0] . '.' . Globals::$DOMAIN;
         $countryLoaded = true;
     }
     error_reporting(E_ALL);
     // PATH_SEPARATOR =  ; for windows, : for *nix
     $iReturn = ini_set('include_path', Globals::$BASE_PATH . PATH_SEPARATOR . Globals::$BASE_PATH . 'app' . PATH_SEPARATOR . (Globals::$BASE_PATH . 'ZendFramework' . DIRECTORY_SEPARATOR . 'library') . PATH_SEPARATOR . ini_get('include_path'));
     require_once 'Zend/Loader.php';
     if ($countryLoaded) {
         //fixes mysterious configuration issue
         require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
         require_once 'Zend/Db.php';
         //set a default database adaptor
         $db = Zend_Db::factory('PDO_MYSQL', array('host' => Settings::$DB_SERVER, 'username' => Settings::$DB_USERNAME, 'password' => Settings::$DB_PWD, 'dbname' => Settings::$DB_DATABASE));
         require_once 'Zend/Db/Table/Abstract.php';
         Zend_Db_Table_Abstract::setDefaultAdapter($db);
     }
 }
開發者ID:falafflepotatoe,項目名稱:trainsmart-code,代碼行數:29,代碼來源:globals.php

示例8: _initDb

 public function _initDb()
 {
     $resource = $this->getPluginResource('db');
     $options = $resource->getOptions();
     $db = new Zend_Db_Adapter_Pdo_Mysql($options["params"]);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
 }
開發者ID:hocondoimeo,項目名稱:giasu-tam.com,代碼行數:7,代碼來源:Bootstrap.php

示例9: run

 public function run()
 {
     // Lade Konfig
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     Zend_Registry::set('config', $config);
     // Erstelle DB Adapter
     $db = Zend_Db::factory($config->db);
     Zend_Registry::set('db', $db);
     Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('db'));
     if (APPLICATION_ENV !== 'production') {
         $profiler = new Zend_Db_Profiler_Firebug('All Database Queries:');
         $profiler->setEnabled(true);
         $db->setProfiler($profiler);
     }
     $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => ''));
     $resourceLoader->addResourceType('plugins', 'plugins', 'Plugins');
     if (PHP_SAPI != 'cli') {
         $front = Zend_Controller_Front::getInstance();
         $front->registerPlugin(new Plugins_Stats());
         if (APPLICATION_ENV == 'production') {
             $front->registerPlugin(new Plugins_Cache());
         }
     }
     Zend_View_Helper_PaginationControl::setDefaultViewPartial('_partials/controls.phtml');
     parent::run();
 }
開發者ID:network-splash,項目名稱:prepaidvergleich24.info,代碼行數:26,代碼來源:Bootstrap.php

示例10: getAdapter

 /**
  * @return Zend_Db_Adapter_Abstract
  */
 public function getAdapter()
 {
     if (empty($this->adapter)) {
         $this->adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     }
     return $this->adapter;
 }
開發者ID:realejo,項目名稱:library-zf1,代碼行數:10,代碼來源:BaseTestCase.php

示例11: __construct

    /**
     * __construct() - For concrete implementation of Zend_Db_Table
     *
     * @param string|array $config string can reference a Zend_Registry key for a db adapter
     *                             OR it can reference the name of a table
     * @param array|Zend_Db_Table_Definition $definition
     */
     
     
    public function __construct($config = array(), $definition = null)
    {
        if ($definition !== null && is_array($definition)) {
            $definition = new Zend_Db_Table_Definition($definition);
        }

        if (is_string($config)) {
            if (Zend_Registry::isRegistered($config)) {
                trigger_error(__CLASS__ . '::' . __METHOD__ . '(\'registryName\') is not valid usage of Zend_Db_Table, '
                    . 'try extending Zend_Db_Table_Abstract in your extending classes.',
                    E_USER_NOTICE
                    );
                $config = array(self::ADAPTER => $config);
            } else {
                // process this as table with or without a definition
                if ($definition instanceof Zend_Db_Table_Definition
                    && $definition->hasTableConfig($config)) {
                    // this will have DEFINITION_CONFIG_NAME & DEFINITION
                    $config = $definition->getTableConfig($config);
                } else {
                    $config = array(self::NAME => $config);
                }
            }
        }

        parent::__construct($config);
    }
開發者ID:hungnv0789,項目名稱:vhtm,代碼行數:36,代碼來源:Table.php

示例12: save

 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkDistrict($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Distritu iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_adddistrict'])) {
             $history = 'INSERE DISTRITU: %s - INSERIDO NOVO DISTRITU';
         } else {
             $history = 'ALTERA DISTRITU: %s - ALTUALIZADO DISTRITO COM SUCESSO';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['District']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
開發者ID:fredcido,項目名稱:simuweb,代碼行數:30,代碼來源:AddDistrict.php

示例13: loginAction

 public function loginAction()
 {
     //Desabilita renderização da view
     $this->_helper->viewRenderer->setNoRender();
     //Obter o objeto do adaptador para autenticar usando banco de dados
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     //Seta qual tabela e colunas procurar o usuário
     $authAdapter->setTableName('usuario')->setIdentityColumn('login')->setCredentialColumn('senha');
     //Seta as credenciais com dados vindos do formulário de login
     $authAdapter->setIdentity($this->_getParam('login'))->setCredential($this->_getParam('senha'))->setCredentialTreatment('MD5(?)');
     //Realiza autenticação
     $result = $authAdapter->authenticate();
     //Verifica se a autenticação foi válida
     if ($result->isValid()) {
         //Obtém dados do usuário
         $usuario = $authAdapter->getResultRowObject();
         //Armazena seus dados na sessão
         $storage = Zend_Auth::getInstance()->getStorage();
         $storage->write($usuario);
         //Redireciona para o Index
         $this->_redirect('index');
     } else {
         $this->_redirect('autenticacao/falha');
     }
 }
開發者ID:lincolnfatal,項目名稱:projetos,代碼行數:26,代碼來源:AutenticacaoController.php

示例14: find

 /**
  * Find admin
  *
  * @param int $applicationId
  * @param string $username
  * @param Admin_Model_Admin $admin
  * @return boolean
  */
 public function find($applicationId, $username, Admin_Model_Admin $admin)
 {
     $select = $this->_dbTable->select();
     $select->setIntegrityCheck(false)->from(array('a' => 'admin'), array('a.*'))->joinLeft(array("aa" => "admin_application"), "aa.admin_id = a.id")->where('a.username = ?', $username)->where('aa.application_id = ?', $applicationId);
     $resultSet = $this->_dbTable->fetchAll($select);
     if (0 == count($resultSet)) {
         return false;
     }
     //get first row from resultSet
     $row = $resultSet->current();
     $admin->setOptions($row->toArray());
     return true;
 }
開發者ID:bokultis,項目名稱:kardiomedika,代碼行數:21,代碼來源:AdminMapper.php

示例15: update

 public function update($id, $state, $info)
 {
     $data = array('state' => $state, 'info' => $info, 'lastupdate' => time());
     $found = $this->find($id);
     if ($found) {
         $data = array_merge($found, $data);
         unset($data['id']);
         $this->dbTable->update($data, array('id = ?' => $id));
     } else {
         $data['id'] = $id;
         $data['sticked'] = 0;
         $this->dbTable->insert($data);
     }
 }
開發者ID:google-code-backups,項目名稱:vlc-shares,代碼行數:14,代碼來源:Mapper.php


注:本文中的Zend_Db_Table_Abstract類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。