public static function &connection() { if (!static::$_connection) { static::$_connection = new MockDocumentSource(); } return static::$_connection; }
public static function _init() { \Config::load('debtsolv', 'debtsolv'); static::$_debtsolv_database = \Config::get('debtsolv.debtsolv_database', static::$_debtsolv_database); static::$_leadpool_database = \Config::get('debtsolv.leadpool_database', static::$_leadpool_database); static::$_connection = \Database_Connection::instance('Debtsolv', \Config::get('debtsolv.connection', static::$_connection)); }
/** * Named connection getter/setter */ public static function connection($connection = null) { if (null !== $connection) { static::$_connection = $connection; return $this; } return static::$_connection; }
/** * init the class */ public static function _init() { // auth config \Config::load('ormauth', true); // set the connection this model should use static::$_connection = \Config::get('ormauth.db_connection'); // set the models table name static::$_table_name = \Config::get('ormauth.table_name', 'users') . '_user_permissions'; }
/** * init the class */ public static function _init() { // auth config \Config::load('ormauth', true); // set the connection this model should use static::$_connection = \Config::get('ormauth.db_connection'); // set the write connection this model should use static::$_write_connection = \Config::get('ormauth.db_write_connection') ?: static::$_connection; // set the models table name static::$_table_name = \Config::get('ormauth.table_name', 'users') . '_providers'; }
public static function forge($companyID = 0, $clientID = 0) { // -- Set the database name // ------------------------ $Database = Database::connect((int) $companyID); static::$databaseName = $Database->debtsolvDBName(); static::$_connection = $Database->connection(); // -- Set the Client ID // -------------------- static::$clientID = (int) $clientID; static::$_companyID = (int) $companyID; }
/** * init the class */ public static function _init() { // auth config \Config::load('ormauth', true); // set the connection this model should use static::$_connection = \Config::get('ormauth.db_connection'); // set the models table name static::$_table_name = \Config::get('ormauth.table_name', 'users') . '_groups'; // set the relations through table names static::$_many_many['roles']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_group_roles'; static::$_many_many['permissions']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_group_permissions'; // model language file \Lang::load('auth_model_group', true); }
public function connect() { try { static::$_oauth = new OAuth(static::$_defaults['consumer_key'], static::$_defaults['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); static::$_oauth->enableDebug(); static::$_oauth->enableSSLChecks(); static::$_oauth->setToken(static::$_defaults['token'], static::$_defaults['token_secret']); //make a simple request to trythe connection static::$_oauth->fetch(static::$_defaults['info_info_api_url']); static::$_connection = true; } catch (OAuthException $E) { static::setErrot($E->lastResponse, $E->getCode()); static::$_connection = false; } return static::$_connection; }
/** * Fetch the database connection name to use * * @param bool if true return the writeable connection (if set) * @return null|string */ public static function connection($writeable = false) { // if in tracsaction, conection force to be writable. if (\DB::in_transaction()) { $writeable = true; } if ($writeable) { if (empty(static::$_write_connection)) { static::$_write_connection = static::get_write_connection_default(); } return static::$_write_connection; } if (empty(static::$_connection)) { static::$_connection = static::get_read_connection_default(); } return static::$_connection; }
/** * Static constructor called by autoloader */ public static function _init() { $config = \Config::load('tinychimp'); if (empty($config['api_key'])) { throw new \FuelException('API key not specified.'); } static::$api_key = $config['api_key']; static::$secure_connection = is_bool($config['secure']) ? $config['secure'] : false; static::$timeout = is_integer($config['timeout']) ? $config['timeout'] : 300; static::$api_url = empty($config['api_url']) ? static::get_api_url() : $config['api_url']; $connection = curl_init(); curl_setopt_array($connection, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => static::$timeout, CURLOPT_POST => true)); if (static::$secure_connection) { curl_setopt_array($connection, array(CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => true, CURLOPT_PORT => 443)); } static::$_connection = $connection; }
/** * init the class */ public static function _init() { // auth config \Config::load('ormauth', true); // set the connection this model should use static::$_connection = \Config::get('ormauth.db_connection'); // set the write connection this model should use static::$_connection = \Config::get('ormauth.db_write_connection'); // set the models table name static::$_table_name = \Config::get('ormauth.table_name', 'users') . '_roles'; // set the relations through table names static::$_many_many['users']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_roles'; static::$_many_many['groups']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_group_roles'; static::$_many_many['permissions']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_role_permissions'; // model language file \Lang::load('auth_model_role', true); // set the filter options from the language file static::$_properties['filter']['form']['options'] = \Lang::get('auth_model_role.permissions'); }
/** * Get the database name * * @author David stansfield */ public static function setDatabaseConnection() { $Database = Database::connect(static::$_userCentreID); static::$_connection = $Database->connection(); static::$_debtsolvDatabase = $Database->debtsolvDBName(); }
/** * @param string $connectionString * @param string $userName * @param string $password * @param array $pdoOptions * * @return void|\PDO */ public static function setConnectionString($connectionString, $userName = null, $password = null, array $pdoOptions = []) { static::setConnection(null); // If you set a connection string a new connection one is created for you if (!empty($connectionString)) { static::$_connectionString = $connectionString; static::$_connection = new \PDO(static::$_connectionString, $userName, $password, array_merge([\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION], $pdoOptions)); } return static::$_connection; }
/** * Sets the write connection to use for this model. * @param string $connection */ public static function set_connection($connection) { static::$_connection = $connection; }
/** * Gets/sets the connection object to which this model is bound. * * @param object $connection The connection instance to set or `null` to get the current one. * @return mixed Returns a connection instance on get. */ public static function connection($connection = null) { if (func_num_args()) { static::$_connection = $connection; unset(static::$_definitions[static::class]); return; } return static::$_connection; }
/** * init the class */ public static function _init() { // auth config \Config::load('auth', true); // get the auth driver in use $drivers = normalize_driver_types(); // modify the model definition based on the driver used if (in_array('Simpleauth', $drivers)) { // remove properties not in use unset(static::$_properties['group_id']); unset(static::$_properties['previous_login']); unset(static::$_properties['user_id']); // remove relations static::$_eav = array(); static::$_belongs_to = array(); static::$_has_many = array(); static::$_many_many = array(); // remove observers unset(static::$_observers['Orm\\Observer_Self']); // simpleauth config \Config::load('simpleauth', true); // set the connection this model should use static::$_connection = \Config::get('simpleauth.db_connection'); // set the write connection this model should use static::$_write_connection = \Config::get('simpleauth.db_write_connection') ?: static::$_connection; // set the models table name static::$_table_name = \Config::get('simpleauth.table_name', 'users'); } elseif (in_array('Ormauth', $drivers)) { // remove properties not in use unset(static::$_properties['group']); unset(static::$_properties['profile_fields']); // ormauth config \Config::load('ormauth', true); // set the connection this model should use static::$_connection = \Config::get('ormauth.db_connection'); // set the write connection this model should use static::$_write_connection = \Config::get('ormauth.db_write_connection') ?: static::$_connection; // set the models table name static::$_table_name = \Config::get('ormauth.table_name', 'users'); // set the relations through table names static::$_many_many['roles']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_roles'; static::$_many_many['permissions']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_permissions'; } // model language file \Lang::load('auth_model_user', true); }
public static function use_master_and_slave() { static::$_write_connection = 'master'; static::$_connection = 'slave'; }