2008-02-10 22:08:31 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Doctrine_TestUtil
|
2008-02-11 22:56:26 +03:00
|
|
|
{
|
2008-02-10 22:08:31 +03:00
|
|
|
public static function getConnection()
|
|
|
|
{
|
2008-06-15 19:56:28 +04:00
|
|
|
$connFactory = new Doctrine_ConnectionFactory();
|
|
|
|
|
2008-02-10 22:08:31 +03:00
|
|
|
if (isset($GLOBALS['db_type'], $GLOBALS['db_username'], $GLOBALS['db_password'],
|
|
|
|
$GLOBALS['db_host'], $GLOBALS['db_name'])) {
|
2008-06-15 19:56:28 +04:00
|
|
|
$params = array(
|
|
|
|
'driver' => $GLOBALS['db_type'],
|
|
|
|
'user' => $GLOBALS['db_username'],
|
|
|
|
'password' => $GLOBALS['db_password'],
|
|
|
|
'host' => $GLOBALS['db_host'],
|
|
|
|
'database' => $GLOBALS['db_name']
|
|
|
|
);
|
|
|
|
//$dsn = "{$GLOBALS['db_type']}://{$GLOBALS['db_username']}:{$GLOBALS['db_password']}@{$GLOBALS['db_host']}/{$GLOBALS['db_name']}";
|
|
|
|
//return Doctrine_Manager::connection($dsn, 'testconn');
|
2008-02-10 22:08:31 +03:00
|
|
|
} else {
|
2008-06-15 19:56:28 +04:00
|
|
|
$params = array(
|
|
|
|
'pdo' => new PDO('sqlite::memory:')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $connFactory->createConnection($params);
|
2008-02-10 22:08:31 +03:00
|
|
|
}
|
2008-06-15 19:56:28 +04:00
|
|
|
/*
|
2008-02-11 22:56:26 +03:00
|
|
|
public static function autoloadModel($className)
|
|
|
|
{
|
|
|
|
$modelDir = dirname(__CLASS__) . '/../models/';
|
|
|
|
$fileName = $modelDir . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
|
|
|
|
if (file_exists($fileName)) {
|
|
|
|
require $fileName;
|
|
|
|
}
|
2008-06-15 19:56:28 +04:00
|
|
|
}*/
|
2008-02-10 22:08:31 +03:00
|
|
|
}
|