PHP cli-config.php - doctrine2 + codeigniter2

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP cli-config.php - doctrine2 + codeigniter2相关的知识,希望对你有一定的参考价值。

<?php
use Doctrine\Common\ClassLoader,
    Doctrine\ORM\Configuration,
    Doctrine\ORM\EntityManager,
    Doctrine\Common\Cache\ArrayCache,
    Doctrine\DBAL\Logging\EchoSqlLogger;
 
define('BASEPATH', __DIR__ . '/../system/');
 
require_once __DIR__ . '/config/database.php';
require_once BASEPATH . 'core/Model.php';
require_once __DIR__ . '/libraries/Doctrine/Common/ClassLoader.php';
 
$doctrineClassLoader = new ClassLoader('Doctrine',  __DIR__.'/libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', __DIR__);
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', __DIR__.'/models/proxies');
$proxiesClassLoader->register();
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
 
$cache = new ArrayCache;
// Set up driver
$Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
$Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, realpath('../models'));
$config->setMetadataDriverImpl($driver);
 
// Database connection information
$connectionOptions = array(
    'driver' => 'pdo_mysql',
    'user' =>     $db['default']['username'],
    'password' => $db['default']['password'],
    'host' =>     $db['default']['hostname'],
    'dbname' =>   $db['default']['database']
);
 
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
 
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));

以上是关于PHP cli-config.php - doctrine2 + codeigniter2的主要内容,如果未能解决你的问题,请参考以下文章

php 卸妆o metabox do OCEANWP Extrasdapáginadeediçãodosprodutos do WooCommerce

PHP流程控制之do...while循环的区别

php do / while循环

php学习笔记-do while循环

php / * DODAWANIE PRODUKTU DO KOSZYKA AJAX * /

php wonolog do_action hook