public function test_query() { $limit = 5; $rows = Generic::query("SELECT * FROM `scoop`.`test` LIMIT ?", [$limit]); $this->assertEquals($limit, $rows->get_num_rows()); $dbConfig = \Scoop\Config::get_db_config(); $dbConfig['database'] = 'scoop'; $connection = new \Scoop\Database\Connection($dbConfig); $rows = Generic::query("SELECT * FROM test LIMIT ?", [$limit], $connection); $this->assertEquals($limit, $rows->get_num_rows()); }
public function __construct() { $this->cache = new Statement(500); $dbConfig = \Scoop\Config::get_db_config(); $this->cache->put(0, new mysqli_stmt(new mysqli($dbConfig['host'], $dbConfig['user'], $dbConfig['password'], '', $dbConfig['port']), '')); }
public function test_set_options() { $options = ['dummy1' => 'value1', 'dummy2' => 'value2', 'dummy3' => 'value3']; Config::set_options($options); $this->assertEquals('value1', Config::get_option('dummy1')); $this->assertEquals('value2', Config::get_option('dummy2')); $this->assertEquals('value3', Config::get_option('dummy3')); }
$run = new Whoops\Run(); $handler = new Whoops\Handler\PrettyPageHandler(); // Set the title of the error page: $handler->setPageTitle("Whoops! There was a problem."); $run->pushHandler($handler); // Add a special handler to deal with AJAX requests with an // equally-informative JSON response. Since this handler is // first in the stack, it will be executed before the error // page handler, and will have a chance to decide if anything // needs to be done. if (Whoops\Util\Misc::isAjaxRequest()) { $run->pushHandler(new Whoops\Handler\JsonResponseHandler()); } // Register the handler with PHP, and you're set! $run->register(); } /************** * Scoop **************/ // load all classpaths that exist foreach (\Scoop\Config::get_class_paths() as $classPath) { if ($classPath = realpath($classPath)) { set_include_path(get_include_path() . PATH_SEPARATOR . $classPath . '/'); } } /** * 'spl_autoload' | use built-in psr-0 spl_autoload() * true | error thrown if 'spl_autoload' not found * true | prepend this autoloader to the beginning of the autoload queue */ spl_autoload_register('spl_autoload', true, true);
public static function connect() { if (is_null(self::$connection)) { self::$connection = new Connection(Config::get_db_config()); } }
public function test___destruct() { $connection = new Connection(\Scoop\Config::get_db_config()); unset($connection); }
if (isset($siteName)) { \Scoop\Config::set_option('site_name', $siteName); } // load config $frameworkConfig = (include \Scoop\Config::get_option('config_dir') . '/framework.php'); // load user config file if one exists foreach ([__DIR__ . '/../../scoop/custom.php', __DIR__ . '/../../../../scoop/custom.php'] as $customConfigFilePath) { if (file_exists($customConfigFilePath)) { $customConfig = (include_once $customConfigFilePath); if (is_array($customConfig)) { $frameworkConfig = array_replace_recursive($frameworkConfig, $customConfig); } } } // set main options \Scoop\Config::set_options($frameworkConfig); // set the timezone if one was provided if (\Scoop\Config::option_exists('timezone')) { date_default_timezone_set(\Scoop\Config::get_option('timezone')); } // the autoloader require_once \Scoop\Config::get_option('bootstrap_dir') . '/autoloader.php'; $clientIP = array_key_exists('REMOTE_ADDR', $_SERVER) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0'; $serverIP = array_key_exists('SERVER_ADDR', $_SERVER) ? $_SERVER['SERVER_ADDR'] : '0.0.0.0'; if (\Scoop\Environment::is_internal_ip($clientIP, $serverIP)) { ini_set('display_errors', 'On'); ini_set('display_startup_errors', 'On'); } else { ini_set('display_errors', 'Off'); ini_set('display_startup_errors', 'Off'); }