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


PHP Doctrine_Core::generateModelsFromDb方法代碼示例

本文整理匯總了PHP中Doctrine_Core::generateModelsFromDb方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Core::generateModelsFromDb方法的具體用法?PHP Doctrine_Core::generateModelsFromDb怎麽用?PHP Doctrine_Core::generateModelsFromDb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine_Core的用法示例。


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

示例1: execute

 public function execute()
 {
     $configs = $this->dispatcher->getConfig();
     $options = isset($configs['generate_models_options']) ? $configs['generate_models_options'] : array();
     Doctrine_Core::generateModelsFromDb($this->getArgument('models_path'), (array) $this->getArgument('connection'), $options);
     $this->notify('Generated models successfully from databases');
 }
開發者ID:sgoen,項目名稱:shumvc,代碼行數:7,代碼來源:GenerateModelsDb.php

示例2: generateModelFromDb

 private function generateModelFromDb()
 {
     $con_name = $this->getArgumentsvalue('name');
     if ($con_name === 'schema.yml') {
         $con_name = $this->Con->getName();
     }
     \Doctrine_Core::generateModelsFromDb($this->getOptionsValue('models-path'), array($con_name), $this->getImportOptions());
 }
開發者ID:Nivl,項目名稱:Ninaca_1,代碼行數:8,代碼來源:GenerateModels.class.php

示例3: generateYamlFromDb

 /**
  * Generates models from database to temporary location then uses those models to generate a yaml schema file.
  * This should probably be fixed. We should write something to generate a yaml schema file directly from the database.
  *
  * @param string $yamlPath Path to write oyur yaml schema file to
  * @param array $connections Array of connection names to generate yaml for
  * @param array  $options Array of options
  * @return void
  */
 public static function generateYamlFromDb($yamlPath, array $connections = array(), array $options = array())
 {
     $directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models';
     $options['generateBaseClasses'] = isset($options['generateBaseClasses']) ? $options['generateBaseClasses'] : false;
     $result = Doctrine_Core::generateModelsFromDb($directory, $connections, $options);
     if (empty($result) && !is_dir($directory)) {
         throw new Doctrine_Exception('No models generated from your databases');
     }
     $export = new Doctrine_Export_Schema();
     $result = $export->exportSchema($yamlPath, 'yml', $directory, array(), Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     Doctrine_Lib::removeDirectories($directory);
     return $result;
 }
開發者ID:atikahmed,項目名稱:joomla-probid,代碼行數:22,代碼來源:Core.php

示例4: array

<?php

require_once "init.php";
Doctrine_Core::generateModelsFromDb('app/models', array('doctrine'), array('generateTableClasses' => true));
//Doctrine_Core::generateModelsFromYaml('yaml/schema.yml', 'app/models');
開發者ID:makmonty,項目名稱:movac,代碼行數:5,代碼來源:create_schema.php

示例5: _generateModels

 /**
  * Generate a set of models for the schema information source
  *
  * @param  string $prefix  Prefix to generate the models with
  * @param  mixed  $item    The item to generate the models from
  * @return string $path    The path where the models were generated
  * @throws Doctrine_Migration_Exception $e
  */
 protected function _generateModels($prefix, $item)
 {
     $path = $this->_tmpPath . DIRECTORY_SEPARATOR . strtolower($prefix) . '_doctrine_tmp_dirs';
     $options = array('classPrefix' => $prefix, 'generateBaseClasses' => false);
     if (is_string($item) && file_exists($item)) {
         $extension = $this->_getItemExtension($item);
         if ($extension === 'yml') {
             Doctrine_Core::generateModelsFromYaml($item, $path, $options);
             return $path;
         } else {
             if ($extension === 'php') {
                 Doctrine_Lib::copyDirectory($item, $path);
                 return $path;
             } else {
                 throw new Doctrine_Migration_Exception('No php or yml files found at path: "' . $item . '"');
             }
         }
     } else {
         try {
             Doctrine_Core::generateModelsFromDb($path, (array) $item, $options);
             return $path;
         } catch (Exception $e) {
             throw new Doctrine_Migration_Exception('Could not generate models from connection: ' . $e->getMessage());
         }
     }
 }
開發者ID:szelpe,項目名稱:cukorka,代碼行數:34,代碼來源:Diff.php

示例6: generateMigrationsFromDb

 /**
  * Generate a set of migration classes from the existing databases
  *
  * @return void
  */
 public function generateMigrationsFromDb()
 {
     $directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models';
     Doctrine_Core::generateModelsFromDb($directory);
     $result = $this->generateMigrationsFromModels($directory, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     Doctrine_Lib::removeDirectories($directory);
     return $result;
 }
開發者ID:atikahmed,項目名稱:joomla-probid,代碼行數:13,代碼來源:Builder.php

示例7: action_admin_db2models

 /**
  * db2models
  *
  * This generates Models from Database.
  *
  * @see Doctrine_Core::generateModelsFromDb
  */
 public function action_admin_db2models()
 {
     Doctrine_Core::generateModelsFromDb(DOCTRINE_MODELS_PATH, array(), self::$options);
     $message = '<b>The MODEL files have been generated from DATABASE.</b>';
     $message .= '<br /><br />Destination Folder: ' . DOCTRINE_MODELS_PATH;
     self::setFlashmessage('success', $message);
     $this->redirectToReferer();
 }
開發者ID:Clansuite,項目名稱:Clansuite,代碼行數:15,代碼來源:DoctrineAdminController.php

示例8: execute

 public function execute()
 {
     Doctrine_Core::generateModelsFromDb($this->getArgument('models_path'), (array) $this->getArgument('connection'));
     $this->notify('Generated models successfully from databases');
 }
開發者ID:tests1,項目名稱:zendcasts,代碼行數:5,代碼來源:GenerateModelsDb.php

示例9: spl_autoload_register

<?php

/*
 * pagina creadora de clases asociadas a la base de datos.
 */
require_once '../_lib/tools/Doctrine-1.2.3/Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$conn = Doctrine_Manager::connection('mysql://localhost:root@localhost/', 'doctrine');
// echo $_SERVER['DOCUMENT_ROOT'] ;
Doctrine_Core::generateModelsFromDb('localhost', array('doctrine'), array('generateTableClasses' => true, 'baseClassPrefix' => 'Base', 'suffix' => '.db.class.php'));
開發者ID:r0b0k,項目名稱:PHP-FUS,代碼行數:10,代碼來源:php_create_orm_model.php

示例10: updateModels

 /**
  * 根據數據庫表 更新 Doctrine 對應的文件
  */
 public function updateModels()
 {
     $result = array();
     $result2 = array();
     // 生成 ORM 文件
     Doctrine_Core::generateModelsFromDb($this->tmpDir);
     // Base 文件
     $files = $this->getFileList($this->tmpBaseDir);
     foreach ($files as $file) {
         // 清除以前生產的文件
         if (is_file($this->pdoBaseDir . $file['name'])) {
             unlink($this->pdoBaseDir . $file['name']);
         }
         // 讀取文件
         $str = file_get_contents($file['path']);
         // 更新Pdo文件製定連接
         $strlne = strlen($file['name']) - 4;
         $BaseClassName = substr($file['name'], 4, $strlne - 4);
         // Member
         $str = str_replace("bindComponent('{$BaseClassName}',", "bindComponent('Pdo{$BaseClassName}',", $str);
         // 寫入文件
         file_put_contents($this->pdoBaseDir . $file['name'], $str);
         @chmod($this->pdoBaseDir . $file['name'], 0777);
         // 刪除臨時文件
         @unlink($file['path']);
     }
     $result[] = '[更新] application/models/Pdo/Base/*';
     // Pdo 文件
     $files = $this->getFileList($this->tmpDir);
     foreach ($files as $file) {
         $CI =& get_instance();
         $model = '';
         $strlne = strlen($file['name']) - 4;
         $oldClassName = substr($file['name'], 0, $strlne);
         // Member , 去掉 .php
         $className = 'Pdo' . $oldClassName;
         // PdoMember
         $Model_PdoName = $className;
         // PdoMember
         $Model_BaseName = 'Base' . $oldClassName;
         // BaseMember
         $Model_Name = $oldClassName;
         // Member
         $Model_Full_Name = 'Model_' . $Model_Name;
         //Model_Member
         $Lower_Model_Name = $this->lowerFirstChar($Model_Name);
         // member
         if (!is_file($this->pdoDir . $className . '.php')) {
             // 讀取文件
             $str = file_get_contents($file['path']);
             // 更新Class Name
             $str = str_replace('class ' . $oldClassName, 'class ' . $className, $str);
             // 寫入文件
             file_put_contents($this->pdoDir . $className . '.php', $str);
             @chmod($this->pdoDir . $className . '.php', 0777);
             // 所有字段
             $model = new $className();
             $columns = array();
             foreach ($model as $column => $value) {
                 $columns[] = $column;
             }
             // 添加驗證功能
             $data = array();
             $data['Model_PdoName'] = $Model_PdoName;
             $data['Model_BaseName'] = $Model_BaseName;
             $data['Model_Full_Name'] = $Model_Full_Name;
             $data['columns'] = $columns;
             $str = '<?php' . $CI->load->view('deepci_helper/models/Pdo.php', $data, true);
             // 寫入文件
             file_put_contents($this->pdoDir . $className . '.php', $str);
             @chmod($this->pdoDir . $className . '.php', 0777);
             $result[] = '[生成] application/models/Pdo/' . $className . '.php';
         }
         // 生成Model文件
         if (!is_file($this->modelDir . $Model_Name . '.php') && !in_array($Model_Name, $this->ignore)) {
             if (empty($columns)) {
                 $model = new $className();
                 $columns = array();
                 foreach ($model as $column => $value) {
                     $columns[] = $column;
                 }
             }
             $data = array();
             $data['Model_PdoName'] = $Model_PdoName;
             $data['columns'] = $columns;
             $data['Model_Name'] = $Model_Name;
             $data['Model_Full_Name'] = $Model_Full_Name;
             $str = '<?php' . $CI->load->view('deepci_helper/models/Model.php', $data, true);
             $str = str_replace('{#member}', $Lower_Model_Name, $str);
             //寫入文件
             file_put_contents($this->modelDir . $Model_Name . '.php', $str);
             @chmod($this->modelDir . $Model_Name . '.php', 0777);
             $result2[] = '[生成] application/models/Modle/' . $Model_Name . '.php';
         }
         unlink($file['path']);
     }
     return array_merge($result, $result2);
//.........這裏部分代碼省略.........
開發者ID:laiello,項目名稱:deep-ci,代碼行數:101,代碼來源:Doctrine.php

示例11: methodGenerateModel

 function methodGenerateModel()
 {
     Doctrine_Core::generateModelsFromDb('flexiphp/assets/temp/models', array('doctrine'), array('generateTableClasses' => true));
     return true;
 }
開發者ID:u007,項目名稱:FlexiPHP,代碼行數:5,代碼來源:controller.php


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