本文整理汇总了PHP中DbManager::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP DbManager::execute方法的具体用法?PHP DbManager::execute怎么用?PHP DbManager::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbManager
的用法示例。
在下文中一共展示了DbManager::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetMappedLicenseRefView
public function testGetMappedLicenseRefView()
{
$this->testDb = new TestPgDb();
$this->testDb->createPlainTables(array('license_ref', 'license_map'));
$this->dbManager = $this->testDb->getDbManager();
$this->dbManager->queryOnce("CREATE TABLE license_candidate (group_fk integer) INHERITS (license_ref)");
$this->dbManager->insertTableRow('license_map', array('license_map_pk' => 0, 'rf_fk' => 2, 'rf_parent' => 1, 'usage' => LicenseMap::CONCLUSION));
$this->dbManager->insertTableRow('license_ref', array('rf_pk' => 1, 'rf_shortname' => 'One', 'rf_fullname' => 'One-1'));
$this->dbManager->insertTableRow('license_ref', array('rf_pk' => 2, 'rf_shortname' => 'Two', 'rf_fullname' => 'Two-2'));
$this->dbManager->insertTableRow('license_candidate', array('rf_pk' => 3, 'rf_shortname' => 'Three', 'rf_fullname' => 'Three-3', 'group_fk' => $this->groupId));
$this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
$view = LicenseMap::getMappedLicenseRefView(LicenseMap::CONCLUSION);
$stmt = __METHOD__;
$this->dbManager->prepare($stmt, $view);
$res = $this->dbManager->execute($stmt);
$map = $this->dbManager->fetchAll($res);
$this->dbManager->freeResult($res);
assertThat($map, is(arrayWithSize(2)));
$expected = array(array('rf_origin' => 1, 'rf_pk' => 1, 'rf_shortname' => 'One', 'rf_fullname' => 'One-1'), array('rf_origin' => 2, 'rf_pk' => 1, 'rf_shortname' => 'One', 'rf_fullname' => 'One-1'));
assertThat($map, containsInAnyOrder($expected));
}
示例2: time
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_FILES['image']['type'] === 'image/jpeg') {
$ext = '.jpg';
} else {
if ($_FILES['image']['type'] === 'image/png') {
$ext = '.png';
}
}
$filepath = DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . "users" . DIRECTORY_SEPARATOR . time() . $ext;
move_uploaded_file($_FILES['image']['tmp_name'], '..' . $filepath);
$db = new DbManager();
$db->execute("INSERT INTO users (name, position_id, contact_number, profile_image_path, user_name, password) VALUES (?, ?, ?, ?, ?, ?);", array($_POST['name'], $_POST['position'], $_POST['contact_number'], $filepath, $_POST['user_name'], $_POST['password']));
}
示例3: addslashes
<?php
session_start();
require "./lib/db.php";
require "./lib/util.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$myusername = addslashes($_POST['username']);
$mypassword = md5(addslashes($_POST['password']));
$db = new DbManager();
$users = $db->execute("SELECT id, full_name FROM users WHERE user_name = ? AND password = ?", array($myusername, $mypassword));
if (count($users) > 0) {
$_SESSION['login_username'] = $myusername;
$_SESSION['login_id'] = $users[0]['id'];
$_SESSION['login_full_name'] = $users[0]['full_name'];
header("location: pages/index.php");
} else {
header("location: index.php");
$_SESSION['error'] = 'Incorrect input';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
示例4: DbManager
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET" && !empty($_POST['id'])) {
$db = new DbManager();
$user = $db->execute("SELECT u.name, p.name, u.contact_number, u.profile_image_path users u INNER JOIN positions p ON p.id = u.position_id WHERE id = ?;", array($_POST['id']));
echo json_encode($user);
}
示例5: DbManager
<?php
include "../includes/header.php";
include "../includes/sidebar.php";
require "../lib/db.php";
require "../lib/util.php";
$db = new DbManager();
$options = $db->execute("SELECT id, genre, name FROM options ORDER BY id ASC", array());
$operators = $db->execute("SELECT id, genre, name FROM operators WHERE genre = 1 ORDER BY id ASC", array());
?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-folder fa-fw"></i> Reports</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="panel panel-primary">
<div class="panel-heading">
Generate Report
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<form class="form-inline">
<div class="form-group">
<select id="option" class="form-control">
<?php
foreach ($options as $i) {
?>
示例6: DbManager
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$db = new DbManager();
$id = $db->execute("INSERT INTO residents (full_name, relationship_id, birth_date, birth_place, civil_status_id, years_of_residency, occupation, citizenship, religion, gender_id, highest_education_attainment_id, deleted) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", array($_POST['full_name'], $_POST['relationship_id'], $_POST['birth_date'], $_POST['birth_place'], $_POST['civil_status_id'], $_POST['years_of_residency'], $_POST['occupation'], $_POST['citizenship'], $_POST['religion'], $_POST['gender_id'], $_POST['highest_education_attainment_id'], 0));
$db->execute("INSERT INTO owner_residents (owner_id, resident_id) VALUES (?, ?);", array($_POST['pk_owner'], $id));
echo $id;
}
示例7: DbManager
<?php
include "includes/header.html";
include "includes/sidebar.html";
require "lib/db.php";
require "lib/util.php";
$db = new DbManager();
if (!empty($_GET['id'])) {
$i = $db->execute("SELECT * FROM residents WHERE id = ?", array($_GET['id']));
}
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$martial_statuses = $db->execute("SELECT id, name FROM martial_statuses ORDER BY id ASC", array());
?>
<div id="page-wrapper">
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Resident Registration
</h1>
</div>
</div>
<!-- /.row -->
<form role="form" method="post" action="registration.php">
<input name="id" type="hidden" value="<?php
echo $_GET['id'];
示例8: DbManager
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$db = new DbManager();
$db->execute("DELETE users WHERE id = ?;", array($_POST['id']));
}
示例9: DbManager
<?php
include "../includes/header.php";
include "../includes/sidebar.php";
require "../lib/db.php";
require "../lib/util.php";
$id = $_GET['id'];
$db = new DbManager();
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$ownerships = $db->execute("SELECT id, name FROM ownerships ORDER BY id ASC", array());
$educations = $db->execute("SELECT id, name FROM educations ORDER BY id ASC", array());
$civil_statuses = $db->execute("SELECT id, name FROM civil_statuses ORDER BY id ASC", array());
$relationships_dependent = $db->execute("SELECT id, name FROM relationships WHERE genre = 1 ORDER BY id ASC", array());
$relationships_boarder = $db->execute("SELECT id, name FROM relationships WHERE genre = 2 ORDER BY id ASC", array());
$house_statuses = $db->execute("SELECT id, name FROM house_statuses ORDER BY id ASC", array());
$owner = $db->execute("SELECT\n o.id\n , o.full_name\n , o.address\n , o.house_number\n , o.birth_date\n , o.birth_place\n , o.citizenship\n , o.religion\n , o.occupation\n , o.years_of_residency\n , os.id AS ownership_id\n , os.name AS ownership_name\n , e.id AS education_id\n , e.name AS education_name\n , c.id AS civil_status_id\n , c.name AS civil_status_name\n , g.id AS gender_id\n , g.name AS gender_name\n , h.id AS house_status_id\n , h.name AS house_status_name\n FROM owners o\n INNER JOIN ownerships os\n ON os.id = o.type_of_ownership_id\n INNER JOIN educations e\n ON e.id = o.highest_education_attainment_id\n INNER JOIN civil_statuses c\n ON c.id = o.civil_status_id\n INNER JOIN genders g\n ON g.id = o.gender_id\n INNER JOIN house_statuses h\n ON h.id = o.house_status_id\n WHERE o.id = ?\n", array($id));
$owner = $owner[0];
$residents = $db->execute("SELECT\n res.id\n , res.full_name\n , res.birth_date\n , res.birth_place\n , res.occupation\n , res.years_of_residency\n , r.id AS relationship_id\n , r.genre AS relationship_genre\n , r.name AS relationship_name\n , e.id AS education_id\n , e.name AS education_name\n , c.id AS civil_status_id\n , c.name AS civil_status_name\n , g.id AS gender_id\n , g.name AS gender_name\n FROM residents res\n INNER JOIN owner_residents ors\n ON ors.resident_id = res.id\n INNER JOIN owners o\n ON o.id = ors.owner_id\n INNER JOIN relationships r\n ON r.id = res.relationship_id\n INNER JOIN educations e\n ON e.id = res.highest_education_attainment_id\n INNER JOIN civil_statuses c\n ON c.id = res.civil_status_id\n INNER JOIN genders g\n ON g.id = res.gender_id\n WHERE o.id = ?\n", array($id));
?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-pencil"></i> Edit House</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<!-- Nav tabs -->
示例10: DbManager
<?php
include "includes/header.html";
include "includes/sidebar.html";
require "lib/db.php";
require "lib/util.php";
$db = new DbManager();
if (!empty($_GET['id'])) {
$i = $db->execute("SELECT id, first_name, middle_name, last_name, suffix, birth_date, TIMESTAMPDIFF(YEAR,birth_date,CURDATE()) AS age, address_line_1, address_line_2, address_line_3, address_line_4, address_line_5, gender_id, martial_status_id, citizenship, contact_number FROM residents WHERE id = ?", array($_GET['id']));
}
$genders = $db->execute("SELECT id, name FROM genders ORDER BY id ASC", array());
$martial_statuses = $db->execute("SELECT id, name FROM martial_statuses ORDER BY id ASC", array());
?>
<div id="page-wrapper">
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Resident Registration
</h1>
</div>
</div>
<!-- /.row -->
<form role="form">
<input name="id" type="hidden" value="<?php
示例11: DbManager
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$db = new DbManager();
$db->execute("UPDATE residents SET\n full_name = ?\n , birth_date = ?\n , birth_place = ?\n , years_of_residency = ?\n , occupation = ?\n , citizenship = ?\n , religion = ?\n , relationship_id = ?\n , highest_education_attainment_id = ?\n , civil_status_id = ?\n , gender_id = ?\n , status_id = ?\n WHERE id = ?;\n ", array($_POST['full_name'], $_POST['birth_date'], $_POST['birth_place'], $_POST['years_of_residency'], $_POST['occupation'], $_POST['citizenship'], $_POST['religion'], $_POST['relationship_id'], $_POST['highest_education_attainment_id'], $_POST['civil_status_id'], $_POST['gender_id'], $_POST['status_id'], $_POST['resident_id']));
}
示例12: DbManager
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$db = new DbManager();
$operators = $db->execute("SELECT\n opr.id AS id\n , opr.name AS name\n FROM options opt\n INNER JOIN operators opr\n ON opr.genre = opt.genre OR opr.genre = 1\n WHERE opt.id = ?\n ORDER BY opr.id ASC;\n ", array($_GET['option_id']));
$r = '';
foreach ($operators as $k => $v) {
$r = $r . '<option value="' . $v['id'] . '">' . $v['name'] . ' </option>';
}
echo $r;
}
示例13: DbManager
<?php
require "../lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$db = new DbManager();
$residents = $db->execute("SELECT\n res.id\n , res.full_name\n , rel.name AS rel_name\n , gen.name AS gen_name\n , res.birth_date\n , res.birth_place\n , civ.name AS civ_name\n , res.years_of_residency\n , res.occupation\n , edu.name AS edu_name\n FROM residents res\n LEFT OUTER JOIN relationships rel\n ON rel.id = res.relationship_id\n LEFT OUTER JOIN genders gen\n ON gen.id = res.gender_id\n LEFT OUTER JOIN civil_statuses civ\n ON civ.id = res.civil_status_id\n LEFT OUTER JOIN educations edu\n ON edu.id = res.highest_education_attainment_id\n LEFT OUTER JOIN owner_residents ors\n ON ors.resident_id = res.id\n WHERE ors.owner_id = ? AND rel.genre = ?\n ORDER BY res.id ASC;\n ", array($_GET['pk_owner'], $_GET['genre']));
$r = '<tr><th></th><th>Full Name</th><th>Relationship</th><th>Gender</th><th>Birth Date</th><th>Birth Place</th><th>Civil Status</th><th>Years of Residency</th><th>Occupation</th><th>Highest Education Attainment</th></tr>';
foreach ($residents as $k => $v) {
$r = $r . '<tr>';
foreach ($v as $k2 => $v2) {
if (isset($_GET['edit']) && $k2 === 'id') {
$r = $r . '<td><button value="' . $v2 . '" style="float:right" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-remove"></span> </button></td>';
} else {
if ($k2 !== 'id') {
$r = $r . '<td>' . $v2 . ' </td>';
}
}
}
$r = $r . '</tr>';
}
echo $r;
}
示例14: DbManager
<?php
require $_SERVER['DOCUMENT_ROOT'] . "/lib/db.php";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$db = new DbManager();
if (empty($_POST['pk_owner'])) {
$id = $db->execute("INSERT INTO owners (house_number, type_of_ownership_id, full_name, address, birth_date, birth_place, citizenship, religion, highest_education_attainment_id, years_of_residency, civil_status_id, occupation, gender_id, deleted) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", array($_POST['house_number'], $_POST['type_of_ownership_id'], $_POST['full_name'], $_POST['address'], $_POST['birth_date'], $_POST['birth_place'], $_POST['citizenship'], $_POST['religion'], $_POST['highest_education_attainment_id'], $_POST['years_of_residency'], $_POST['civil_status_id'], $_POST['occupation'], $_POST['gender_id'], 0));
echo $id;
} else {
$id = $db->execute("UPDATE owners SET house_number = ?, type_of_ownership_id = ?, full_name = ?, address = ?, birth_date = ?, birth_place = ?, citizenship = ?, religion = ?, highest_education_attainment_id = ?, years_of_residency = ?, civil_status_id = ?, occupation = ?, gender_id = ? WHERE id = ?;", array($_POST['house_number'], $_POST['type_of_ownership_id'], $_POST['full_name'], $_POST['address'], $_POST['birth_date'], $_POST['birth_place'], $_POST['citizenship'], $_POST['religion'], $_POST['highest_education_attainment_id'], $_POST['years_of_residency'], $_POST['civil_status_id'], $_POST['occupation'], $_POST['gender_id'], $_POST['pk_owner']));
echo $id;
}
}
示例15: DbManager
<?php
include "../includes/header.php";
include "../includes/sidebar.php";
require '../lib/db.php';
if (isset($_POST['id'])) {
$id = $_SESSION['login_id'];
$db = new DbManager();
if ($_POST['password'] == "") {
$query = $db->execute("UPDATE users SET full_name = ? WHERE id = ?", array($_POST['full_name'], $id));
header("location: user_settings.php");
$_SESSION['info'] = 'Successfully updated!';
$_SESSION['login_full_name'] = $_POST['full_name'];
} else {
$query = $db->execute("UPDATE users SET full_name = ?, password = md5(?) WHERE id = ?", array($_POST['full_name'], $_POST['password'], $id));
header("Refresh:0");
$_SESSION['info'] = 'Successfully updated!';
$_SESSION['login_full_name'] = $_POST['full_name'];
}
}
?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-gear fa-fw"></i> User Settings</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-6">