1
0
mirror of synced 2024-12-15 23:56:02 +03:00
doctrine2/website/plugins/sfDoctrinePlugin/lib/sfDoctrine.class.php
2007-09-12 21:56:14 +00:00

53 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* @package symfony.plugins
* @subpackage sfDoctrine
* @version SVN: $Id: sfDoctrine.class.php 4092 2007-05-23 17:37:26Z chtito $
*/
class sfDoctrine
{
// uses the default connection if none is given
static public function connection($connection = null)
{
if ($connection === null)
{
return Doctrine_Manager::getInstance()->getCurrentConnection();
}
return Doctrine_Manager::getInstance()->getConnection($connection);
}
// returns either the connection connectionName or uses the doctrine manager
// to find out the connection bound to the class (or the current one)
public static function connectionForClass($className, $connectionName = null)
{
if (isset($connectionName))
{
return Doctrine_Manager::getInstance()->getConnection($connectionName);
}
return Doctrine_Manager::getInstance()->getConnectionForComponent($className);
}
public static function getTable($className)
{
return Doctrine_Manager::getInstance()->getTable($className);
}
public static function queryFrom($className)
{
sfContext::getInstance()->getLogger()->err('The sfDoctrine::queryFrom() method is deprecated; use "Doctrine_Query::create()->from($className)" instead.');
return self::getTable($className)->createQuery();
}
}