本文整理汇总了PHP中get_db_connection函数的典型用法代码示例。如果您正苦于以下问题:PHP get_db_connection函数的具体用法?PHP get_db_connection怎么用?PHP get_db_connection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_db_connection函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: set_active_state
function set_active_state($vermutung_id, $new_state)
{
$connection = get_db_connection();
$update_query = sprintf("UPDATE vermutung SET active = '%s' WHERE id = '%s'", mysql_real_escape_string($new_state), mysql_real_escape_string($vermutung_id));
$result = mysql_query($update_query);
mysql_close($connection);
return $result;
}
开发者ID:paedubucher,项目名称:paedubucher.ch,代码行数:8,代码来源:db_access.php
示例2: exec_query
function exec_query($sql)
{
static $conn = null;
if ($conn == null) {
$conn = get_db_connection();
}
if (mysql_query($sql, $conn) === FALSE) {
error_out(500, "MySQL Error: " . mysql_error($conn) . "; running query: {$sql}");
}
}
开发者ID:nysenate,项目名称:SendgridStatsAccumulator,代码行数:10,代码来源:fix_event_ids.php
示例3: users_getById
function users_getById($id)
{
$db = get_db_connection();
$tmp = $db->query("SELECT * from users WHERE id = {$id}");
if ($tmp->num_rows != 0) {
$user = $tmp->fetch_assoc();
} else {
$user = false;
}
return $user;
}
开发者ID:Fznamznon,项目名称:myPhotoGallery,代码行数:11,代码来源:users.php
示例4: list_all_hackers
function list_all_hackers()
{
$db = get_db_connection();
$hackers = $db->select('parameter_tampering', '*');
$output = "<pre><table>";
foreach ($hackers as $hacker) {
$output .= "<tr><td>" . $hacker["id"] . ". " . $hacker["name"] . " booked " . $hacker["number_of_tickets"] . " and paid " . $hacker["amount"] . "\$ . (Email: " . $hacker["email"] . " ) </td></tr>";
}
$output .= "</table></pre>";
return $output;
}
开发者ID:Braunson,项目名称:web-attacks,代码行数:11,代码来源:ticket_booking.php
示例5: photos_getByUser
function photos_getByUser($id)
{
$db = get_db_connection();
$tmp = $db->query("SELECT * FROM photo WHERE user_id = {$id}");
if ($tmp->num_rows != 0) {
while ($row = $tmp->fetch_assoc()) {
$photo[] = $row;
}
} else {
$photo = [];
}
return $photo;
}
开发者ID:Fznamznon,项目名称:myPhotoGallery,代码行数:13,代码来源:photo.php
示例6: albums_getById
function albums_getById($id)
{
$db = get_db_connection();
if (is_null($id)) {
return false;
}
$tmp = $db->query("SELECT * FROM albums WHERE id = {$id}");
if ($tmp->num_rows != 0) {
$a = $tmp->fetch_assoc();
} else {
$a = false;
}
return $a;
}
开发者ID:Fznamznon,项目名称:myPhotoGallery,代码行数:14,代码来源:albums.php
示例7: getProjectsByTech
function getProjectsByTech($techID)
{
try {
$db = get_db_connection();
$stmt = $db->prepare("SELECT projects.* FROM projects\n JOIN site_techs ON projects.project_id = site_techs.project_id\n JOIN techniques ON site_techs.tech_id = techniques.tech_id\n WHERE techniques.tech_id = ?;");
$stmt->bindParam(1, $techID, PDO::PARAM_INT);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$this->name[] = $row['name'];
$this->url[] = $row['url'];
$this->github[] = $row['github'];
$this->projectID[] = $row['project_id'];
$this->imagePath[] = $row['image_url'];
}
} catch (Exception $e) {
echo "Fehler beim Verbinden zur Datenbank";
}
}
开发者ID:sewede,项目名称:wetzel.work,代码行数:18,代码来源:class.projects.php
示例8: save
/**
* Will attempt to save the current record
* An INSERT will be performed if the primary key for $this is not already populated
* An UPDATE will be performed otherwise
* Various options will be available within the function --> still under construction(sanitize,quote,includeEmpties,includeNulls)
* @param string/array $listOfFields --> determines which fields are to be saved (single fieldname string or indexed array of fieldnames)
* @return bool
*/
public function save($listOfFields = "*")
{
//If user passes *, then we'll attempt to save all columns (except for the primary key) to the database
if ($listOfFields == '*') {
$listOfFields = $this->allFieldsWithoutKeys;
} elseif (!is_array($listOfFields)) {
$listOfFields = array((string) $listOfFields);
}
$db = get_db_connection();
//Create an assoc array of all the values we're about to save
$nameValuePairs = $this->GetFieldsAsAssocArray($listOfFields);
$field_values = array_values($nameValuePairs);
$field_names = array_keys($nameValuePairs);
array_unshift($field_values, $this->GetBoundParamTypeString($field_names));
if (empty($this->test_pk)) {
//INSERT new record when this class's primary key property is empty
$sql = 'INSERT INTO `test`' . ' (`' . implode('`, `', $field_names) . '`)' . ' VALUES (' . str_repeat('?,', count($field_names) - 1) . '?) ';
$rs = $db->query($sql, null, null, $field_values);
if ($rs) {
$this->test_pk = $db->insertID();
return true;
} else {
return false;
}
} else {
//UPDATE existing record based on this class's primary key
$field_values[0] = $field_values[0] . $this->GetBoundParamTypeString(array('test_pk'));
$sql = 'UPDATE `test` SET ' . '`' . implode('`=?, `', $field_names) . '`=? ' . ' WHERE `test_pk` = ?';
$field_values[] = $this->test_pk;
$rs = $db->query($sql, null, null, $field_values);
if ($rs) {
$this->test_pk = $db->insertID();
return true;
} else {
return false;
}
}
}
开发者ID:Blue-Kachina,项目名称:Helping-Developers-With-Class,代码行数:46,代码来源:deleteme.php
示例9: get_db_connection
function &default_context($make_session)
{
/*
Argument is a boolean value that tells the function whether to make a
session or not.
*/
$db =& get_db_connection();
/* change character set to utf8 */
$db->query("SET NAMES utf8mb4");
//$db->query("SET CHARACTER SET 'utf8'");
$user = null;
$type = get_preferred_type($_GET['type'] ? $_GET['type'] : $_SERVER['HTTP_ACCEPT']);
if ($type == 'text/html' && $make_session) {
// get the session user if there is one
session_set_cookie_params(86400 * 31, get_base_dir(), null, false, true);
session_start();
$user = cookied_user($db);
}
// Smarty is created last because it needs $_SESSION populated
$sm =& get_smarty_instance($user);
$ctx = new Context($db, $sm, $user, $type);
return $ctx;
}
开发者ID:ndpgroup,项目名称:fp-legacy,代码行数:23,代码来源:lib.everything.php
示例10: get_db_connection
<?php
require_once '../admin/config.php';
function get_db_connection()
{
$db = new pdo(DB_DRIVER . ":dbname=" . DB_NAME . ";charset=utf8;host=" . DB_HOST, DB_USER, DB_PASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $db;
}
function __autoload($class)
{
require '../classes/class.' . $class . '.php';
}
$techID = $_POST['techID'];
try {
$db = get_db_connection();
$stmt = $db->prepare("SELECT projects.* FROM projects\n JOIN site_techs ON projects.project_id = site_techs.project_id\n JOIN techniques ON site_techs.tech_id = techniques.tech_id\n WHERE techniques.tech_id = ?;");
$stmt->bindParam(1, $techID, PDO::PARAM_INT);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$name[] = $row['name'];
$url[] = $row['url'];
$github[] = $row['github'];
$projectID[] = $row['project_id'];
$imagePath[] = $row['image_url'];
}
} catch (Exception $e) {
echo "Fehler beim Verbinden zur Datenbank";
}
$countTechs = count($name);
echo "Anzahl: {$countTechs}<br>";
开发者ID:sewede,项目名称:wetzel.work,代码行数:31,代码来源:getTechs.php
示例11: ini_set
<?php
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '../lib');
require_once 'init.php';
require_once 'data.php';
require_once 'output.php';
list($response_format, $response_mime_type) = parse_format($_GET['format'], 'html');
$dbh =& get_db_connection();
if (get_request_user()) {
// auth stuff here
}
$dbh = null;
$sm = get_smarty_instance();
if (get_request_user()) {
// secure template vars here
}
header("Content-Type: {$response_mime_type}; charset=UTF-8");
print $sm->fetch("index.{$response_format}.tpl");
开发者ID:quilime,项目名称:mus,代码行数:18,代码来源:default.php
示例12: urlencode
// already URL encoded
$location = $_POST['location'];
// user friendly display name of user location
if ($location != "") {
$location = urlencode($location);
$place_name = urldecode($location);
// geocode
try {
$location_XML = yahoo_geo($_REQUEST['location']);
$location = $location_XML['Latitude'] . "," . $location_XML['Longitude'];
$location_latitude = $location_XML['Latitude'];
$location_longitude = $location_XML['Longitude'];
// get event number
$event_index = $_POST['event_index'];
if ($event_index > 0) {
$conn = get_db_connection($db_user, $db_passwd, $db_name);
$event_label = $event_index;
$latitudes[$event_index] = $location_latitude;
$longitudes[$event_index] = $location_longitude;
$sql_result = save_vote($location_latitude, $location_longitude, $event_label);
//
$db_status_close = close_db_connection($conn);
} else {
$event_label = "";
}
//
$map_click_X = $_POST['map_x'];
$map_click_Y = $_POST['map_y'];
} catch (exception $e) {
$location_latitude = 0;
$location_longitude = 0;
开发者ID:rheotaxis,项目名称:cuervos,代码行数:31,代码来源:index.php
示例13: get_db_connection
<?php
require 'db.php';
$conn = get_db_connection();
if ($conn === false) {
?>
<h1>Error connecting to database</h1>
<?php
die;
}
/* GET READY */
/* PUT YOUR CODE HERE */
?>
<form method="post">
<textarea name="content"></textarea>
<input type="text" name="author" placeholder="Your Name" />
<button type="submit">Submit Post</button>
</form>
开发者ID:txcsmad,项目名称:s16-web,代码行数:19,代码来源:messageboard.php
示例14: createFormElements
function createFormElements($report_elements)
{
global $bDebug;
if (!is_array($report_elements)) {
return;
}
unset($form_elements);
foreach ($report_elements as $key => $value) {
$elemName = $key;
$elemLabel = $value["label"];
$elemType = $value["type"];
//$arr_params = Array("dbLink"=>get_db_connection(), "bDebug"=>$bDebug );
$arr_params = get_db_connection();
$elemValuesFunction = $value["values_func"];
if ($elemValuesFunction != NULL) {
$elemValues = @call_user_func_array($elemValuesFunction, $arr_params);
//log_err("elemValuesFunction : $elemValuesFunction");
} else {
$elemValues = $value["values"];
}
$elemDefault = $value["default"];
$elemRequired = $value["required"];
switch ($elemType) {
case "date":
$strControl = createDateControl("document._FRM", $elemName, $elemDefault, $elemRequired);
break;
case "select":
$strControl = createSelect($elemName, $elemValues, $elemDefault, $script, $class_style);
break;
case "multiselect":
$strControl = createMultipleSelect($elemName, $elemValues, $elemDefault, $script, $class_style);
break;
case "input":
$strControl = createTextField($elemName, $elemValues, $elemLabel, $class);
break;
case "checkbox":
$strControl = createCheckBox($elemName, $elemValues, $elemLabel, $elemDefault);
break;
default:
$strControl = "cant create control, elem type {$elemType} undefined.";
break;
}
$form_elements[] = array("label" => $elemLabel, "required" => $elemRequired, "control" => $strControl);
}
return $form_elements;
}
开发者ID:laiello,项目名称:ebpls,代码行数:46,代码来源:ebpls.html.funcs.php
示例15: get_database
function get_database($dbname)
{
$conn = get_db_connection();
return $conn->{$dbname};
}
开发者ID:ramr,项目名称:phpmongotweet-example,代码行数:5,代码来源:common.php
示例16: save
/**
* Will attempt to save the current record. Can throw exceptions, so please try() your save()
* An INSERT will be performed if the primary key for $this is not already populated
* An UPDATE will be performed otherwise
* Various options will be available within the function --> still under construction(ie. sanitize,quote,includeEmpties,includeNulls)
* @param string/array $listOfFields --> determines which fields are to be saved (single fieldname string or indexed array of fieldnames)
* @return bool
*/
public function save($listOfFields = "*")
{
//If user passes *, then we'll attempt to save all columns (except for the primary key(s)) to the database
if ($listOfFields == '*') {
$listOfFields = $this->GetListOfFields();
} elseif (!is_array($listOfFields)) {
$listOfFields = array((string) $listOfFields);
//In the event that only a fieldname was passed as a parameter (instead of an array), then we'll turn it into an array so we can continue anyway
}
$db = get_db_connection();
//Create an assoc array of all the values we're about to save
$nameValuePairs = $this->GetFieldsAsAssocArray($listOfFields);
//Will remove the fields that are supposed to be excluded, and will even sanitize the data.
$field_values = array_values($nameValuePairs);
$field_names = array_keys($nameValuePairs);
if (DB_DRIVER == 'mysql') {
array_unshift($field_values, $this->GetBoundParamTypeString($field_names));
}
$primaryKeyData = array();
foreach ($this->PRIMARYKEY as $fieldName) {
$primaryKeyData[$fieldName] = $this->{$fieldName};
}
$pkValues = array_values($primaryKeyData);
$autoIncrementFieldName = $this->AUTOINCREMENT[0];
$boolAllPrimaryKeysHaveValues = count(array_filter($primaryKeyData)) == count($this->PRIMARYKEY);
$boolNoPrimaryKeysHaveValues = count(array_filter($primaryKeyData)) == 0;
if (!$boolAllPrimaryKeysHaveValues && !$boolNoPrimaryKeysHaveValues) {
throw new Exception('Not all primary keys have a value in "this" object. Not sure if INSERT or UPDATE is required, and so program was aborted.');
}
$field_esc_pre = $this::CHAR_ESCAPE_FIELD_NAME_PRE;
$field_esc_post = $this::CHAR_ESCAPE_FIELD_NAME_POST;
if ($boolNoPrimaryKeysHaveValues) {
//INSERT new record when this class's primary key property is empty
$sql = "INSERT INTO {$field_esc_pre}{$this->TABLENAME}{$field_esc_post}" . " ({$field_esc_pre}" . implode("{$field_esc_post}, {$field_esc_pre}", $field_names) . "{$field_esc_post})" . ' VALUES (' . str_repeat('?,', count($field_names) - 1) . '?) ';
//file_put_contents('c:/temp/phplog.txt',$sql);
$rs = $db->query($sql, null, null, $field_values);
if ($rs) {
$this->{$autoIncrementFieldName} = $db->insertID();
return true;
} else {
return false;
}
} else {
$where = 'WHERE ' . implode('=? AND ', $primaryKeyData) . ' = ?';
//UPDATE existing record based on this class's primary key
$sql = "UPDATE {$field_esc_pre}{$this->TABLENAME}{$field_esc_post} SET " . "{$field_esc_pre}" . implode("{$field_esc_post}=?, {$field_esc_pre}", $field_names) . "{$field_esc_post}=? " . " {$where}";
if (DB_DRIVER == 'mysql') {
$field_values[0] = $field_values[0] . $this->GetBoundParamTypeString($this->PRIMARYKEY);
}
//Since we're about to add PRIMARYKEY's values ($pkValues), we'll need to append their 'iissdd'
$field_values = array_merge($field_values, $pkValues);
$rs = $db->query($sql, null, null, $field_values);
if ($rs) {
if (count($this->{$autoIncrementFieldName})) {
//If an auto-incrementing field exists in this table
$this->{$autoIncrementFieldName} = $db->insertID();
//Then set it equal to the newly generated ID
}
return true;
} else {
return false;
}
}
}
开发者ID:Blue-Kachina,项目名称:Helping-Developers-With-Class,代码行数:72,代码来源:GeneratedClass.php
示例17: error_reporting
<?php
error_reporting(E_ALL);
session_start();
define('WEB', "http://localhost/photoAlbum/");
define('UPLOAD', WEB . 'files/');
define('INC', WEB . 'inc/');
define('ROOT', realpath(dirname(__FILE__)) . '/');
define('APP', ROOT . 'app/');
define('MODELS', ROOT . 'models/');
define('CONTROLLERS', ROOT . 'controllers/');
define('VIEWS', ROOT . 'views/');
require APP . "db.php";
get_db_connection()->query("set names UTF-8");
$queryString = $_SERVER['REQUEST_URI'];
$qmPos = strpos($queryString, '?');
if ($qmPos != 0) {
$queryString = substr($queryString, 0, $qmPos);
}
$tmp = explode('/', $queryString);
$tmp = array_filter($tmp);
array_shift($tmp);
$queryString = implode('/', $tmp);
switch (true) {
case empty($queryString):
$controller = 'index';
$action = 'index';
$params = array();
break;
case preg_match('/^photos\\/(\\d+)$/', $queryString, $matches):
$controller = 'photos';
开发者ID:Fznamznon,项目名称:myPhotoGallery,代码行数:31,代码来源:index.php
示例18: get_db_connection
<?php
require_once "lib/ebpls.lib.php";
require_once "lib/ebpls.utils.php";
require_once "ebpls-php-lib/utils/ebpls.search.funcs.php";
//require_once("includes/eBPLS_header.php");
//--- get connection from DB
$dbLink = get_db_connection();
?>
<?php
echo date("F dS Y h:i:s A");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<title>MATERLIST OF PROFESSIONAL TAX</title>
<meta name="Author" content=" Pagoda, Ltd. ">
<link href="includes/eBPLS.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="includes/eBPLS.js"></script>
</head>
<body>
<?php
$result = mysql_query("select lgumunicipality, lguprovince, lguoffice from ebpls_buss_preference") or die(mysql_error());
$resulta = mysql_fetch_row($result);
?>
开发者ID:laiello,项目名称:ebpls,代码行数:30,代码来源:ebpls_prof_tax.php
示例19: get_dm_db_connection
function get_dm_db_connection()
{
global $DB_CONFIGS;
return get_db_connection($DB_CONFIGS['DM_DB_CREDS']);
}
开发者ID:jacksteadman,项目名称:warehouse,代码行数:5,代码来源:db.php
示例20: print_ctc_form
function print_ctc_form($type, $form_elem_values)
{
$dbLink = get_db_connection();
$is_ctc_renew = false;
$ctcDebug = false;
$is_ctc_renew = true;
$clsCTC = new EBPLSCTC($dbLink, $ctcDebug);
if ($type == "") {
$type = CTC_TYPE_INDIVIDUAL;
}
//--- make a script that will calculate the tax
//$ctc_additional_tax1_due=((int)($ctc_addtional_tax1)/1000));
$tax_a1_fields = array("in" => array("document._FRM.ctc_additional_tax1"), "out" => "document._FRM.ctc_additional_tax1_due");
$tax_a2_fields = array("in" => array("document._FRM.ctc_additional_tax2"), "out" => "document._FRM.ctc_additional_tax2_due");
if ($type == CTC_TYPE_INDIVIDUAL) {
$tax_a3_fields = array("in" => array("document._FRM.ctc_additional_tax3"), "out" => "document._FRM.ctc_additional_tax3_due");
$basic_tax_field = array("in" => array('document._FRM.ctc_tax_exempted'), "out" => 'document._FRM.ctc_basic_tax');
$out_total_interest_due = array("in" => array("x1" => 'document._FRM.current_month', "x2" => 'document._FRM.ctc_total_amount_due'), "out" => 'document._FRM.ctc_total_interest_due');
$out_total_amount_due = array("in" => array("x1" => 'document._FRM.ctc_basic_tax', "x2" => 'document._FRM.ctc_additional_tax1_due', "x3" => 'document._FRM.ctc_additional_tax2_due', "x4" => 'document._FRM.ctc_additional_tax3_due'), "out" => 'document._FRM.ctc_total_amount_due');
$out_total_paid_due = array("in" => array("x1" => 'document._FRM.ctc_total_amount_due', "x2" => 'document._FRM.ctc_total_interest_due'), "out" => 'document._FRM.ctc_total_paid');
} else {
$basic_tax_field = array("in" => NULL, "out" => 'document._FRM.ctc_basic_tax');
$out_total_interest_due = array("in" => array("x1" => 'document._FRM.current_month', "x2" => 'document._FRM.ctc_total_amount_due'), "out" => 'document._FRM.ctc_total_interest_due');
$out_total_amount_due = array("in" => array("x1" => 'document._FRM.ctc_basic_tax', "x2" => 'document._FRM.ctc_additional_tax1_due', "x3" => 'document._FRM.ctc_additional_tax2_due'), "out" => 'document._FRM.ctc_total_amount_due');
$out_total_paid_due = array("in" => array("x1" => 'document._FRM.ctc_total_amount_due', "x2" => 'document._FRM.ctc_total_interest_due'), "out" => 'document._FRM.ctc_total_paid');
}
?>
<P><BR>
<script language=Javascript>
function checkCitizenship() {
if ( document._FRM.ctc_citizenship.selectedIndex > 1 ) {
document._FRM.ctc_icr_no.disabled = false;
} else {
document._FRM.ctc_icr_no.disabled = true;
document._FRM.ctc_icr_no.value = '';
}
}
//--- start CTC application page scripts
function validate_ctc_form_application()
{
var _FRM = document._FRM
var msgTitle = "Community Tax Certificate Application\n";
if ( _FRM.ctc_type.value == 'INDIVIDUAL' ) {
if( isBlank(_FRM.ctc_last_name.value) == true)
{
alert( msgTitle + "Please input a valid lastname!");
_FRM.ctc_last_name.focus();
return false;
}
if( isBlank(_FRM.ctc_first_name.value) == true)
{
alert( msgTitle + "Please input a valid firstname!");
_FRM.ctc_first_name.focus();
return false;
}
if( isBlank(_FRM.ctc_middle_name.value) == true)
{
alert( msgTitle + "Please input a valid middlename!");
_FRM.ctc_middle_name.focus();
return false;
}
if( isBlank(_FRM.ctc_address.value) == true)
{
alert( msgTitle + "Please input a valid address!");
_FRM.ctc_address.focus();
return false;
}
if( _FRM.ctc_gender.selectedIndex == 0 )
{
alert( msgTitle + "Please input a valid gender!");
_FRM.ctc_gender.focus();
return false;
}
if( _FRM.ctc_citizenship.selectedIndex == 0 )
{
alert( msgTitle + "Please input a valid citizenship!");
_FRM.ctc_citizenship.focus();
return false;
}
if( _FRM.ctc_citizenship.item(_FRM.ctc_citizenship.selectedIndex).value != 'FILIPINO' && _FRM.ctc_icr_no.value == '' )
{
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:ebpls,代码行数:101,代码来源:ebpls101.php
注:本文中的get_db_connection函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论