当前位置: 首页>>代码示例>>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;未经允许,请勿转载。