/** * execution of a prepared statement. * * @param string $sql the sql query * @param mixed[] $inputs the variables of the prepared statement * @return mixed[] $dataquery array containing the newle created dataset. */ public function execute($sql, $inputs = array()) { $db = madr_mvc_model_db_singleton::instance(); $query = $db->prepare($sql); $query->setFetchMode(PDO::FETCH_NAMED); count($inputs) == 0 ? $query->execute() : $query->execute($inputs); return $query->fetchAll(); }
public static function instance() { if (!isset(self::$instance)) { self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_DATABASE, DB_UID, DB_PW); self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); self::$instance->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, 1); } return self::$instance; }
/** * the initiation of the application * * @author Anders Ytterström <*****@*****.**> * @name init.php * @since 2006-07-29 * @version 1.0 * @package library */ // Includes require '../application/constants.php'; define('SECURE_ACTION_PATH', 'https://' . ROOT_PATH . 'application/controllers/'); define('ACTION_PATH', ROOT_PATH . 'application/controllers/'); define('VIEW_PATH', ROOT_PATH . 'application/views'); define('MODEL_PATH', ROOT_PATH . 'application/models/'); define('PLUGIN_PATH', ROOT_PATH . 'application/plugins/'); define('CACHE_PATH', ROOT_PATH . 'cache/'); define('CLASS_PATH', ROOT_PATH . 'madr/classes'); define('FCT_PATH', ROOT_PATH . 'madr/functions/'); require FCT_PATH . 'common.php'; require FCT_PATH . 'handlers.php'; // Basic configuration set_time_limit(15); setlocale(LC_ALL, 'sv_SE'); date_default_timezone_set('Europe/Stockholm'); error_reporting(SHOW_DEBUGGING_INFO ? E_ALL | E_STRICT : 0); // database connection $db = madr_mvc_model_db_singleton::instance(); // Initiate the session @session_start();
/** * execution of a prepared statement. * * @param string $sql the sql query * @param mixed[] $inputs the variables of the prepared statement * @return mixed[] $dataquery array containing the newle created dataset. */ public function execute($sql, $inputs = array()) { $db = madr_mvc_model_db_singleton::instance(); }
/** * execute sql-query * * @param string $sql the prepared sql-query * @param mixed[] $inputs the inputs for the array */ protected function execute($sql, $inputs = array()) { $db = madr_mvc_model_db_singleton::instance(); $query = $db->prepare($sql); count($inputs) == 0 ? $query->execute() : $query->execute($inputs); }