本文整理汇总了PHP中DB_Functions类的典型用法代码示例。如果您正苦于以下问题:PHP DB_Functions类的具体用法?PHP DB_Functions怎么用?PHP DB_Functions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB_Functions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processForm
function processForm()
{
$db = new DB_Functions();
$error_msg = "";
//validate user input
if ($_POST['companyName'] == "") {
printForm();
echo "Invalid Company Name.\n";
return;
} else {
if ($_POST['lastTradedPrice'] == "") {
printForm();
echo "Invalid Last Traded Price Value.\n";
return;
} else {
if ($_POST['previousPrice'] == "") {
printForm();
echo "Invalid Previous Price Value.\n";
return;
}
}
}
//save data to table
$change = $_POST['lastTradedPrice'] - $_POST['previousPrice'];
$result = $db->addShareListingEntry($_POST['companyName'], $_POST['lastTradedPrice'], $_POST['previousPrice'], $change);
if (!$result == false) {
//data was successfully saved to database
header('Location: http://localhost/eserver/account.php');
} else {
$error_msg = "Data could not be saved in database.\n";
printForm();
}
}
示例2: send_notification
/**
* Sending Push Notification
*/
public function send_notification($title, $message)
{
// include config
include_once './config.php';
include_once './db_functions.php';
$db = new DB_Functions();
$ids = $db->getRegisteredIds();
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array('registration_ids' => $ids, 'notification' => array('title' => $title, 'body' => $message));
$headers = array('Authorization: key=' . GOOGLE_API_KEY, 'Content-Type: application/json');
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
// Close connection
curl_close($ch);
echo $result;
}
示例3: getUltimoPacienteId
function getUltimoPacienteId()
{
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
$id = $db->getUltimoPacienteInserido();
return $id;
}
示例4: storePatient
/**
* Storing new user
* returns user details
*/
public function storePatient($name, $email, $password, $address, $telephone)
{
require_once 'DB_Functions.php';
$dbFunctions = new DB_Functions();
$resultP = mysqli_query($this->mysqli, "INSERT INTO per_all_people_f(name, email, person_type, telephone ) VALUES('{$name}', '{$email}', 'P' , '{$telephone}');");
// check for successful store
if ($resultP) {
// get user details
$personId = mysqli_insert_id($this->mysqli);
// last inserted id
$uuid = uniqid('', true);
$hash = $dbFunctions->hashSSHA($password);
$encrypted_password = $hash["encrypted"];
// encrypted password
$salt = $hash["salt"];
// salt
$resultU = mysqli_query($this->mysqli, "INSERT INTO users(unique_id, name, email, person_id, encrypted_password, salt, created_at) VALUES('{$uuid}', '{$name}', '{$email}', '{$personId}', '{$encrypted_password}', '{$salt}', NOW())");
$resultPatient = mysqli_query($this->mysqli, "INSERT INTO patient(person_id) VALUES('{$personId}')");
$patientId = mysqli_insert_id($this->mysqli);
// last inserted id
$patientIdUpdate = mysqli_query($this->mysqli, "update per_all_people_f set patient_id = {$patientId} where person_id = {$personId}");
$resultAddress = mysqli_query($this->mysqli, "INSERT INTO address(house_no,person_id) VALUES('{$address}','{$personId}')");
$result = mysqli_query($this->mysqli, "SELECT * FROM per_all_people_f WHERE person_id = {$personId}");
if ($resultU && $resultPatient && $resultAddress && $patientIdUpdate) {
return mysqli_fetch_array($result);
} else {
return FALSE;
}
} else {
return false;
}
}
示例5: smartpush
function smartpush($uid, $message)
{
include "db_functions.php";
include "gcm.php";
$gcm = new GCM();
$db = new DB_Functions();
$users = $db->getAllUsers();
if ($users != false) {
$no_of_users = mysql_num_rows($users);
} else {
$no_of_users = 0;
}
if ($no_of_users > 0) {
while ($row = mysql_fetch_array($users)) {
$regId = $row['gcm_regid'];
// $message = "สวัสดีชาวโลก";
$registatoin_ids = array($regId);
// $message = array("price" => $message);
$result = $gcm->send_notification($registatoin_ids, $message);
//echo $result;
}
} else {
echo "ไม่มีข้อมูล";
}
}
示例6: processForm
function processForm()
{
$db = new DB_Functions();
$error_msg = "";
//validate user input
if ($_POST['currency'] == "") {
printForm();
echo "Invalid Currency Entered.\n";
return;
} else {
if ($_POST['buyingRate'] == "") {
printForm();
echo "Invalid Buying Rate.\n";
return;
} else {
if ($_POST['sellingRate'] == "") {
printForm();
echo "Invalid Selling Rate.\n";
return;
}
}
}
//save data to table
$result = $db->addExchangeRate($_POST['currency'], $_POST['buyingRate'], $_POST['sellingRate']);
if (!$result == false) {
//data was successfully saved to database
header('Location: http://localhost/eserver/account.php');
} else {
$error_msg = "Data could not be saved in database.\n";
printForm();
}
}
示例7: testChangeBeliebt
public function testChangeBeliebt()
{
$db = new DB_Functions();
$this->assertTrue($db->changeBeliebt(1, 1));
$irgendneVariable = $db->getSpeisen();
$this->assertEquals(1, $irgendneVariable[0]['beliebt'], 'Beliebtheit nicht gestiegen');
}
示例8: searchDB
function searchDB($query, $extra)
{
// Get Database connector
include_once 'config/db_functions.php';
$db = new DB_Functions();
$result = $db->searchTable($query, $extra);
//$result =$extra;
return $result;
}
示例9: send_notification
/**
* Sending Push Notification
*/
public function send_notification($registration_ids, $message)
{
// include config
require_once 'config.php';
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array('registration_ids' => $registration_ids, 'data' => $message);
$headers = array('Authorization: key=' . GOOGLE_API_KEY, 'Content-Type: application/json');
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
} else {
$jsonres = json_decode($result);
if (!empty($jsonres->results)) {
require_once 'db_functions.php';
$db = new DB_Functions();
for ($i = 0; $i < count($jsonres->results); $i++) {
if (isset($jsonres->results[$i]->registration_id)) {
$new = $db->updateUser($registration_ids[$i], $jsonres->results[$i]->registration_id);
} else {
if (isset($jsonres->results[$i]->error)) {
if ($jsonres->results[$i]->error == "NotRegistered") {
$res = $db->deleteUser($registration_ids[$i]);
}
}
}
}
echo $result . "\n";
$canonical_ids_count = $jsonres->canonical_ids;
if ($canonical_ids_count) {
echo count($canonical_ids_count) . " registrations updated\n";
}
}
}
// Close connection
curl_close($ch);
}
示例10: processForm
function processForm()
{
$db = new DB_Functions();
$error_msg = "";
//validate user input
if ($_POST['ad'] == "") {
printForm();
echo "Invalid Adert value.\n";
return;
} else {
if ($_POST['ad_url'] == "") {
printForm();
echo "Invalid Advert URL value.\n";
return;
} else {
if ($_POST['ad_category'] == "") {
printForm();
echo "Invalid Advert category value.\n";
return;
}
}
}
//save data to table
$result = $db->addNewAdvert($_POST['ad'], $_POST['ad_url'], $_POST['ad_category']);
if (!$result == false) {
//data was successfully saved to database
header('Location: http://localhost/eserver/account.php');
} else {
$error_msg = "Data could not be saved in database.\n";
printForm();
}
}
示例11: reportList
function reportList()
{
$db = new DB_Functions();
$reportNames = $db->getAllReportList();
if ($reportNames != false) {
$no_of_reports = mysql_num_rows($reportNames);
} else {
$no_of_reports = 0;
}
echo '<li><a>NA</a></li>';
if ($no_of_reports > 0) {
while ($row = mysql_fetch_array($reportNames)) {
echo '<li><a >' . $row["ReportName"] . '</a></li>';
}
} else {
echo '<li>No Reports Added Yet!</li>';
}
}
示例12: usersList
function usersList()
{
$db = new DB_Functions();
$users = $db->getAllUsers();
if ($users != false) {
$no_of_users = mysql_num_rows($users);
} else {
$no_of_users = 0;
}
echo '<li><a>NA</a></li>';
if ($no_of_users > 0) {
while ($row = mysql_fetch_array($users)) {
echo '<li><a >' . $row["Name"] . '</a></li>';
}
} else {
echo '<li>No Users Registered Yet!</li>';
}
}
示例13: processForm
function processForm()
{
$db = new DB_Functions();
//validate user input
if ($_POST['rangeFrom'] == "") {
printForm();
echo "Invalid From Range.\n";
return;
} else {
if ($_POST['rangeTo'] == "") {
printForm();
echo "Invalid Invalid Range To.\n";
return;
} else {
if ($_POST['1MonthPa'] == "") {
printForm();
echo "Invalid 1 month pa Value.\n";
return;
} else {
if ($_POST['3MonthPa'] == "") {
printForm();
echo "Invalid 3 month pa Value.\n";
return;
} else {
if ($_POST['6MonthPa'] == "") {
printForm();
echo "Invalid 6 month pa Value.\n";
return;
} else {
if ($_POST['1YearPa'] == "") {
printForm();
echo "Invalid 1 Year pa Value.\n";
return;
}
}
}
}
}
}
//save data to table
$result = $db->addFixedDepositRate($_POST['rangeFrom'], $_POST['rangeTo'], $_POST['1MonthPa'], $_POST['3MonthPa'], $_POST['6MonthPa'], $_POST['1YearPa']);
if (!$result == false) {
//data was successfully saved to database
header('Location: http://localhost/eserver/account.php');
} else {
$error_msg = "Data could not be saved in database.\n";
printForm();
}
}
示例14: processForm
function processForm()
{
$db = new DB_Functions();
$error_msg = "";
//validate user input
if ($_POST['adminname'] == "") {
printForm();
echo "Invalid Name.\n";
return;
} else {
if ($_POST['idNo'] == "") {
printForm();
echo "Invalid IdNo.\n";
return;
} else {
if ($_POST['password'] == "") {
printForm();
echo "Invalid Password.\n";
return;
} else {
if ($_POST['password'] != $_POST['passwordConfirm']) {
printForm();
echo "Passwords do not match!\n";
return;
} else {
if ($_POST['username'] == "") {
printForm();
echo "Invalid Username.\n";
return;
}
}
}
}
}
//save data to table
$result = $db->administratorSignUp($_POST['username'], md5($_POST['password']), $_POST['idNo'], $_POST['adminname']);
if (!$result == false) {
//data was successfully saved to database
header('Location: http://localhost/eserver/account.php');
} else {
$error_msg = "Data could not be saved in database.\n";
printForm();
}
}
示例15: ini_set
<?php
ini_set('default_charset', 'utf-8');
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
// json response array
$response = array("error" => FALSE);
if (isset($_POST['userID']) && isset($_POST['building']) && isset($_POST['floor']) && isset($_POST['room'])) {
// receiving the post params
$userID = $_POST['userID'];
$building = $_POST['building'];
$floor = $_POST['floor'];
$room = $_POST['room'];
$company = $_POST['company'];
$phone = $_POST['phone'];
// check if user is already existed with this user_ID
if ($db->isUserIDExisted($userID)) {
// create a new user
$userAddress = $db->updateUserAddress($userID, $building, $floor, $room, $company, $phone);
if ($userAddress) {
$response["error"] = FALSE;
$response["userAddress"]["building"] = $userAddress["building"];
$response["userAddress"]["floor"] = $userAddress["floor"];
$response["userAddress"]["room"] = $userAddress["room"];
$response["userAddress"]["company"] = $userAddress["company"];
$response["userAddress"]["phone"] = $userAddress["phone"];
echo json_encode($response, JSON_UNESCAPED_UNICODE);
} else {
// user failed to store
$response["error"] = TRUE;
$response["error_msg"] = "Unknown error occurred in updating address!";