本文整理汇总了PHP中DataObject::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::connect方法的具体用法?PHP DataObject::connect怎么用?PHP DataObject::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObject
的用法示例。
在下文中一共展示了DataObject::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteAllForMember
public static function deleteAllForMember($memberId)
{
$conn = parent::connect();
$sql = "DELETE FROM " . TBL_ACCESS_LOG . " WHERE memberId = :memberId";
try {
$st = $conn->prepare($sql);
$st->bindValue(":memberId", $memberId, PDO::PARAM_INT);
$st->execute();
parent::disconnect($conn);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例2: insert
public function insert()
{
$conn = parent::connect();
$sql = "INSERT INTO factura (id_pedido, precio) \nVALUES (:id_pedido, :precio);";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT);
$st->bindValue(":precio", $this->data["precio"], PDO::PARAM_STR);
$st->execute();
parent::disconnect($conn);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例3: getMember
public static function getMember($id)
{
$conn = parent::connect();
$sql = "SELECT * FROM " . TBL_MEMBERS . " WHERE id = :id";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id", $id, PDO::PARAM_INT);
$st->execute();
if ($row = $st->fetch()) {
return new Member($row);
}
} catch (PDOException $e) {
die("Query failed: " . $e->getMessage());
}
}
示例4: insert
public function insert()
{
$conn = parent::connect();
$sql = "INSERT INTO pedido_menu (id_menu, id_pedido, id_decoracion) \nVALUES (:id_menu, :id_pedido, :id_decoracion);";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id_menu", $this->data["id_menu"], PDO::PARAM_INT);
$st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT);
$st->bindValue(":id_decoracion", $this->data["id_decoracion"], PDO::PARAM_INT);
$st->execute();
parent::disconnect($conn);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例5: getById
public static function getById($id_decoracion)
{
$conn = parent::connect();
$sql = "SELECT * FROM decoracion WHERE id_decoracion = :id_decoracion";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id_decoracion", $id_decoracion, PDO::PARAM_INT);
$st->execute();
$row = $st->fetch();
parent::disconnect($conn);
if ($row) {
return new Decoracion($row);
}
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例6: getPrecio
public static function getPrecio($id_menu)
{
$conn = parent::connect();
$sql = "SELECT nombre, precio FROM menu WHERE id_menu = :id_menu";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id_menu", $id_menu, PDO::PARAM_INT);
$st->execute();
$row = $st->fetch();
parent::disconnect($conn);
if ($row) {
return new Menu($row);
}
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例7: getById
public static function getById($id_bebida)
{
$conn = parent::connect();
$sql = "SELECT * FROM bebidas WHERE id_bebida = :id_bebida";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id_bebida", $id_bebida, PDO::PARAM_STR);
$st->execute();
$row = $st->fetch();
parent::disconnect($conn);
if ($row) {
return new Bebida($row);
}
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例8: insert
public function insert()
{
$conn = parent::connect();
$sql = "INSERT INTO cliente (email, pass, nombre, apellidos, telefono) \n VALUES (:email, SHA(:pass), :nombre, :apellidos, :telefono)";
try {
$st = $conn->prepare($sql);
$st->bindValue(":email", $this->data["email"], PDO::PARAM_STR);
$st->bindValue(":pass", $this->data["pass"], PDO::PARAM_STR);
$st->bindValue(":nombre", $this->data["nombre"], PDO::PARAM_STR);
$st->bindValue(":apellidos", $this->data["apellidos"], PDO::PARAM_STR);
$st->bindValue(":telefono", $this->data["telefono"], PDO::PARAM_STR);
$st->execute();
parent::disconnect($conn);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例9: getBebidas
public static function getBebidas()
{
$conn = parent::connect();
$sql = "SELECT * FROM tipos_bebidas;";
try {
$st = $conn->prepare($sql);
$st->execute();
$tipos = array();
foreach ($st->fetchAll() as $row) {
$tipos[] = new Tipo($row);
}
$row = $st->fetch();
parent::disconnect($conn);
return array($tipos);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例10: getLogEntries
public static function getLogEntries($memberId)
{
$conn = parent::connect();
$sql = "SELECT * FROM " . TBL_ACCESS_LOG . " WHERE memberId = :memberId ORDER BY lastAccess DESC";
try {
$st = $conn->prepare($sql);
$st->bindValue(":memberId", $memberId, PDO::PARAM_INT);
$st->execute();
$logEntries = array();
foreach ($st->fetchAll() as $row) {
$logEntries[] = new LogEntry($row);
}
parent::disconnect($conn);
return $logEntries;
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例11: authenticate
public static function authenticate(array $data)
{
$pdo = parent::connect();
if ($data['email'] != '') {
$attr = 'email';
} elseif ($data['username'] != '') {
$attr = 'username';
}
$pass = hash_hmac('SHA256', $data['pass'], User::SALT);
$table = TBL_USERS;
$q = "SELECT id, username, userType, email, pass, dateAdded FROM {$table} WHERE {$attr}=:attr AND pass=:pass";
$stmt = $pdo->prepare($q);
$stmt->execute(array(':attr' => $data[$attr], ':pass' => $pass));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
parent::disconnect($pdo);
if ($row) {
return new User($row);
}
}
示例12: record
public function record()
{
$conn = parent::connect();
$sql = "SELECT * FROM " . TBL_MESSAGE . " ";
$sql .= "WHERE member_id = :member_id and message_text = :message_text and subject = :subject";
try {
$st = $conn->prepare($sql);
$st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT);
$st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR);
$st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR);
$st->execute();
// var_dump($sql, $this->data, $st);
if ($st->fetch()) {
$sql = "UPDATE " . TBL_MESSAGE . " SET num_access = num_access + 1 ";
$sql .= "WHERE member_id = :member_id and message_text = :message_text and subject = :subject";
$st = $conn->prepare($sql);
$st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT);
$st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR);
$st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR);
// var_dump($sql, $st);
$st->execute();
} else {
$sql = "INSERT INTO " . TBL_MESSAGE . " ( member_id, message_text, num_access, subject ) ";
$sql .= " VALUES ( :member_id, :message_text, 1, :subject )";
$st = $conn->prepare($sql);
$st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT);
$st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR);
$st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR);
// var_dump($sql, $st);
$st->execute();
}
// var_dump($sql, $st);
parent::disconnect($conn);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例13: getTravelAdvisories
public function getTravelAdvisories()
{
$connection = parent::connect();
$selectSQL = "SELECT * FROM TRAVELADVISORY";
$rows = $connection->query($selectSQL);
$traveladvisories = array();
foreach ($rows as $row) {
$traveladvisory = new traveladvisory();
$traveladvisory->setTravelAdvisoryId($row[0]);
$traveladvisory->setTravelAdvisorySourceName($row[1]);
$traveladvisory->setTravelAdvisorySourceLink($row[2]);
$traveladvisory->setTravelAdvisorySourceLinkType($row[3]);
$traveladvisories[] = $traveladvisory;
}
parent::disconnect($connection);
return $traveladvisories;
}
示例14: insert
public function insert()
{
$conn = parent::connect();
$sql = "INSERT INTO pedidos (id_cliente, fecha, hora, cp, direccion, comensales) \nVALUES (:id_cliente, STR_TO_DATE(:fecha,'%d/%m/%Y'), :hora, :cp, :direccion, :comensales);";
try {
$st = $conn->prepare($sql);
$st->bindValue(":id_cliente", $this->data["id_cliente"], PDO::PARAM_INT);
$st->bindValue(":fecha", $this->data["fecha"], PDO::PARAM_STR);
$st->bindValue(":hora", $this->data["hora"], PDO::PARAM_STR);
$st->bindValue(":cp", $this->data["cp"], PDO::PARAM_INT);
$st->bindValue(":direccion", $this->data["direccion"], PDO::PARAM_STR);
$st->bindValue(":comensales", $this->data["comensales"], PDO::PARAM_INT);
$st->execute();
parent::disconnect($conn);
} catch (PDOException $e) {
parent::disconnect($conn);
die("Query failed: " . $e->getMessage());
}
}
示例15: getEvents
public function getEvents()
{
$connection = parent::connect();
$selectSQL = "SELECT * FROM EVENT";
$rows = $connection->query($selectSQL);
$events = array();
foreach ($rows as $row) {
$event = new Event();
$event->setEventId($row[0]);
$event->setEventType($row[1]);
$event->setEventSourceName($row[2]);
$event->setEventSourceLink($row[3]);
$event->setEventSourceLinkType($row[4]);
$events[] = $event;
}
parent::disconnect($connection);
return $events;
}