/** * init our class instance * * @return void */ function __construct() { if (!class_exists('\\Imagine\\Imagick\\Imagine')) { //include the imagine package require_once 'phar://' . VENDOR_PATH . '/imagine/imagine.phar'; } //check if the image magic extension is availble if (extension_loaded('imagick')) { $this->imagine = new \Imagine\Imagick\Imagine(); $this->is_imagick = true; } else { $this->imagine = new \Imagine\Gd\Imagine(); $this->is_gd = true; } //retrireve the image config $this->config = Config::settings('image'); }
/** * create our instance and fill in all the class wide variables * * @param class string The name of the model we want to deal with * * @return void */ function __construct($class = null) { if (!is_null(static::$db)) { return; } //pass our class if its present if (!is_null($class)) { $this->class = $class; //if we have a class, we should have a table too... if (property_exists($class, 'table')) { $this->table = $class::$table; } else { throw new MeagrException('No table property found'); } } //get our merged config $connect = Config::settings('database'); //try to connect try { static::$db = new \PDO("mysql:host=" . $connect['host'] . ";dbname=" . $connect['dbname'], $connect['username'], $connect['password']); static::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { // Log::add('Failed to connect to database: ' . $connect['host'] . ' ' . $e->getMessage(), __METHOD__, 'error'); } }