本文整理汇总了PHP中Propel::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::init方法的具体用法?PHP Propel::init怎么用?PHP Propel::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel
的用法示例。
在下文中一共展示了Propel::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @see Console\Command\Command
*/
protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
{
$schemaFile = $input->getArgument('schema-file');
$configFile = $input->getArgument('config-file');
$dataSource = $input->getOption('datasource');
$ignoreConstraints = $input->getOption('ignore-constraints');
// initialize propel
\Propel::init($configFile);
// get xml representation of schema file
$schemaXml = simplexml_load_file($schemaFile);
// intitialize doctrine DBAL with data from propel
$config = \PropelCli\Configuration::getDataSourceConfiguration($dataSource, \Propel::getConfiguration());
$conn = DBAL\DriverManager::getConnection($config->toArray(), new DBAL\Configuration());
$sm = $conn->getSchemaManager();
// create a schema of the existing db
$fromSchema = $sm->createSchema();
// initialize a schema for the updated db
$toSchema = new \Doctrine\DBAL\Schema\Schema();
// generate the schema object
$generator = new \PropelCli\Schema\Generator($schemaXml);
$generator->generate($toSchema);
// generate the sql to migrate from fromSchema to toSchema
$sql = $fromSchema->getMigrateToSql($toSchema, $conn->getDatabasePlatform());
if ($input->getOption('dump-sql')) {
foreach ($sql as $stmt) {
if ($ignoreConstraints && preg_match('/CONSTRAINT/', $stmt)) {
continue;
}
$output->write($stmt . ';' . PHP_EOL);
}
}
}
示例2: tearDown
protected function tearDown()
{
if ($this->con) {
$this->con->rollback();
}
parent::tearDown();
Propel::init(dirname(__FILE__) . '/../../../../fixtures/bookstore/build/conf/bookstore-conf.php');
}
示例3: CI_Propel
public function CI_Propel()
{
define('DS', DIRECTORY_SEPARATOR);
//EDIT for Virtual hosts
set_include_path(get_include_path() . PATH_SEPARATOR . APPPATH . 'models/');
require dirname(__FILE__) . DS . "propel" . DS . 'Propel.php';
Propel::init(APPPATH . DS . "config" . DS . "cpu-conf.php");
}
示例4: testPhpNamingMethod
public function testPhpNamingMethod()
{
set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes");
Propel::init('fixtures/bookstore/build/conf/bookstore-conf.php');
$bookTmap = Propel::getDatabaseMap(BookPeer::DATABASE_NAME)->getTable(BookPeer::TABLE_NAME);
$this->assertEquals('AuthorId', $bookTmap->getColumn('AUTHOR_ID')->getPhpName(), 'setPhpName() uses the default phpNamingMethod');
$pageTmap = Propel::getDatabaseMap(PagePeer::DATABASE_NAME)->getTable(PagePeer::TABLE_NAME);
$this->assertEquals('LeftChild', $pageTmap->getColumn('LEFTCHILD')->getPhpName(), 'setPhpName() uses the configured phpNamingMethod');
}
示例5: initPropel
protected function initPropel(Application $app)
{
if (!class_exists('Propel')) {
require_once $this->guessPropel($app);
}
$modelPath = $this->guessModelPath($app);
$config = $this->guessConfigFile($app);
\Propel::init($config);
set_include_path($modelPath . PATH_SEPARATOR . get_include_path());
$this->alreadyInit = true;
}
示例6: index
public function index()
{
$user = UserQuery::create();
$this->usuarios = $user->find();
// Initialize Propel with the runtime configuration
Session::set('myDbName', 'dokeos_0001');
Propel::init(APP_PATH . 'config/propel/dokeos-conf.php');
$foro = ForumForumQuery::create();
$this->foros = $foro->find();
Session::set('myDbName', 'dokeos_main');
Propel::init(APP_PATH . 'config/propel/dokeos-conf.php');
$user = UserQuery::create();
$this->usuarios2 = $user->find();
}
示例7: initialiseDb
/**
* Initialise the database (we don't always want this, so it's offered separately)
*/
public static function initialiseDb($testMode = false)
{
$projectRoot = self::getProjectRoot();
// Include system models
set_include_path($projectRoot . self::getPaths()->getPathModelsSystem() . PATH_SEPARATOR . get_include_path());
require_once $projectRoot . self::getPaths()->getFilePropelRuntime();
Propel::init($projectRoot . self::getPaths()->getPathConnsSystem() . '/database-conf.php');
// If we're in test mode, autoload the non-test system models
if ($testMode) {
$path = $projectRoot . self::getPaths()->getPathConnsSystem(false) . '/classmap-database-conf.php';
$map = (include $path);
$loader = PropelAutoloader::getInstance();
$loader->addClassPaths($map);
}
// Not normally needed, but the tests use this connection approach even for node schemas
self::autoloadMeshingClasses($testMode);
}
示例8: init
/**
*
* Makes all initialization.
*/
protected function init()
{
/* Checking if HTTPS needed */
if ($this->isSecure() && !isset($_SERVER['HTTPS'])) {
/* Redirecting to HTTPS */
header('Location: https://' . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI']);
/* Further processing is not necessary */
die;
}
/* Propel Initialization */
if (defined('DS_CONFIGFILE')) {
require_once DIR_LIB_PROTECTED . 'propel/runtime/lib/Propel.php';
Propel::init(DIR_SITE . 'build/conf/' . DS_CONFIGFILE . '.php');
set_include_path(DIR_SITE . 'build/classes' . PATH_SEPARATOR . get_include_path());
}
/* Twig Initialization */
require_once DIR_LIB_PROTECTED . 'twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
}
示例9: readConfig
/**
* Read the config file which contains info on the Propel database to work with. Initialize things.
*/
function readConfig()
{
// load config file
include_once 'autoweb.config';
// load the proper propel stuff -- this should be moved to a config file
ini_set('include_path', ini_get('include_path') . ":{$__autowebConfig['propelOutputDir']}");
require_once $__autowebConfig['propelConfFile'];
// walk propel directory for a list of contents
$propelClassesDir = $__autowebConfig['propelOutputDir'] . "/{$__autowebConfig['propelDatabaseName']}";
foreach (new DirectoryIterator($propelClassesDir) as $item) {
if (!(preg_match('/^[^\\.].*\\.php$/', $item) == 1)) {
continue;
}
// skip everything buy PHP classs, skip invisible files
$propelFile = $propelClassesDir . '/' . $item;
require_once $propelFile;
// include everything
}
// start up propel; this will load the database map including info for all included files
Propel::init($__autowebConfig['propelConfFile']);
// load databaseMap into inst var
$this->propelDBMap = Propel::getDatabaseMap($__autowebConfig['propelDatabaseName']);
}
示例10: autoSuggest
function autoSuggest($query)
{
Propel::init("..\\..\\config\\build\\conf\\bookingspace-conf.php");
set_include_path("..\\..\\config\\build\\classes" . PATH_SEPARATOR . get_include_path());
$players = PlayerQuery::create()->where('Player.firstName like ?', '%' . $query . '%')->orWhere('Player.lastName like ?', '%' . $query . '%')->find();
$totalRows = $players->count();
if ($totalRows > 0) {
$items = '<ul class="div-table">';
// var_dump($players->toArray());
foreach ($players->toArray() as $row) {
$items .= '<li><div class="div-table-row">';
$items .= '<div class="div-table-col col-img"><img src="' . PATH_PICS . $row['Photo'] . '" width="90" height="90" /> </div>';
$items .= '<div class="div-table-col">' . $row['LastName'] . ' - ' . $row['FirstName'] . '<br />';
$items .= 'Τηλ. Επικοιν' . $row['Phone'] . '<br />';
$items .= 'Κινητο:' . $row['Mobile'] . '</div>';
$items .= '</div></li>';
}
$items .= '</ul>';
// echo $items;
} else {
$items = "Δεν υπάρχουν εγγραφές";
}
echo $items;
}
示例11: initialize
<?php
/**
* Todas las controladores heredan de esta clase en un nivel superior
* por lo tanto los metodos aqui definidos estan disponibles para
* cualquier controlador.
*
* @category Kumbia
* @package Controller
* */
// @see Controller nuevo controller
require_once CORE_PATH . 'kumbia/controller.php';
// Include the main Propel script
require_once APP_PATH . 'libs/propel/Propel.php';
// Initialize Propel with the runtime configuration
Propel::init(APP_PATH . 'config/propel/dokeos-conf.php');
// Add the generated 'classes' directory to the include path
set_include_path(APP_PATH . 'models');
class AppController extends Controller
{
protected $my_auth;
public $title = "mdokeos";
protected final function initialize()
{
Session::delete('myDbName');
$this->my_auth = new MyAuth();
if (!$this->my_auth->check()) {
Flash::warning($this->my_auth->getError());
Input::delete('password');
View::select(null, 'login');
}
示例12: init
public function init(ModuleManager $moduleManager)
{
\Propel::init(__DIR__ . '/build/conf/hva-conf.php');
set_include_path(__DIR__ . '/build/classes' . PATH_SEPARATOR . get_include_path());
}
示例13: tearDown
protected function tearDown()
{
parent::tearDown();
Propel::init(dirname(__FILE__) . '/../../../fixtures/bookstore/build/conf/bookstore-conf.php');
}
示例14: Benchmark_Timer
require 'propel/Propel.php';
include_once 'Benchmark/Timer.php';
$timer = new Benchmark_Timer();
$timer->start();
// Some utility functions
function boolTest($cond)
{
if ($cond) {
return "[OK]\n";
} else {
return "[FAILED]\n";
}
}
try {
// Initialize Propel
Propel::init($conf_path);
} catch (Exception $e) {
die("Error initializing propel: " . $e->__toString());
}
function check_tables_empty()
{
try {
print "\nChecking to see that tables are empty\n";
print "-------------------------------------\n\n";
print "Ensuring that there are no records in [author] table: ";
$res = AuthorPeer::doSelect(new Criteria());
print boolTest(empty($res));
print "Ensuring that there are no records in [publisher] table: ";
$res2 = PublisherPeer::doSelect(new Criteria());
print boolTest(empty($res2));
print "Ensuring that there are no records in [book] table: ";
示例15: error_reporting
/**
* Includes classes and sets paths required by all applications.
* @package diy-framework
* @author Martynas Jusevicius <pumba@xml.lt>
* @link http://www.xml.lt
*/
error_reporting(E_ALL);
//define("ROOT_DIR", getcwd()."/");
define("PROJECT_NAME", "test-project");
define("CLASSES_DIR", "classes/");
define("MAIN_DIR", CLASSES_DIR . PROJECT_NAME . "/");
define("MODEL_DIR", MAIN_DIR . "model/");
define("PROPEL_PROJECT", PROJECT_NAME . ".model");
// PROPEL
set_include_path("lib/propel/runtime/classes" . PATH_SEPARATOR . get_include_path());
set_include_path("lib/creole/classes" . PATH_SEPARATOR . get_include_path());
require "propel/Propel.php";
Propel::init(MODEL_DIR . "conf/" . PROPEL_PROJECT . "-conf.php");
$con = Propel::getConnection();
$con->executeQuery("SET NAMES utf8;");
$con->executeQuery("SET CHARACTER SET utf8;");
$con->executeQuery('SET character_set_client="utf8"');
$con->executeQuery('SET character_set_connection="utf8"');
$con->executeQuery('SET character_set_results="utf8"');
// DIY FRAMEWORK
set_include_path("lib/diy-framework/classes/diy-framework" . PATH_SEPARATOR . get_include_path());
require "propel/om/BaseObject.php";
// for Resource to extend
require "DIYFrameworkLoader.class.php";
// MODEL
set_include_path(CLASSES_DIR . PATH_SEPARATOR . get_include_path());