/** * Insert values into SQL string and calls * execute on Node Driver * * @param type $params * @return boolean|Array|string */ public function execute($params = null) { if ($this->_hasExecuted) { return; } if (empty($this->_sql)) { return; } $this->_hasExecuted = true; $sql = $this->_sql; foreach ($this->_values as $item) { $column = $item[0]; $value = $item[1]; if (is_numeric($column)) { $sql = preg_replace('/\\?/', $value, $sql, 1); } } foreach (array_reverse($this->_values) as $item) { $column = $item[0]; $value = $item[1]; if (!is_numeric($column)) { $sql = preg_replace('/\\:' . $column . '/', $value, $sql); } } try { $response = $this->_driver->execute($sql); $this->_fetch_results = $this->_results = $response; return $response; } catch (Exception $e) { Cake\Log\Log::error($e); return false; } }
mkdir(APP, 0770, true); } define('TMP', ROOT . DS . 'tmp' . DS); if (!is_dir(TMP)) { mkdir(TMP, 0770, true); } define('CONFIG', ROOT . DS . 'config' . DS); define('LOGS', TMP . 'logs' . DS); define('CACHE', TMP . 'cache' . DS); define('CAKE_CORE_INCLUDE_PATH', ROOT . '/vendor/cakephp/cakephp'); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); define('CAKE', CORE_PATH . APP_DIR . DS); require dirname(__DIR__) . '/vendor/autoload.php'; require CORE_PATH . 'config/bootstrap.php'; Cake\Core\Configure::write('App', ['namespace' => 'TestApp', 'paths' => ['templates' => [ROOT . DS . 'tests' . DS . 'test_app' . DS . 'src' . DS . 'Template' . DS]]]); Cake\Core\Configure::write('debug', true); $cache = ['default' => ['engine' => 'File'], '_cake_core_' => ['className' => 'File', 'prefix' => 'crud_myapp_cake_core_', 'path' => CACHE . 'persistent/', 'serialize' => true, 'duration' => '+10 seconds'], '_cake_model_' => ['className' => 'File', 'prefix' => 'crud_my_app_cake_model_', 'path' => CACHE . 'models/', 'serialize' => 'File', 'duration' => '+10 seconds']]; $config = ['Log' => ['debug' => ['className' => 'DatabaseLog.Database'], 'error' => ['className' => 'DatabaseLog.Database']]]; Cake\Log\Log::config($config['Log']); Cake\Cache\Cache::config($cache); Cake\Core\Plugin::load('DatabaseLog', ['path' => ROOT . DS, 'autoload' => true, 'bootstrap' => false, 'routes' => true]); DispatcherFactory::add('Routing'); DispatcherFactory::add('ControllerFactory'); class_alias(AppController::class, 'App\\Controller\\AppController'); // Ensure default test connection is defined if (!getenv('db_class')) { putenv('db_class=Cake\\Database\\Driver\\Sqlite'); putenv('db_dsn=sqlite::memory:'); } Cake\Datasource\ConnectionManager::config('test', ['className' => 'Cake\\Database\\Connection', 'driver' => getenv('db_class'), 'dsn' => getenv('db_dsn'), 'database' => getenv('db_database'), 'username' => getenv('db_username'), 'password' => getenv('db_password'), 'timezone' => 'UTC', 'quoteIdentifiers' => true, 'cacheMetadata' => true]); Cake\Datasource\ConnectionManager::config('test_database_log', ['className' => 'Cake\\Database\\Connection', 'driver' => getenv('db_class'), 'dsn' => getenv('db_dsn'), 'database' => getenv('db_database'), 'username' => getenv('db_username'), 'password' => getenv('db_password'), 'timezone' => 'UTC', 'quoteIdentifiers' => true, 'cacheMetadata' => true]);