当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine::exportSql方法代码示例

本文整理汇总了PHP中Doctrine::exportSql方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::exportSql方法的具体用法?PHP Doctrine::exportSql怎么用?PHP Doctrine::exportSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine的用法示例。


在下文中一共展示了Doctrine::exportSql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run_doctrine_build_sql

function run_doctrine_build_sql($task, $args)
{
    if (count($args) < 1) {
        throw new Exception('You must provide your app name.');
    }
    $sf_root_dir = sfConfig::get('sf_root_dir');
    define('SF_APP', $args[0]);
    $connection = isset($args[1]) ? $args[1] : 'all';
    simpleAutoloader::registerCallable(array('Doctrine', 'autoload'));
    sfConfig::set('sf_app_module_dir', $sf_root_dir . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR);
    $doctrineSchemaPathScheme = DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR . 'doctrine' . DIRECTORY_SEPARATOR;
    $doctrineModelDir = sfConfig::get('sf_lib_dir') . $doctrineSchemaPathScheme;
    $generatedDir = $doctrineModelDir . 'generated' . DIRECTORY_SEPARATOR;
    $tmp_dir = $sf_root_dir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . md5(uniqid(rand(), true));
    $db_connections = sfYaml::load($sf_root_dir . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'databases.yml');
    if (!isset($db_connections[$connection])) {
        throw new sfException('Unable to find connection: ' . $connection);
    }
    $connection = current($db_connections[$connection]);
    $db = new sfDoctrineDatabase();
    $db->initialize($connection['param']);
    $directories = sfFinder::type('dir')->maxdepth(0)->ignore_version_control()->in(sfConfig::get('sf_model_lib_dir') . '/doctrine');
    foreach ($directories as $directory) {
        $basename = basename($directory);
        $name = $basename == 'generated' ? 'doctrine' : 'doctrine-' . $basename;
        pake_echo_action("Building SQL", $name);
        $sql = implode(";\n\n", Doctrine::exportSql($directory)) . ";\n";
        $sql = str_replace(array(" (", ") ", ","), array("(\n ", ")\n", ",\n"), $sql);
        if (!is_dir($sf_root_dir . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sql')) {
            mkdir($sf_root_dir . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sql');
        }
        $fd = fopen($sf_root_dir . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $name . '.model.sql', 'w+');
        fwrite($fd, $sql);
        fclose($fd);
    }
    return;
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:37,代码来源:sfPakeDoctrine.php


注:本文中的Doctrine::exportSql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。