本文整理汇总了PHP中get_connection函数的典型用法代码示例。如果您正苦于以下问题:PHP get_connection函数的具体用法?PHP get_connection怎么用?PHP get_connection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_connection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_product
function update_product($name, $type, $price, $description, $logo, $id)
{
$db_connection = get_connection();
$query = "UPDATE products SET name='{$name}', type='{$type}', price='{$price}', description='{$description}', logo='{$logo}' WHERE id='{$id}'";
mysqli_query($db_connection, $query);
mysqli_close($db_connection);
}
示例2: db_query
/**
* Выполняет SQL-запрос (INSERT/UPDATE/DELETE/REPLACE/ALTER/...).
*
* @param string $query SQL-запрос
* @param array $params Список именованных параметров и их значений, например: array(':email' => 'foo@bar.com')
*
* @return int Количество затронутых строк (сколько строк было вставлено или изменено или удалено в таблице)
*/
function db_query($query, $params = array())
{
/** @var PDO $pdo */
$pdo = get_connection();
$statement = $pdo->prepare($query);
$statement->execute($params);
return $statement->rowCount();
}
示例3: data_edit_setting
function data_edit_setting($config, $name, $value)
{
// get connection
$conn = get_connection($config);
// create the SQL statement
$sql = "UPDATE setting \n\t\t\tSET Value = '{$value}'\n\t\t\tWHERE name = '{$name}'";
// execute the SQL statement
return mysql_query($sql, $conn) or die(mysql_error());
}
示例4: __construct
/**
* PersonaModel constructor.
* @param $persona
*/
public function __construct(Persona $persona = null)
{
if ($persona) {
$this->persona = $persona;
}
$this->connecion = get_connection();
$this->connecion->selectDB("test");
$this->CPersona = $this->connecion->selectCollection("test", "persona");
//selecciona la coleccion
}
示例5: store_on_temp_table
public function store_on_temp_table()
{
$id_last_trajectory = get_last_id_trajectory();
$connection = get_connection();
$sql_insert_fix = sprintf($this->sql_insert_fix_temp_table, $id_last_trajectory, $this->latitude, $this->longitude, $this->timestamp, $this->accuracy);
$connection->query($sql_insert_fix);
if ($connection->error) {
die('Could not store fix' . $connection->error);
}
$connection->close();
}
示例6: store
public function store()
{
$id_last_trajectory = get_last_id_trajectory();
$sql_insert_staypoint = sprintf($this->sql_insert_staypoint, $id_last_trajectory, $this->latitude, $this->longitude, $this->arrival_time, $this->departure_time, $this->fixes_involved);
$connection = get_connection();
$connection->query($sql_insert_staypoint);
if ($connection->error) {
die('Could not store staypoint' . $connection->error);
}
$connection->close();
}
示例7: dump_query
function dump_query($q, $array = NULL, $tableclass = NULL)
{
$Connection = get_connection();
$s = $Connection->prepare($q);
if (is_null($array)) {
$s->execute();
} else {
$s->execute($array);
}
return dump_result($s, $tableclass);
}
示例8: del_user
function del_user($user_id)
{
if (!($db_link = get_connection())) {
return -1;
}
$sql = 'delete from user where id=' . $user_id;
if (mysqli_query($db_link, $sql)) {
mysqli_close($db_link);
return 1;
} else {
mysqli_close($db_link);
return -2;
}
}
示例9: handle_put
function handle_put($conversation)
{
// Note: You can only "consume" the entity once, so if we want it
// as text, and want to refer to it more than once, we should keep
// a reference to that text.
$text = $conversation->entity->getText();
$note = json_decode($text, true);
$connection = get_connection();
try {
add_note($note, $connection);
update_board_timestamp($note, $connection);
} catch (Exception $x) {
$connection->close();
throw $x;
}
$connection->close();
return handle_get($conversation);
}
示例10: list_users
function list_users()
{
$dbh = get_connection($GLOBALS['db_access_info_daityo']);
if ($dbh == false) {
error_exit("データベースに接続できません。理由: {$php_errormsg}");
} else {
//error_exit("データベースに接続できました。");
}
$sql = "select employeecode, employeenamekana, employeenamekanji, password, categorycode, inoutflag, email" . " from employee" . " where (status <> " . bind_param(1, PRAM_STRING) . ")" . " and categorycode in ('005', '007')" . " and (employeecode <> '998' and employeecode <> '999')" . " order by employeecode";
$res = pg_query($dbh, $sql);
if ($res == false) {
error_exit("SQLの実行に失敗しました。理由: {$php_errormsg}");
} else {
$list = pg_fetch_all($res);
//$list = array();
//while($rc = pg_fetch_array($res)) {
// array_push($list, $rc);
//}
return $list;
}
}
示例11: get_user_data
function get_user_data($id)
{
$year = date('Y', strtotime("+3 months", strtotime(date('Y-m-d'))));
$conn = get_connection();
$r = $conn->query('select u.name name, u.email email, u.year year, un.name universe, u.first_time first_time, u.ready ready, u.admin admin,
l.list list, e.excluded exclusion
from zolken_invisiblefriend.users u
inner join zolken_invisiblefriend.universes un on un.id = u.universe
left join zolken_invisiblefriend.lists l on u.id = l.user and l.year=' . $year . '
left join zolken_invisiblefriend.exclusions e on u.id = e.user and e.year=' . $year . '
where u.id=' . $id . ';');
$json = null;
if ($r && $r->num_rows > 0) {
$row = $r->fetch_array(MYSQLI_ASSOC);
$row['name'] = base64_decode($row['name']);
$row['email'] = base64_decode($row['email']);
$json = json_encode($row);
}
$conn->close();
return $json;
}
示例12: select_from
function select_from($What, $Where, $Array = NULL)
{
$Connection = get_connection();
if (is_null($Array)) {
$Query = "SELECT {$What} FROM {$Where}";
$Statement = $Connection->prepare($Query);
// $Statement->bindValue(':a',$What,PDO::PARAM_STR);
// $Statement->bindValue(':b',$Where,PDO::PARAM_STR);
$Statement->execute();
} else {
$Query = "SELECT {$What} FROM {$Where}";
$Statement = $Connection->prepare($Query);
$Statement->execute($Array);
}
$Row = $Statement->fetch();
$Statement->closeCursor();
if ($Row !== FALSE) {
return $Row[0];
} else {
return NULL;
}
}
示例13: send_welcome_mail
function send_welcome_mail($id)
{
$boundary = "__imafuckinggodbaby";
$eencoded = "";
$epass = "";
$uu = "";
$name = "";
include_once '../mysql_connection.php';
$conn = get_connection();
$res = $conn->query("select u.name,u.email,u.password,un.name uname from zolken_invisiblefriend.users u inner join zolken_invisiblefriend.universes un on un.id = u.universe where u.id=" . $id . ";");
if ($res && $res->num_rows > 0) {
$row = $res->fetch_array(MYSQLI_ASSOC);
$name = base64_decode($row['name']);
$eencoded = $row['email'];
$epass = $row['password'];
$uu = $row['uname'];
} else {
return false;
}
$conn->close();
$header = "From:no-reply@ztools.tk\r\nX-PHP-Script: PHP ztools.tk\r\nContent-Type:multipart/alternative; boundary={$boundary}\r\n\r\n";
$plain = "--{$boundary}\r\nContent-Type:text/plain; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n" . file_get_contents('../../pages/welcome_mail.txt') . "\r\n";
$plain = str_replace('#user#', $name, $plain);
$html = "--{$boundary}\r\nContent-Type:text/html; charset=\"UTF-8\"\r\nContent-Transfer-Encoding: 8bit\r\n\r\n" . file_get_contents('../../pages/welcome_mail.html') . "\r\n";
$html = str_replace('#user#', $name, $html);
$link = "http://www.ztools.tk/php/users/active_user.php?id=" . $id . "&hash=" . md5($eencoded . $epass);
$unsub = "http://www.ztools.tk/php/users/unsub_user.php?id=" . $id . "&hash=" . md5($eencoded . $epass);
$plain = str_replace('#universe#', $uu, $plain);
$plain = str_replace('#link#', $link, $plain);
$plain = str_replace('#unsub#', $unsub, $plain);
$html = str_replace('#universe#', $uu, $html);
$html = str_replace('#link#', $link, $html);
$html = str_replace('#unsub#', $unsub, $html);
$rew = 5;
while (!mail(base64_decode($eencoded), "Correu de confirmació", $plain . $html, $header) && $rew > 0) {
$rew--;
}
return $rew > 0;
}
示例14: send_mail
function send_mail($rem, $rew)
{
global $year;
$conn = get_connection();
if ($conn->multi_query("select u.name name1, u.email email\n\t\t\t\t\t from zolken_invisiblefriend.users u\n where u.id=" . $rem . ";\n\t\t\t\t\t select u.id id2, u.name name2,l.list\n\t\t\t\t\t from zolken_invisiblefriend.users u\n\t\t\t\t\t left join zolken_invisiblefriend.lists l on l.user = u.id\n\t\t\t\t\t where u.id=" . $rew . ";")) {
if ($result = $conn->store_result()) {
$info1 = $result->fetch_array(MYSQLI_ASSOC);
} else {
return false;
}
$conn->next_result();
if ($result = $conn->store_result()) {
$info2 = $result->fetch_array(MYSQLI_ASSOC);
} else {
return false;
}
} else {
return false;
}
send_raffle_mail(base64_decode($info1['email']), base64_decode($info1['name1']), base64_decode($info2['name2']), $info2['id2'], str_replace(';', '\\n', $info2['list']));
$conn->close();
return true;
}
示例15: define
<?php
define("ROOT", "../..");
require ROOT . "/libs/lib_list.php";
$f = array('deletar_cliente' => function () {
$dao = new ClienteDAO(get_connection());
$dao->deletar_cliente($_GET['cod_cliente']);
Header("Location: listar.php?alert=success");
});
$f[$_GET['f']]();