本文整理汇总了PHP中DBAccess::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP DBAccess::initialize方法的具体用法?PHP DBAccess::initialize怎么用?PHP DBAccess::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBAccess
的用法示例。
在下文中一共展示了DBAccess::initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DBAccess
<?php
//Autoload functionality
header("Access-Control-Allow-Origin: *");
include "../DBAccess.php";
$dbA = new DBAccess();
$pdo = $dbA->initialize();
$visitor = $_GET['visitor'];
$tenant_id = $_GET['tenant_id'];
$building_id_q = $pdo->query("SELECT building_id FROM users WHERE name = '{$tenant_id}'");
$building_id_a = $building_id_q->fetch(PDO::FETCH_ASSOC);
$building_id = $building_id = $building_id_a['building_id'];
$datetime = new DateTime();
$end_arrival_time = $datetime->add(new DateInterval('PT1H'));
$end_arrival_time = $end_arrival_time->format('Y-m-d H:i:s');
$datetime2 = new DateTime();
$arrival_time = $datetime2->sub(new DateInterval('PT1H'));
$arrival_time = $arrival_time->format('Y-m-d H:i:s');
$query = $pdo->prepare("INSERT INTO appointments (tenant_id, visitor, arrival_time, end_arrival_time, building_id) VALUES (?,?,NOW(), ?, ?)");
$query->execute(array($tenant_id, $visitor, $end_arrival_time, $building_id));