public static function create(Atomik_Db_Instance $instance = null) { if ($instance === null) { $instance = Atomik_Db::getInstance(); } return new self($instance); }
/** * Sets the default manager * * @param Atomik_Model_Manager $db */ public static function setDefault(Atomik_Model_Manager $manager = null) { if ($manager === null) { $manager = new self(Atomik_Db::getInstance()); } self::$_default = $manager; }
/** * Sets the instance * * @param Atomik_Db_Instance|string $instance An instance name or an Atomik_Db_Instance object */ public static function setInstance($instance = null) { if (is_string($instance)) { if (isset(self::$_availableInstances[$instance])) { $instance = self::$_availableInstances[$instance]; } else { require_once 'Atomik/Db/Exception.php'; throw new Atomik_Db_Exception('The instance named ' . $instance . ' does not exist'); } } else if ($instance === null) { $instance = new Atomik_Db_Instance(); if (count(self::$_availableInstances) == 0) { self::$_availableInstances['default'] = $instance; } } self::$_instance = $instance; }
/** * Executes sql scripts for models and the ones located in the sql folder. * Will look in the app folder as well as in each plugin folder. * * @param string $instance * @param array $filter * @param bool $echo Whether to echo or return the output from the script execution * @return string */ public static function dbCreate($instance = 'default', $filter = array(), $echo = false) { $script = self::getDbScript($filter, $echo); Atomik::fireEvent('Db::Create::Before', array(&$instance, $script)); $script->run(Atomik_Db::getInstance($instance)); Atomik::fireEvent('Db::Create::After', array($instance, $script)); return $script->getOutputHandler()->getText(); }