define('SF_ROOT_DIR', realpath(dirname(__file__).'/..'));define('SF_APP', 'AbaWebTreuhand');define('SF_ENVIRONMENT', 'dev');define('SF_DEBUG', 1);require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');$databaseManager = new sfDatabaseManager();$databaseManager->initialize();Doctrine_Manager::connection()->beginTransaction();$query = new Doctrine_Query();$query->from('Subscription s LEFT JOIN s.Subscriber sb ' . 'LEFT JOIN sb.Installation i');$where_part = 's.is_active = ?';$where_args = array('1');// it accepts a month as a parameter (optional default is the previous month)$month = isset($argv[1]) ? $argv[1] : date('Y-m-01');// only those subscriptions are relevant according to the validuntil date columns$where_part.= ' AND (s.validuntil IS NULL OR s.validuntil > ?)';array_push($where_args, $month);// all subscriptions in their first month will be ignored for billing purposes$where_part.= ' AND s.validfrom < ?';array_push($where_args, $month);$result = $query->execute();foreach ($result as $subscription) { var_dump($subscription->getId());}Doctrine_Manager::connection()->rollback();