本文整理汇总了PHP中DbHandler类的典型用法代码示例。如果您正苦于以下问题:PHP DbHandler类的具体用法?PHP DbHandler怎么用?PHP DbHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DbHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calcularPercentilMargens
public static function calcularPercentilMargens($imc, $sexo, $nascimento)
{
$curva = new Curva();
// Margens dos percentis baseado no cálculo inicial.
$margemIMCInferior = $imc - MARGEM_LIMITE_PERCENTIL;
$margemIMCSuperior = $imc + MARGEM_LIMITE_PERCENTIL;
// Valores crescentes e decrescentes do IMC.
$imcDecrescente = $imc;
$imcCrescente = $imc;
$idadeMeses = DataUtil::calcularIdadeMeses($nascimento);
$db = new DbHandler();
// Verificação do percentil inferior.
$percentilInferior = NULL;
while (empty($percentilInferior) && $imcDecrescente >= $margemIMCInferior) {
// Decrescer gradativamente os valores do IMC na escala.
$imcDecrescente = $imcDecrescente - ESCALA_IMC_PERCENTIL;
$percentilInferior = $db->selecionarPercentil($imcDecrescente, $sexo, $idadeMeses);
}
$curva->setPercentilInferior($percentilInferior);
// Verificação do percentil superior.
$percentilSuperior = NULL;
while (empty($percentilSuperior) && $imcCrescente <= $margemIMCSuperior) {
// Crescer gradativamente os valores do IMC na escala.
$imcCrescente = $imcCrescente + ESCALA_IMC_PERCENTIL;
$percentilSuperior = $db->selecionarPercentil($imcCrescente, $sexo, $idadeMeses);
}
$curva->setPercentilSuperior($percentilSuperior);
return $curva;
}
示例2: authenticate
/**
* Checking if the request has valid api key in the "Authorization" header
*/
function authenticate(\Slim\Route $route)
{
$headers = apache_request_headers();
$response = array();
$app = \Slim\Slim::getInstance();
if (isset($headers["Authorization"])) {
$db = new DbHandler();
$api_key = $headers["Authorization"];
$user = $db->isValidApiKey($api_key);
if ($user == null) {
$response["error"] = true;
$response["message"] = "Access Denied. Invalid Api key";
echoResponse(FAILURE_CODE, $response);
$app->stop();
} else {
global $user_name;
$user_name = $user;
}
} else {
$response["error"] = true;
$response["message"] = "Api key is misssing";
echoResponse(404, $response);
$app->stop();
}
}
示例3: authenticate
/**
* Adding Middle Layer to authenticate every request
* Checking if the request has valid api key in the 'Authorization' header
*/
function authenticate(\Slim\Route $route)
{
// Getting request headers
$headers = apache_request_headers();
$response = array();
$app = \Slim\Slim::getInstance();
// Verifying Authorization Header
if (isset($headers['Authorization'])) {
$db = new DbHandler();
// get the api key
$api_key = $headers['Authorization'];
// validating api key
if (!$db->isValidApiKey($api_key)) {
// api key is not present in users table
$response["error"] = true;
$response["message"] = "Access Denied. Invalid Api key";
echoRespnse(401, $response);
$app->stop();
} else {
global $user_id;
// get user primary key id
$user_id = $db->getUserId($api_key);
}
} else {
// api key is missing in header
$response["error"] = true;
$response["message"] = "Api key is misssing";
echoRespnse(400, $response);
$app->stop();
}
}
示例4: doLog
function doLog($Mesaj)
{
$db = new DbHandler();
$useragent = $_SERVER["HTTP_USER_AGENT"];
$IPAdres = $_SERVER["REMOTE_ADDR"];
$db->Log($IPAdres, $useragent, $Mesaj);
}
示例5: notifyAdmins
public function notifyAdmins($id, $title, $description, $author, $email, $time = "", $geo = "", $source = "")
{
$dbHandler = new DbHandler();
$emails = $dbHandler->getAdminsEmails();
if (count($emails) == 0) {
return;
}
$emails_comma_separated = $this->recieversString($emails);
$subject = $this->constructEmailSubject($id);
$body = $this->constructEmailBody($id, $title, $description, $author, $email, $time, $geo, $source);
$headers = $this->makeHeaders();
mail($emails_comma_separated, $subject, $body, $headers);
}
示例6: getTable
function getTable()
{
$db = new DbHandler();
$result = $db->getEbookAll();
$response["error"] = false;
$response["ebooks"] = array();
$allEbooksArray = array();
if ($result != null) {
while ($row = $result->fetch_assoc()) {
$allEbooksArray[] = array("Id" => $row['id'], "nazwa" => $row['nazwa'], "opis" => $row['opis'], "dane" => $row['dane']);
}
}
$this->allEbooksArray = $allEbooksArray;
}
示例7: getUserId
protected static function getUserId($username)
{
$conn = DbHandler::getConnection();
$query = "SELECT id FROM users WHERE username = '" . $conn->escapeString($username) . "'";
$user_id = $conn->querySingle($query);
return $user_id;
}
示例8: insertMessage
public static function insertMessage($user_id, $chat_id, $message)
{
$conn = DbHandler::getConnection();
$query = "INSERT INTO messages (chat_id, user_id, message, insert_time) " . "VALUES (" . $conn->escapeString($chat_id) . ", " . $conn->escapeString($user_id) . ", '" . $conn->escapeString($message) . "', " . $conn->escapeString(getMicrotime()) . ")";
$conn->exec($query);
UserHandler::setUserActivity();
return true;
}
示例9: array
$sheet = $objPHPExcel->getActiveSheet();
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
// Loop through each row of the worksheet in turn
$array['cols'][] = array('type' => 'date', 'id' => 'date', 'label' => 'Date');
$array['cols'][] = array('type' => 'number', 'id' => 'Theorique', 'label' => 'Théorique');
$array['cols'][] = array('type' => 'number', 'id' => 'Centres_ouverts', 'label' => 'Centres ouverts');
$array['cols'][] = array('type' => 'number', 'id' => 'Centres_actifs', 'label' => 'Centres actifs');
for ($row = 2; $row <= $highestRow; $row++) {
$array['rows'][] = array('c' => array(array('v' => 'Date(' . date('Y, m , j', strtotime('-1 month', strtotime(date('Y-m-j', PHPExcel_Shared_Date::ExcelToPHP($sheet->getCellByColumnAndRow(0, $row)->getValue()))))) . ')'), array('v' => $sheet->getCellByColumnAndRow('1', $row)->getValue()), array('v' => $sheet->getCellByColumnAndRow('2', $row)->getValue()), array('v' => $sheet->getCellByColumnAndRow('3', $row)->getValue())));
}
echoResponse(200, $array);
}
});
$app->get('/etude/:id/courbe/patient', function ($id) {
$db = new DbHandler();
$query = "SELECT laboratoire.libelle as lab,etude.libelle as et FROM etude , laboratoire WHERE etude.id_laboratoire=laboratoire.id and etude.id={$id}";
$response = $db->execute($query);
foreach ($response as &$value) {
$rep = "../../data/" . $value['lab'] . "/" . $value['et'] . "/Courbe_Patients.xlsx";
}
date_default_timezone_set('Europe/Paris');
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
if (file_exists($rep)) {
$objPHPExcel = $objReader->load($rep);
$sheet = $objPHPExcel->getActiveSheet();
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
// Loop through each row of the worksheet in turn
$array['cols'][] = array('type' => 'date', 'id' => 'date', 'label' => 'Date');
示例10: define
<?php
require_once '../include/DbHandler.php';
require_once '../include/PassHash.php';
require '.././libs/Slim/Slim.php';
define('DB_HOST', 'localhost');
define('DB_NAME', 'task_manager');
define('DB_USER', 'vyk');
define('DB_PASSWORD', 'navneeta');
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db = mysql_select_db(DB_NAME, $con) or die("Failed to connect to MySQL: " . mysql_error());
$u = $_POST['user'];
$p = $_POST['pass'];
$db = new DbHandler();
// check for correct email and password
if ($db->checkLogin($email, $password)) {
// get the user by email
$user = $db->getUserByEmail($email);
if ($user != NULL) {
echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
} else {
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
}
}
示例11: array
$pdf->Open();
$pdf->AddPage();
$pdf->SetMargins(5, 3, 5);
// margen, left, top y right
//$pdf->Ln(03);
//$pdf->SetWidths(array(65, 60, 55, 50, 20));
$pdf->SetFont('Arial', 'B', 8);
$pdf->SetFillColor(85, 107, 47);
$pdf->SetTextColor(0);
$pdf->ln();
//
$response = array();
$lisPreguntas = json_decode($app->request->getBody());
$idUser = intval($_SESSION['uid']);
$lista = implode(",", $lisPreguntas);
$db = new DbHandler();
$impresas = $db->get1Record("select fn_num_respuesta_print( '{$lista}' ) as cantidad");
//var_dump($impresas);
if ($impresas['cantidad'] == 0) {
// genera las respuestas en el documento PDF
// $target_dir = $_SERVER['DOCUMENT_ROOT'] . "/server/uploaded_files/";
// registra el nuevo lote de preguntas impresas
// insert into pyr_respuesta_print ( id, fecha, id_usuario ) values ( now(), now(), 12 );
$idLote = $db->get1Record("select fn_ins_pyr_respuesta_print( {$idUser} ) as id");
if ($idLote != NULL && $idLote > 0) {
$ok = true;
foreach ($lisPreguntas as $respuesta) {
// registra el detalle de preguntas incluidas en el lote
// insert into pyr_respuesta_print_det ( id_print, id_pregunta ) values ( '2015-11-13 01:04:40', 63 );
if ($ok == true) {
$idDet = $db->get1Record("select fn_ins_pyr_respuesta_print_det( '" . $idLote['id'] . "', {$respuesta} ) as idDet");
示例12: function
}
});
$app->post('/resetPassword', function () use($app) {
require_once 'passwordHash.php';
$response = array();
$r = json_decode($app->request->getBody());
$password_non = $r->password;
if (strtolower($password) == $password_non) {
$response["status"] = "error";
$response["message"] = "Need at least 1 capital letter in password";
echoResponse(201, $response);
$app->stop();
}
if (!preg_match('/[0-9]+/', $password_non)) {
$response["status"] = "error";
$response["message"] = "Need at least 1 number in password";
echoResponse(201, $response);
$app->stop();
}
$password = passwordHash::hash($password_non);
$key = $r->key;
$db = new DbHandler();
$dbemail = $db->getOneRecord("select email from confirm where validation_key='{$key}'");
$email = $dbemail['email'];
$dbuid = $db->getOneRecord("select uid from users where email='{$email}'");
$uid = $dbuid['uid'];
$db->updateOneRecord("update users set password = '{$password}' where uid='{$uid}'");
$response["status"] = "success";
$response["message"] = "Account password sucessfully reset.";
echoResponse(200, $response);
});
示例13: exit
<?php
include_once "utility.php";
include_once "db.php";
/**
* Created by PhpStorm.
* User: Steve
* Date: 9/22/14
* Time: 8:09 PM
*/
$user = "richarddurden";
$pw = "Zero";
if (strtolower($_POST['user_name']) != $user || $_POST['user_password'] != $pw) {
exit("INVALID CREDENTIALS");
}
$week = $_POST["week"];
$scorecard = $_POST["scorecard"];
if ($scorecard == 'true') {
$scorecard = 1;
} else {
$scorecard = 0;
}
$news1 = $_POST["news1"];
$news2 = $_POST["news2"];
$news3 = $_POST["news3"];
$db = new DbHandler();
$db->insertVariables($week, $scorecard, $news1, $news2, $news3);
exit("Status: Content inserted successfully");
示例14: array
$response["message"] = array();
// looping through result and preparing tasks array
while ($project = $result->fetch_assoc()) {
$tmp = array();
$tmp["nombre"] = $project["nombre"];
$tmp["socialID"] = $project["socialID"];
$tmp["proyectoID"] = $project["proyectoID"];
$tmp["comentario"] = $project["comentario"];
$tmp["fecha_comentario"] = $project["fecha_comentario"];
array_push($response["message"], $tmp);
}
echoRespnse(200, $response);
});
$app->post('/donar', function () use($app) {
$response = array();
$db = new DbHandler();
// fetching all user tasks
$result = $db->getAllProjects();
$response["error"] = false;
$response["message"] = array();
// looping through result and preparing tasks array
while ($project = $result->fetch_assoc()) {
$tmp = array();
$tmp["nombre"] = $project["nombre"];
$tmp["descripcionLarga"] = $project["descripcion_larga"];
$tmp["descripcionCorta"] = $project["descripcion_corta"];
$tmp["monto"] = $project["monto"];
$tmp["diasVigencia"] = $project["diasvigencia"];
$tmp["proyectoID"] = $project["proyectoID"];
$tmp["categoria"] = $project["categoria"];
$tmp["ciudad"] = $project["ciudad"];
示例15: DbHandler
<?php
require_once '../include/DbHandler.php';
$db = new DbHandler();
$result = $db->crearRespuesta("Hola hola bla bla", 6, 1);
if (is_null($result)) {
echo "Es NULL";
} else {
print_r($result);
}