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