public static function add_accounts($account) { // This is used in both Parts I and II // $piece1 = '('; $insertPiece .= ' (name, email) VALUES (?, ?)'; echo " \n "; // print_r($_POST); The post fields are available here possibly because the code files are all together echo " \n "; $insert[] = addslashes($account->get_name()); $insert[] = addslashes($account->get_email()); //$piece1 = implode( "',") //$insertPiece = $piece1 . $piece2; $dbh = DBConn::SingleDB(accountData::$NSLS_Database); $sql = " INSERT INTO account" . $insertPiece . ""; $sthselect = $dbh->PrepareSQL($sql); $dbh->ExecuteSQL($sthselect, $insert); $recordID = $dbh->LastInsertId(); if (!empty($recordID)) { $results = "ID: " . $recordID . PHP_EOL . "One record for accounts has been successfully inserted."; } else { $results = false; } // "could not insert account record"; return $results; }
function getCurrentVersion($fields) { $base_si_path = realpath(dirname(__FILE__) . '/../'); require_once $base_si_path . '/includes/DBConn.php'; // Check for version using db settings provided by user $DB_SERVER = ''; $DB_DATABASE = ''; $DB_USER = ''; $DB_PASSWORD = ''; if (file_exists($base_si_path . '/includes/global_config.php')) { if (include $base_si_path . '/includes/global_config.php') { if (defined('DB_SERVER') && defined('DB_USER') && defined('DB_PASSWORD') && defined('DB_DATABASE')) { $this->field_values['db_server'] = DB_SERVER; $this->field_values['db_user'] = DB_USER; $this->field_values['db_password'] = DB_PASSWORD; $this->field_values['db_database'] = DB_DATABASE; $DB_SERVER = DB_SERVER; $DB_DATABASE = DB_DATABASE; $DB_USER = DB_USER; $DB_PASSWORD = DB_PASSWORD; } } } if (empty($DB_SERVER) || empty($DB_DATABASE) || empty($DB_USER)) { for ($i = 0; $i < count($fields); $i++) { if ($fields[$i]->name == 'db_server') { $DB_SERVER = $fields[$i]->value; } if ($fields[$i]->name == 'db_database') { $DB_DATABASE = $fields[$i]->value; } if ($fields[$i]->name == 'db_user') { $DB_USER = $fields[$i]->value; } if ($fields[$i]->name == 'db_password') { $DB_PASSWORD = $fields[$i]->value; } } } $db_conn = new DBConn($DB_SERVER, $DB_DATABASE, $DB_USER, $DB_PASSWORD, TRUE); if ($db_conn->connect() == FALSE) { return FALSE; } return $this->_getVersionNumberFromDB($db_conn); }
public static function add_or_update_like($uid, $page) { $res = DBConn::get_rows(self::$_table, array(), array("uid=" . $uid, "page='" . $page . "'")); if (count($res) > 0) { DBConn::update_row(self::$_table, array("num_likes" => $res[0]['num_likes'] + 1), array("uid = " . $uid, "page='" . $page . "'")); } else { self::add_like($uid, $page); } }
public static function add_or_update_user($fb_id, $name) { $res = DBConn::get_rows(self::$_table, array(), array("fb_id=" . $fb_id)); if (count($res) > 0) { $datetime = new DateTime(); DBConn::update_row(self::$_table, array("last_logged_in" => date_format($datetime, 'Y-m-d H:i:s'), "logged_in" => TRUE), array("fb_id = " . $fb_id)); } else { self::add_user($fb_id, $name); } }
public function SQLConnect() { try { self::$SQLHandle = new PDO("mysql:host=" . $this->SQLHost . ";dbname=" . $this->DBName . "", $this->SQLUser, $this->SQLPassword, array(PDO::ATTR_PERSISTENT => true)); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); exit(1); } self::$SQLHandle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
public static function getInstance($newconn = false, $pconn = false) { if (!isset(self::$instance) || true == $newconn) { $className = __CLASS__; if (false != $pconn) { self::$instance = new $className(); } else { self::$instance = new $className(true); } } return self::$instance; }
public static function get_instance() { if (isset(self::$db_conn)) { return self::$db_conn; } else { require __DIR__ . '\\config.php'; global $hostname, $username, $password, $dbname; self::$db_conn = mysqli_connect($hostname, $username, $password); mysqli_select_db(self::$db_conn, $dbname); return self::$db_conn; } }
/** * Funcao construtor da conexao com o banco * @access static * @return a instancia da conexao */ public function __construct() { //cria a conexao se a instancia for nula if (is_null(self::$instance)) { try { self::$instance = parent::__construct('mysql:host=' . self::HOST . ';dbname=' . self::DB . ';charset=' . self::CHARSET, self::USER, self::PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . self::CHARSET)); parent::setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo "Connection Error: " . $e->getMessage(); exit; } } return self::$instance; }
public static function getFotosAlbum($album) { $stmt = DBConn::getInstance()->prepare("SELECT * FROM imagens WHERE id_album = {$album}"); $stmt->execute(); $lista = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $u = new CadastroAlbum(); foreach ($row as $k => $v) { $u->{$k} = $v; } $lista[] = $u; } return $lista; }
public static function getCategorias() { $stmt = DBConn::getInstance()->prepare("SELECT * FROM categoria"); $stmt->execute(); $lista = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $u = new CadastroCategoria(); foreach ($row as $k => $v) { $u->{$k} = $v; } $lista[] = $u; } return $lista; }
public static function getConnection() { if (self::$_db == null) { // No PDO exists yet, so make one and send it back. try { self::$_db = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWORD, array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); } catch (PDOException $e) { die('<h1>Sorry. The Database connection is temporarily unavailable.</h1>'); } return self::$_db; } else { return self::$_db; } }
public function selectDashBoardChartId($id) { $conn = parent::getConn(); $sql = "select id from chart where dashboard_id=:id "; try { $st = $conn->prepare($sql); $st->bindValue(":id", $id, PDO::PARAM_INT); $st->execute(); $row = $st->fetchAll(); return $row; } catch (PDOException $e) { echo "failure:" . $e->getMessage(); return false; } }
/** * 查询上周新增和未关闭BUG * LW lastweek */ public function execSql($ip, $port, $user, $pass, $sql) { $dsnStr = "mysql:host=" . $ip . ":" . $port . ";dbname=mysql"; $conn = parent::getConn($dsnStr, $user, $pass); try { $st = @$conn->prepare($sql); $st->execute(); $row = $st->fetchALL(); $conn = Null; } catch (PDOException $e) { echo "failure:" . $e->getMessage(); return false; } return $row; }
public function selectByDay($day) { $conn = parent::getConn(); $sql = "select id,name,path,ower,uploadtime,size,msg from picture WHERE DATE_SUB(CURDATE(), INTERVAL {$day} DAY)=DATE(uploadtime) "; try { $st = $conn->prepare($sql); $st->execute(); $row = $st->fetchAll(); $conn = Null; } catch (PDOException $e) { echo "failure:" . $e->getMessage(); return false; } return $row; }
/** * 根据panel的id来获取panel位置 */ public function selectPermissionDB($id) { $conn = parent::getConn(); $sql = "SELECT user_email,rule FROM permission WHERE user_email=:email"; try { $st = $conn->prepare($sql); $st->bindValue(":email", $id, PDO::PARAM_STR); $st->execute(); $row = $st->fetchAll(); } catch (PDOException $e) { echo "failure:" . $e->getMessage(); return false; } return $row; }
/** * 查询backlog信息 */ public function selectSprintBacklog($pvid) { $conn = parent::getConn(); $sql = "SELECT `id`, `pv_id`, `story_name`, `dev_need_hour`, `test_need_hour`, `priority`, `dev`, `qa`, `find_bugs`, `start_time`, `cc_time`, `tc_time`, `remark`, `create_time`FROM `sprint_backlog` WHERE pv_id = :pvid"; try { $st = $conn->prepare($sql); $st->bindValue(":pvid", $pvid, PDO::PARAM_STR); $st->execute(); $row = $st->fetchALL(); } catch (PDOException $e) { echo "selectSprintBacklog() failed:" . $e->getMessage(); return false; } return $row; }
function fetch_form_list($uid) { global $form_list; global $form_list_size; // permissions should be incorporated here $sql_str = "SELECT " . "tng_form.form_id, " . "tng_form.form_name " . "FROM " . "tng_form " . "INNER JOIN tng_process_form_permissions ON tng_form.form_id = tng_process_form_permissions.form_id " . "WHERE " . "tng_process_form_permissions.uid = " . $_SESSION['obj_login']->uid . " "; $dbconn = new DBConn(); $dbconn->connect(); $result = pg_query($dbconn->conn, $sql_str); if (!$result) { echo "An error occurred while executing the query " . pg_last_error($dbconn->conn); $dbconn->disconnect(); } else { // successfuly ran the query $form_list_size = pg_num_rows($result); // fill the array with the form ids and form names. // each element in the form_list array is an array // of two elements. for ($i = 0; $i < $form_list_size; $i++) { $form_list[$i] = array(pg_fetch_result($result, $i, 0), pg_fetch_result($result, $i, 1)); } } $dbconn->disconnect(); }
/** * Връща модел за текущия потребител * * Ако има $_SESSION['user_id'] се връща модел, * с това което е успял да зареди, в противен случай * се връща false * * @return mixed: User|boolean */ static function loadCurrentUser() { if (empty($_SESSION['user_id'])) { return false; } if ($_SESSION['user_serialized']) { $_SESSION['user'] = unserialize($_SESSION['user_serialized']); $_SESSION['user']->dbconn = DBConn::getInstance()->conn; } else { $model_user = new User(DBConn::getInstance()->conn, $_SESSION['user_id']); $model_user->fetch(); $_SESSION['user'] = $model_user; $_SESSION['user_serialized'] = serialize($model_user); } return $_SESSION['user']; }
public function hasUser($email) { $conn = parent::getConn(); $sql = "select email,username from showdb.user WHERE email=:email "; try { $st = $conn->prepare($sql); $st->bindValue(":email", $email, PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); $conn = Null; return $row; } catch (PDOException $e) { echo " error:" . $e->getMessage(); return false; } }
/** * 插入slider页面click事件 */ public function insertLog($data) { $event = $data['event']; $page = $data['page']; $description = $data['description']; $username = $data['username']; $ip = $data['ip']; $conn = parent::getConn(); $sql = "INSERT INTO sys_log (`event`,`page`,`description`,`username`,`ip`)" . "VALUES('{$event}','{$page}','{$description}','{$username}','{$ip}');"; try { $st = $conn->prepare($sql); $st->execute(); $conn = Null; } catch (PDOException $e) { echo "failure:" . $e->getMessage(); return false; } return true; }
function update_schedule_detail() { $schoolid = $_REQUEST['schoolid']; $hw_time = $_REQUEST['hw_time']; $att_time = $_REQUEST['att_time']; $slip_time = $_REQUEST['slip_time']; $non_scheduled_hw = $_REQUEST["non_scheduled_hw"]; $non_scheduled_att = $_REQUEST["non_scheduled_att"]; $teacher_hw_time = $_REQUEST["teacher_hw_time"]; $teacher_att_time = $_REQUEST["teacher_att_time"]; $send_sms_to_students = $_REQUEST["send_sms_to_students"]; $output['success'] = 0; $res = DBConn::queryFetchRowAssoc("SELECT att_time,hw_time,slip_time FROM tab_sms_schedule WHERE schoolid=" . $schoolid) ? 1 : 0; if (!$res) { $output['success'] = DBConn::exec("INSERT INTO tab_sms_schedule(SchoolId,att_time,hw_time,slip_time,non_scheduled_hw,non_scheduled_att,teacher_hw_time,teacher_att_time,send_sms_to_students) VALUES ({$schoolid},'{$att_time}','{$hw_time}','{$slip_time}','{$non_scheduled_hw}','{$non_scheduled_att}','{$teacher_hw_time}','{$teacher_att_time}','{$send_sms_to_students}')"); } else { $output['success'] = DBConn::exec("UPDATE tab_sms_schedule SET att_time='{$att_time}',hw_time='{$hw_time}',slip_time='{$slip_time}',non_scheduled_hw='{$non_scheduled_hw}',non_scheduled_att='{$non_scheduled_att}',teacher_att_time='{$teacher_att_time}',teacher_hw_time='{$teacher_hw_time}',send_sms_to_students='{$send_sms_to_students}' WHERE SchoolId={$schoolid}"); } echo json_encode($output); }
public function updateVersionInfo($data) { $conn = parent::getConn(); $sql = "UPDATE product_version_info Set version_name=:version_name,start_time=:start_time,cc_time=:cc_time, tc_time=:tc_time,oc_time=:oc_time, remark=:remark where id=:id "; try { $st = $conn->prepare($sql); $st->bindValue(":version_name", $data["version_name"], PDO::PARAM_STR); $st->bindValue(":start_time", $data["start_time"], PDO::PARAM_STR); $st->bindValue(":cc_time", $data["cc_time"], PDO::PARAM_STR); $st->bindValue(":tc_time", $data["tc_time"], PDO::PARAM_STR); $st->bindValue(":oc_time", $data["oc_time"], PDO::PARAM_STR); $st->bindValue(":id", $data["id"], PDO::PARAM_INT); $st->bindValue(":remark", $data["remark"], PDO::PARAM_STR); echo "<pre>"; print_r($data); $st->execute(); return true; } catch (PDOException $e) { // echo "failure:".$e->getMessage(); return false; } }
public function selectWeekTotalBug() { $conn = parent::getConn(DB_DSN_REDMINE); $sql = "CALL selectWeekTotalBug();"; //echo $sql; try { $st = $conn->prepare($sql); $st->execute(); $row = $st->fetchALL(); $conn = Null; } catch (PDOException $e) { echo "failure:" . $e->getMessage(); return false; } return $row[0][0]; }
public function selectAppQrsById($id) { $conn = parent::getConn(); $sql = "select app_name,app_path,create_time from qr where id=" . $id; try { $st = $conn->prepare($sql); $st->execute(); $row = $st->fetch(); return $row; } catch (PDOException $e) { echo "selectAppDirs():" . $e->getMessage(); return false; } }
if (!$outputlevel){ $outputlevel = "notice"; }elseif($outputlevel == "notice" || $outputlevel == "warning"){ //do nothing. }else{ die("Invalid outputlevel: \"" . $outputlevel . "\".\n"); } require_once("knj/dbconn/class_dbconn.php"); $dbconn1 = new DBConn(); if (!$dbconn1->openConn($db1[0], $db1[1], $db1[2], $db1[3], $db1[4], $db1[5])){ die("Could not make a connection to db1: \"" . $dbconn1->query_error() . "\".\n"); } $dbconn2 = new DBConn(); if (!$dbconn2->openConn($db2[0], $db2[1], $db2[2], $db2[3], $db2[4], $db2[5])){ die("Could not make a connection to db2: \"" . $dbconn2->query_error() . "\".\n"); } $tables1 = $dbconn1->getTables(); $tables2 = $dbconn2->getTables(); foreach($tables1 AS $table1){ if ($outputlevel == "notice"){ echo("Notice: Checking table \"" . $table1["name"] . "\".\n"); } //Check if the table exist in db2. $found = false; foreach($tables2 AS $testtable2){
<?php //~ ini_set('display_errors', 0); require_once "servicios.php"; require_once "configuration.php"; set_include_path(get_include_path() . PATH_SEPARATOR . $cscwebPath_g); require_once "dbconn.php"; $dbconn_g = new DBConn($dbConfig_g); $dbconn_g->connect(); $link_g = $dbconn_g->getConnection(); $myws = new Servicios(); $idwsname = isset($_GET['wsname']) ? $_GET['wsname'] : NULL; if (isset($_GET['wsname'])) { $idwsname = $_GET['wsname']; $record = $_GET; } else { if (isset($_POST['wsname'])) { $idwsname = $_POST['wsname']; $record = $_POST; } else { $xml = '<?xml version="1.0"?>'; $xml .= '<result>'; $xml .= '<response>KO</response>'; $xml .= '<description>No existe servicio</description>'; $xml .= '</result>'; } } if ($idwsname != NULL) { $record = isset($_GET['wsname']) ? $_GET : $_POST; if (method_exists($myws, $idwsname)) { $xml = $myws->{$idwsname}($record);
it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************************/ $locs = array(); $list = '<script type="text/javascript">!window.jQuery && document.write(\'<script src="jquery/jquery-1.4.3.min.js"><\\/script>\');'; $dbconn = new DBConn(); $res = $dbconn->query("SELECT pid, name FROM place", array()); if ($res) { while (($row = $resultset->fetch()) != false) { $locs[] = "{$row[1]} ({$row[0]})"; } $list .= '<!-- $(function () { $(\'#f, #t\').tagSuggest({ tags: ["' . implode('","', $locs) . '"] }); }); //-->'; } $list .= '</script>'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Bus Route Finder</title> <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" /> <link href="img/bus.ico" rel="icon" type="image/vnd.microsoft.icon"/>
} $invoices[$row['invoice']]['ids'][] = $ta->id; $checks[$row['check']]['user_id'] = $row['user_id']; $checks[$row['check']]['ids'][] = $ta->cost_trans_id; if ($ta->end_ts > $checks[$row['check']]['timestamp']) { $checks[$row['check']]['timestamp'] = $ta->end_ts; } $checks[$row['check']]['amount'] += $ta->cost; } $task_activity_result->free(); debug('Added task activities to sureinvoice!'); } $si_db = new DBConn(DB_SERVER, DB_DATABASE, DB_USER, DB_PASSWORD); assert_die($si_db->connect(TRUE), "Could not connect to sureinvoice database!\n" . $si_db->getLastError()); debug('Connected to sureinvoice database ' . DB_DATABASE); $dt_db = new DBConn($phpdt_server, $phpdt_database, $phpdt_username, $phpdt_password); assert_die($dt_db->connect(TRUE), "Could not connect to phpdt database!\n" . $dt_db->getLastError()); debug('Connected to phpdt database ' . $phpdt_database); // Migrate companies $companies = array(); $company_rates = array(); $company_sql = "\nSELECT `id`, `name`, `address1`, `address2`, `city`, `state`,\n`zip`, `phone`, `fax`, `hourly_rate`, `created_ts`, `updated_ts`\nFROM `companies`\n"; $company_result = $dt_db->query($company_sql, TRUE); assert_die($company_result, "Could not get company list!\n" . $dt_db->getLastError()); debug('Got ' . $company_result->numRows() . ' company rows from phpdt.'); while ($row = $company_result->fetchArray(MYSQL_ASSOC)) { $company_insert_sql = "\nINSERT INTO companies (id, name, address1, address2, city,\nstate, zip, phone, fax, hourly_rate,created_ts, updated_ts)\nVALUES(" . $row['id'] . ", '" . $si_db->escapeString($row['name']) . "', '" . $row['address1'] . "', \n'" . $row['address2'] . "', '" . $row['city'] . "', '" . $row['state'] . "', \n'" . $row['zip'] . "', '" . $row['phone'] . "', '" . $row['fax'] . "', \n" . $row['hourly_rate'] . ", " . $row['created_ts'] . ", " . $row['updated_ts'] . ")\n\t"; assert_die($si_db->query($company_insert_sql, TRUE), "Error adding company!\n" . $si_db->getLastError(), FALSE); debug('Added ' . $row['name'] . ' to sureinvoice'); $company_rates[$row['id']] = $row['hourly_rate']; $companies[$row['id']] = $row;
<?php require_once 'dbCon.php'; header("content-type: application/json"); $db = new DBConn(); $name = $_POST['name_']; $pass = $_POST['pass_']; $db->loGin($name, $pass);
define('WEB_ROOT', $wr); // Installer checks $include_path = realpath(dirname(__FILE__)); if (!file_exists($include_path . '/global_config.php') || filesize($include_path . '/global_config.php') < 10) { if (file_exists(realpath(dirname(__FILE__) . '/../installer') . '/index.php')) { $url = WEB_ROOT . 'installer/'; header("Location: " . $url . "\r\n"); exit; } else { print "No configuration file found: " . $include_path . '/global_config.php' . "<BR>\n"; exit; } } require_once 'DBConn.php'; require_once 'global_config.php'; $db_conn = new DBConn(DB_SERVER, DB_DATABASE, DB_USER, DB_PASSWORD, TRUE); if ($db_conn->connect() == FALSE) { trigger_error("Could not connect to database!\n" . $db_conn->getLastError(), E_USER_ERROR); } $GLOBALS['CONFIG'] = SI_Config::getAppConfig(); require_once 'html.php'; require_once 'SI_User.php'; require_once 'SI_Config.php'; require_once 'SI_TimeImport.php'; require_once 'version.php'; require_once 'SureInvoice.php'; session_start(); ob_start(); // Error handling functions function site_error_handler($errno, $errstr, $errfile, $errline) {