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


PHP Doctrine類代碼示例

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


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

示例1: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     sfContext::createInstance($this->configuration);
     $blast = Doctrine::getTable('Blast')->find(1);
     $response = Doctrine::getTable('BlastResponse')->find(1);
     BlastManager::createTextResponse($response);
 }
開發者ID:jnankin,項目名稱:makeaminyan,代碼行數:10,代碼來源:TestEmailTask.class.php

示例2: executeDelete

 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($encuestado_sanciones = Doctrine::getTable('EncuestadoSanciones')->find(array($request->getParameter('id'))), sprintf('Object encuestado_sanciones does not exist (%s).', $request->getParameter('id')));
     $encuestado_sanciones->delete();
     $this->redirect('EncuestadoSancionesVigentes/index');
 }
開發者ID:rmoralesm,項目名稱:FONDEF-D08I1205,代碼行數:7,代碼來源:actions.class.php

示例3: getInstance

 /**
  * Singleton pattern, returneaza conexiunea
  * @return EntityManger
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new Doctrine();
     }
     return self::$instance;
 }
開發者ID:bardascat,項目名稱:blogify,代碼行數:11,代碼來源:Doctrine.php

示例4: authenticateUserRequest

 public function authenticateUserRequest()
 {
     $authResult = $this->authenticateKey($this->request->getParameter('_key'));
     switch ($authResult) {
         case self::AUTH_FAIL_KEY:
             $this->response->setStatusCode(401);
             sfLoader::loadHelpers('Partial');
             $partial = get_partial('global/401');
             $this->response->setContent($partial);
             $this->response->setHttpHeader('WWW-Authenticate', 'Your request must include a query parameter named "_key" with a valid API key value. To obtain an API key, visit http://api.littlesis.org/register');
             $this->response->sendHttpHeaders();
             $this->response->sendContent();
             throw new sfStopException();
             break;
         case self::AUTH_FAIL_LIMIT:
             $this->response = sfContext::getInstance()->getResponse();
             $this->response->setStatusCode(403);
             $user = Doctrine::getTable('ApiUser')->findOneByApiKey($this->request->getParameter('_key'));
             sfLoader::loadHelpers('Partial');
             $partial = get_partial('global/403', array('request_limit' => $user->request_limit));
             $this->response->setContent($partial);
             $this->response->sendHttpHeaders();
             $this->response->sendContent();
             throw new sfStopException();
             break;
         case self::AUTH_SUCCESS:
             break;
         default:
             throw new Exception("Invalid return value from LsApi::autheticate()");
     }
 }
開發者ID:silky,項目名稱:littlesis,代碼行數:31,代碼來源:LsApiRequestFilter.class.php

示例5: doSave

 protected function doSave($con = null)
 {
     parent::doSave();
     $newOptions = $this->getValue('option');
     $newOptions = preg_split('/[\\s ]+/u', $newOptions, -1, PREG_SPLIT_NO_EMPTY);
     $voteQuestion = $this->getObject();
     // 過去の選択肢の抽出
     $oldOptions = $voteQuestion->getVoteQuestionOptions();
     $oldOptions = $oldOptions->toKeyValueArray('id', 'body');
     // 削除された選択肢の抽出
     $deletedOptions = array_diff($oldOptions, $newOptions);
     foreach ($deletedOptions as $id => $body) {
         // 削除
         $object = Doctrine::getTable('VoteQuestionOption')->find($id);
         $object->delete();
     }
     // 新規の選択肢
     $insertOptions = array_diff($newOptions, $oldOptions);
     foreach ($insertOptions as $body) {
         // 追加
         $object = new VoteQuestionOption();
         $object->setVoteQuestion($voteQuestion);
         $object->setBody($body);
         $object->save();
     }
 }
開發者ID:rysk92,項目名稱:opVotePlugin,代碼行數:26,代碼來源:PluginVoteQuestionForm.class.php

示例6: executeDelete

 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($product = Doctrine::getTable('Product')->find(array($request->getParameter('id'))), sprintf('Object product does not exist (%s).', array($request->getParameter('id'))));
     $product->delete();
     $this->redirect('product/index');
 }
開發者ID:nubee,項目名稱:nubee,代碼行數:7,代碼來源:actions.class.php

示例7: execute

 protected function execute($arguments = array(), $options = array())
 {
     $app = $options['app'];
     $env = $options['env'];
     $this->bootstrapSymfony($app, $env, true);
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase('doctrine')->getConnection();
     $this->logSection('import', 'initializing...');
     $plugins = SymfonyPluginApi::getPlugins();
     $count = 0;
     foreach ($plugins as $plugin) {
         $new = Doctrine::getTable('SymfonyPlugin')->findOneByTitle($plugin['id']);
         // if plugin exists update info.  Otherwise, create it
         if ($new) {
             // Nothing Yet
         } elseif ($plugin['id']) {
             $new = new SymfonyPlugin();
             $new['title'] = (string) $plugin['id'];
             $new['description'] = (string) $plugin->description;
             $new['repository'] = (string) $plugin->scm;
             $new['image'] = (string) $plugin->image;
             $new['homepage'] = (string) $plugin->homepage;
             $new['ticketing'] = (string) $plugin->ticketing;
             $new->saveNoIndex();
             $this->logSection('import', "added '{$new->title}'");
             $count++;
         }
     }
     $this->logSection('import', "Running Lucene Cleanup");
     $this->runLuceneRebuild();
     $this->logSection('import', "Completed.  Added {$count} new plugins(s)");
 }
開發者ID:bshaffer,項目名稱:Symplist,代碼行數:33,代碼來源:importSymfonyPluginsTask.class.php

示例8: signIn

 /**
  * Авторизовать пользователя
  *
  * @param  User $user
  * @param  bool $remember
  * @return void
  */
 public function signIn(User $user, $remember = false)
 {
     $this->user = $user;
     $this->setAttribute('id', $user->getId(), 'user');
     $this->setAuthenticated(true);
     $this->clearCredentials();
     if ($remember) {
         $now = new DateTime();
         $expired = clone $now;
         $expired->modify("-" . $this->getExpiration() . " sec");
         // убить все старые кючи
         Doctrine::getTable('myAuthRememberKey')->removeOldKeys($expired)->execute();
         // убить все ключи этого пользователя
         Doctrine::getTable('myAuthRememberKey')->removeKeysByUserId($user->getId())->execute();
         // создать новый ключ
         $key = $this->generateRandomKey();
         // сохранить ключ
         $rk = new myAuthRememberKey();
         $rk->setRememberKey($key);
         $rk->setUser($user);
         $rk->setIpAddress($_SERVER['REMOTE_ADDR']);
         $rk->save();
         // отдать ключ в виде печенья
         sfContext::getInstance()->getResponse()->setCookie($this->getCookieName(), $key, time() + $this->getExpiration());
     }
 }
開發者ID:EasyFinance,項目名稱:myAuthPlugin,代碼行數:33,代碼來源:myAuthSecurityUser.class.php

示例9: executeAjaxCustomerAutocomplete

 /**
  * ajax action for customer name autocompletion
  *
  * @return JSON
  * @author Enrique Martinez
  **/
 public function executeAjaxCustomerAutocomplete(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     $q = $request->getParameter('q');
     $items = Doctrine::getTable('Customer')->simpleRetrieveForSelect($request->getParameter('q'), $request->getParameter('limit'));
     return $this->renderText(json_encode($items));
 }
開發者ID:solutema,項目名稱:siwapp-sf1,代碼行數:13,代碼來源:actions.class.php

示例10: executeDelete

 public function executeDelete(sfWebRequest $request)
 {
     $this->forward404Unless($area_interesse = Doctrine::getTable('AreaInteresse')->find(array($request->getParameter('id'))), sprintf('Object area_interesse does not exist (%s).', $request->getParameter('id')));
     $area_interesse->delete();
     $this->getUser()->setFlash('success', 'Área de Interesse excluída com sucesso!');
     $this->redirect('areaInteresse/index');
 }
開發者ID:kidh0,項目名稱:TCControl,代碼行數:7,代碼來源:actions.class.php

示例11: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('doctrine', 'created tables successfully');
     $databaseManager = new sfDatabaseManager($this->configuration);
     Doctrine::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE);
     Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
 }
開發者ID:yasirgit,項目名稱:afids,代碼行數:10,代碼來源:sfDoctrineInsertSqlTask.class.php

示例12: execute

 protected function execute($arguments = array(), $options = array())
 {
     $con = $this->crearConexion();
     try {
         $record = Doctrine::getTable('EmailConfiguration')->findAll()->getFirst();
         $config_mail = array('charset' => 'UTF-8', 'encryption' => $record->getSmtpSecurityType(), 'host' => $record->getSmtpHost(), 'port' => $record->getSmtpPort(), 'username' => $record->getSmtpUsername(), 'password' => $record->getSmtpPassword(), 'authentication' => $record->getSmtpAuthType());
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->CharSet = $config_mail['charset'];
         if ($config_mail['authentication'] == "login") {
             $mail->SMTPAuth = true;
         }
         if ($config_mail['encryption'] == "tls") {
             $mail->SMTPSecure = "tls";
         }
         if ($config_mail['encryption'] == "ssl") {
             $mail->SMTPSecure = "ssl";
         }
         $mail->Host = $config_mail['host'];
         $mail->Port = $config_mail['port'];
         $mail->Username = $config_mail['username'];
         $mail->Password = $config_mail['password'];
         $mail->FromName = 'Mi company';
         $mail->From = $config_mail['username'];
         //email de remitente desde donde se env?a el correo
         $mail->AddAddress($config_mail['username'], 'Destinatario');
         //destinatario que va a recibir el correo
         $mail->Subject = "confeccion de gafete";
         /*Recojemos los datos del oficial*/
         $dao = new EmployeeDao();
         $employeeList = $dao->getEmployeeList();
         foreach ($employeeList as $employee) {
             if ($employee->getJoinedDate() != "") {
                 $datetime1 = new DateTime($employee->getJoinedDate());
                 $datetime2 = new DateTime(date('y-m-d', time()));
                 $formato = $datetime2->format('y-m-d');
                 $intervalo = $datetime1->diff($datetime2, true);
                 if ($intervalo->m == 2 && $intervalo->d == 0) {
                     $html = "Identificador: " . $employee->getEmployeeId() . "<br/>";
                     $html .= "ID: " . $employee->getOtherId() . "<br/>";
                     $html .= "Nombre      : " . utf8_encode($employee->getFullName()) . "<br/>";
                     $html .= "Fecha Nac   : " . $employee->getEmpBirthday() . "<br/>";
                     $sexo = $employee->getEmpGender() == 1 ? "Masculino" : "Femenino";
                     $html .= "G&eacute;nero      : " . $sexo . "<br/>";
                     $html .= "Nacionalidad: " . $employee->getNationality() . "<br/>";
                     $html .= "M&oacute;vil: " . $employee->getEmpMobile() . "<br/>";
                     $mail->MsgHTML($html);
                     if (!$mail->Send()) {
                         $this->escribirYML('log_tareas', false, $mail->ErrorInfo . " Error al enviar el correo  con los datos del empleado " . $employee->getFullName());
                     } else {
                         $this->escribirYML('log_tareas', true, "correo enviado  con los datos del empleado " . $employee->getFullName());
                     }
                 }
             }
         }
         Doctrine_Manager::getInstance()->closeConnection($con);
     } catch (Exception $e) {
         $this->escribirYML('log_tareas', false, $e->getMessage());
     }
 }
開發者ID:abdocmd,項目名稱:spmillen,代碼行數:60,代碼來源:notificacionEstadiaDosMesesTask.class.php

示例13: executeChangeOrder

 public function executeChangeOrder(sfWebRequest $request)
 {
     $col1 = explode(',', $request->getParameter('col1'));
     $col2 = explode(',', $request->getParameter('col2'));
     Doctrine::getTable('MyWidgets')->setUserRef($this->getUser()->getAttribute('db_user_id'))->changeOrder($request->getParameter('category') . "_widget", $col1, $col2);
     return $this->renderText(var_export($col1, true) . var_export($col2, true));
 }
開發者ID:naturalsciences,項目名稱:Darwin,代碼行數:7,代碼來源:actions.class.php

示例14: setup

 public function setup()
 {
     $db = $this->databasemanager->getDatabase('doctrine');
     /* @var $db sfDoctrineDatabase */
     // Special Handling for postgre, since droping even when closing the connection, fails with
     // SQLSTATE[55006]: Object in use: 7 ERROR:  database "cs_doctrine_act_as_sortable_test" is being accessed by other users DETAIL:  There are 1 other session(s) using the database.
     if ($db->getDoctrineConnection() instanceof Doctrine_Connection_Pgsql) {
         try {
             $db->getDoctrineConnection()->createDatabase();
         } catch (Exception $e) {
         }
         $export = new Doctrine_Export_Pgsql($db->getDoctrineConnection());
         $import = new Doctrine_Import_Pgsql($db->getDoctrineConnection());
         $tablenames = array(SortableArticleTable::getInstance()->getTableName(), SortableArticleUniqueByTable::getInstance()->getTableName(), SortableArticleCategoryTable::getInstance()->getTableName());
         foreach ($tablenames as $tablename) {
             if ($import->tableExists($tablename)) {
                 $export->dropTable($tablename);
             }
         }
     } else {
         try {
             // ignore error if database does not yet exist (clean CI-env)
             $db->getDoctrineConnection()->dropDatabase();
         } catch (Exception $e) {
         }
         $db->getDoctrineConnection()->createDatabase();
     }
     // Using Doctrine instead of Doctrine_Core keeps it symfony 1.2 compatible, which uses
     Doctrine::loadModels(dirname(__FILE__) . '/../fixtures/project/lib/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE);
     Doctrine::createTablesFromArray(Doctrine::getLoadedModels());
     Doctrine::loadData(dirname(__FILE__) . '/../fixtures/project/data/fixtures/categories.yml');
 }
開發者ID:robo47,項目名稱:csDoctrineActAsSortablePlugin-1,代碼行數:32,代碼來源:sfPluginTestBootstrap.class.php

示例15: executeActivityBox

 public function executeActivityBox(sfWebRequest $request)
 {
     $id = $request->getParameter('id', $this->getUser()->getMemberId());
     $this->activities = Doctrine::getTable('ActivityData')->getActivityList($id, null, $this->gadget->getConfig('row'));
     $this->member = Doctrine::getTable('Member')->find($id);
     $this->isMine = $id == $this->getUser()->getMemberId();
 }
開發者ID:phenom,項目名稱:OpenPNE3,代碼行數:7,代碼來源:sfOpenPNEMemberComponents.class.php


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