當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。