If you look at the way symfony creates a custom task skeleton ( ./symfony generate:task yourTaskName), you will see the code that looks like inside the execution function:
protected function execute([..])
{
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
[..]
, , , ( database.yml schema.yml, ), , :
protected function configure()
{
$databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true));
$connection = $databaseManager->getDatabase("the_name_of_your_connection")->getConnection();
[..]
, :
$myItem = Doctrine_Core::getTable('item')->find(14);
echo $myItem->getId();