function query($sqlQuery) { //dbQuery($sql); try { //$dbh = $this->connection; //var_dump($this->_db); $argc = func_num_args(); $binds = func_get_args(); //$sth = false; // PDO SQL Preparation $sth = $this->_db->prepare($sqlQuery); if ($argc > 1) { array_shift($binds); for ($i = 0; $i < count($binds); $i++) { $sth->bindValue($binds[$i], $binds[++$i]); } } //var_dump($this->_db); $result = $sth->execute(); //$sth->closeCursor(); if ($sth->errorCode() > '0') { simpleInvoicesError('sql', $sth->errorInfo(), $sqlQuery); } } catch (Exception $e) { echo $e->getMessage(); echo "Dude, what happened to your query?:<br /><br /> " . htmlsafe($sqlQuery) . "<br />" . htmlsafe(end($this->_db->errorInfo())); $sth = NULL; } //$this->connection->closeCursor(); return $sth; #return $result; $sth->closeCursor(); $sth = NULL; }
function db_connector() { global $config; /* * strip the pdo_ section from the adapter */ $pdoAdapter = substr($config->resources->db->adapter, 4); if(!defined('PDO::MYSQL_ATTR_INIT_COMMAND') AND $pdoAdapter == "mysql" AND $config->resources->db->adapter->utf8 == true) { simpleInvoicesError("PDO::mysql_attr"); } try { switch ($pdoAdapter) { case "pgsql": $connlink = new PDO( $pdoAdapter.':host='.$config->resources->db->params->host.'; dbname='.$config->resources->db->params->dbname, $config->resources->db->params->username, $config->resources->db->params->password ); break; case "sqlite": $connlink = new PDO( $pdoAdapter.':host='.$config->resources->db->params->host.'; dbname='.$config->resources->db->params->dbname, $config->resources->db->params->username, $config->resources->db->params->password ); break; case "mysql": if ($config->resources->db->params->charset === 'utf8') { $connlink = new PDO( 'mysql:host='.$config->resources->db->params->host.'; port='.$config->resources->db->params->port.'; dbname='.$config->resources->db->params->dbname, $config->resources->db->params->username, $config->resources->db->params->password, array( PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8;") ); } else { $connlink = new PDO( $pdoAdapter.':host='.$config->resources->db->params->host.'; port='.$config->resources->db->params->port.'; dbname='.$config->resources->db->params->dbname, $config->resources->db->params->username, $config->resources->db->params->password ); } break; } } catch( PDOException $exception ) { simpleInvoicesError("dbConnection",$exception->getMessage()); die($exception->getMessage()); } return $connlink; }
*/ $backendOptions = array('cache_dir' => './tmp/'); // getting a Zend_Cache_Core object $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); //required for some servers Zend_Date::setOptions(array('cache' => $cache)); // Active aussi pour Zend_Locale /* * Zend Framework cache section - end */ $smarty = new Smarty(); $smarty->debugging = false; //cache directory. Have to be writeable (chmod 777) $smarty->compile_dir = "tmp/cache"; if (!is_writable($smarty->compile_dir)) { simpleInvoicesError("notWriteable", 'folder', $smarty->compile_dir); //exit("Simple Invoices Error : The folder <i>".$smarty -> compile_dir."</i> has to be writeable"); } //adds own smarty plugins $smarty->plugins_dir = array("plugins", "include/smarty_plugins"); //add stripslash smarty function $smarty->register_modifier("unescape", "stripslashes"); /* * Smarty inint - end */ $path = pathinfo($_SERVER['REQUEST_URI']); //SC: Install path handling will need changes if used in non-HTML contexts $install_path = htmlsafe($path['dirname']); include_once './config/define.php'; /* * Include another config file if required
if(!chmod(APPLICATION_PATH . '/tmp/cache', 0770)) { simpleInvoicesError('notWriteable','folder', APPLICATION_PATH . '/tmp/cache'); } } /* * Make sure the sessions folder exists */ if (isset($config->resources->session->save_path)) { if (!file_exists($config->resources->session->save_path)) { if (!mkdir($config->resources->session->save_path, 0770, true)) { simpleInvoicesError('notWriteable','folder', $config->resources->session->save_path); } } elseif(!is_writeable($config->resources->session->save_path)) { if(!chmod($config->resources->session->save_path, 0770)) { simpleInvoicesError('notWriteable','folder', $config->resources->session->save_path); } } } /** * Backward compatibility * * Gateway between Bootstrap and Init * Some global variables may be removed, however, to get a fast start * we just get them from the Zend_Registry and go along as up until now */ $config = Zend_Registry::get('config'); $auth_session = Zend_Registry::get('auth_session'); $logger = Zend_Registry::get('logger');
function checkConnection() { global $dbh; global $db_server; if (!$dbh) { simpleInvoicesError("dbConnection", $db_server, $dbh->errorInfo()); } }