本文整理汇总了PHP中Database::executeQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::executeQuery方法的具体用法?PHP Database::executeQuery怎么用?PHP Database::executeQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::executeQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSave
private function doSave($item, $value, $environment, $group, $namespace = null)
{
$connection = $this->getConnection();
$query = $connection->createQueryBuilder();
if (is_array($value)) {
foreach ($value as $key => $val) {
$key = ($item ? $item . '.' : '') . $key;
$this->doSave($key, $val, $environment, $group, $namespace);
}
return;
}
$query->update('Config', 'c')->set('configValue', $query->expr()->literal($value))->where($query->expr()->comparison('configGroup', '=', $query->expr()->literal($group)));
if ($item) {
$query->andWhere($query->expr()->comparison('configItem', '=', $query->expr()->literal($item)));
}
$query->andWhere($query->expr()->comparison('configNamespace', '=', $query->expr()->literal($namespace ?: '')));
if (!$query->execute()) {
try {
$query = "INSERT INTO Config (configItem, configValue, configGroup, configNamespace) VALUES (?, ?, ?, ?)";
\Database::executeQuery($query, array($item, $value, $group, $namespace ?: ''));
} catch (\Exception $e) {
// This happens when the update succeeded, but didn't actually change anything on the row.
}
}
}
示例2: commit
/**
* Commit current tracking data.
* @param $groupId
*/
public function commit($groupId)
{
$sql = "UPDATE dbtrack_actions SET groupid = :groupid WHERE groupid = 0";
$this->dbms->executeQuery($sql, array('groupid' => $groupId));
// Count new actions.
$count = $this->dbms->getResult('SELECT COALESCE(COUNT(id), 0) AS actions FROM dbtrack_actions WHERE groupid = :groupid', array('groupid' => $groupId));
return $count->actions;
}
示例3: getInstance
public static function getInstance()
{
if (!self::$instance) {
if (!file_exists(DB_DIR . "driver_db")) {
$db = new Database(ROOT_DATABASE);
$db->executeQuery("CREATE DATABASE driver_db");
}
self::$instance = new Database("driver_db");
}
return self::$instance;
}
示例4: getDataFromDb2
public function getDataFromDb2()
{
$db = new Database();
$db->executeQuery("SELECT * FROM cars");
return $db->getAllRows();
// $a = NULL;
// $a = 100;
// if (isset($a)) {
// echo "set";
// } else {
// echo 'not set';
// }
// return $a;
}
示例5: getEntitiesFromList
public function getEntitiesFromList($listId, $return, $offset)
{
// for now, ignoring return & offset - will return all products in list
$query = 'call getProductsByEntityListIdEx(' . $listId . ',' . $this->tenantid . ',' . $offset . ',' . $return . ')';
$data = Database::executeQuery($query);
$entity = '';
if ($data->num_rows == 0) {
return array();
}
while ($r = mysqli_fetch_assoc($data)) {
$entities[] = $r;
}
return $entities;
}
示例6: Yflatfile
public function Yflatfile($url)
{
$url = parse_url($url);
// Decode url-encoded information in the db connection string
$url['path'] = urldecode($url['path']);
//Check if the database exists
$dbname = substr($url['path'], 1);
if (!file_exists(DB_DIR . $dbname)) {
$db = new Database(ROOT_DATABASE);
$create_db_sql = "CREATE DATABASE {$dbname}";
if (!$db->executeQuery($create_db_sql)) {
die(txtdbapi_get_last_error());
}
}
$this->lnk = new Database($dbname);
}
示例7: getAvailableChildren
public function getAvailableChildren($fieldname)
{
if ($fieldname == "pageCollections") {
$query = "select id, name from pageCollection where tenantid=" . $this->tenantid;
$results = Database::executeQuery($query);
if ($results->num_rows == 0) {
return array();
} else {
$entities = array();
while ($r = mysqli_fetch_assoc($results)) {
$entities[] = $r;
}
return $entities;
}
return $results->fetch;
} else {
return parent::getAvailableChildren($fieldname);
}
}
示例8: perform
static function perform()
{
$db = new Database();
$rows = $db->executeQuery("SELECT * FROM MailQueue WHERE sent = 0");
if (is_array($rows) && count($rows) > 0) {
foreach ($rows as $data) {
$result = Emailer::send([$data['senderEmail'] => $data['senderName']], [$data['receiverEmail']], $data['subject'], $data['body']);
if ($result) {
$params = ['id' => $data['id'], 'sent' => 1, 'now' => date('Y-m-d H:i:s')];
$r = $db->executeUpdate("UPDATE MailQueue SET sentAt=:now, sent=:sent WHERE id = :id", $params);
if ($r) {
print "[{$data['subject']}] Email sent to: " . $data['receiverEmail'] . PHP_EOL;
} else {
print "[{$data['subject']}] Failed to send email for: " . $data['receiverEmail'] . PHP_EOL;
}
}
}
}
}
示例9: generateKE_1
public function generateKE_1($elementObj)
{
$db = new Database();
$query = "SELECT `E` FROM `ba_mat` WHERE `rcdNo`=";
if ($elementObj->PK4ba_mat == 2) {
$query .= "22";
} elseif ($elementObj->PK4ba_mat == 0) {
$query .= "23";
}
$dataset = $db->executeQuery($query);
$r = $dataset->fetch_assoc();
$E = $r['E'];
$I = $elementObj->PK4ba_g;
$EI = $E * $I;
$le = $elementObj->getLength();
$v1 = $EI * 12 / pow($le, 3);
$v2 = $EI * 6 / pow($le, 2);
$v3 = $EI * 4 / $le;
$v4 = pow($EI, 2) / $le;
$k_e = array(array($v1, $v2, -$v1, $v2), array($v2, $v3, -$v2, $v4), array(-$v1, -$v2, $v1, -$v2), array($v2, $v4, -$v2, $v3));
return $k_e;
}
示例10: executeQueryReturnArray
public static function executeQueryReturnArray($query)
{
// executes the specified query and returns a multidimensional associative array with the results
$data = Database::executeQuery($query);
$resultSet = array();
while ($row = mysqli_fetch_assoc($data)) {
array_push($resultSet, $row);
}
return $resultSet;
}
示例11: updatepassword
public function updatepassword($pass)
{
$secure_pass = generateHash($pass);
$query = "UPDATE user SET password = " . Database::queryString($secure_pass) . ' WHERE id = ' . Database::queryNumber($this->id);
return Database::executeQuery($query);
}
示例12: Database
<?php
include "./db-api/txt-db-api.php";
$db = new Database("database_EAM");
$a = 0;
$username = $_POST['name'];
$password = $_POST['password'];
$er1 = "    <font color=red>Invalid username/password</font>";
$redirect = "./index.php?er={$er1}";
$rs = $db->executeQuery("SELECT * FROM user;");
//get all rows
while ($rs->next()) {
//read next line
list($usernam, $passwor) = $rs->getCurrentValues();
//do whatever you wish...
if ($username == $usernam && $a != 2) {
$a = 55;
/*exei username apo thn vash user*/
if ($password == $passwor) {
$a = 2;
/*vrhkame ton xrhsth*/
session_start();
/*if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}*/
unset($_SESSION["login_message"]);
$_SESSION["isLoggedIn"] = 1;
$_SESSION["uname"] = $username;
$_SESSION["type"] = "user";
示例13: VALUES
echo " Δώσατε λάθος πόλη. \n<br>";
$a = 1;
}
if (preg_match($regex1, $dieu8unsh)) {
# valid name
} else {
echo " Δώσατε λάθος διεύθυνση. \n<br>";
$a = 1;
}
if (is_numeric($tk)) {
} else {
echo " Δώσατε λάθος ταχυδρομικό κώδικα.\n<br>";
$a = 1;
}
if ($oroi_xrhshs != NULL and $oroi_xrhshs1 != NULL and $sign_up == 'user' and $a != 1) {
$resultset = $db->executeQuery("INSERT INTO user VALUES ('" . $username . "','" . $password . "','" . $ar_taut . "','" . $onoma . "','" . $epitheto . "','" . $nomos . "','" . $polh . "','" . $dieu8unsh . "','" . $tk . "','" . $mail . "') ");
}
if ($oroi_xrhshs != NULL and $oroi_xrhshs1 != NULL and $sign_up == 'doctor' and $a != 1) {
/*$resultset1=$db->executeQuery("SELECT COUNT(*) FROM doctor");
(username, password, ar_taut, onoma, epitheto, nomos, polh, dieu8unsh, tk,email)
(username, password, ar_taut, onoma, epitheto, nomos, polh, dieu8unsh, tk,email, eidikothta, dieu8_iatreiou)
printf("resultset1= %d ",$resultset1);*/
$resultset = $db->executeQuery("INSERT INTO doctor VALUES ('" . $username . "','" . $password . "','" . $ar_taut . "','" . $onoma . "','" . $epitheto . "','" . $nomos . "','" . $polh . "','" . $dieu8unsh . "','" . $tk . "','" . $mail . "','" . $ar_ad . "','" . $eidikothta . "','" . $dieu8_iatreiou . "') ");
}
if ($oroi_xrhshs == NULL || $oroi_xrhshs1 == NULL) {
printf("Δεν έχετε συμφωνήσει με τους όρους χρήσης\n");
$a = 1;
}
if ($a != 1) {
echo "<br/><br/><br/>DOCTORS<br/>";
$rs = $db->executeQuery("SELECT * FROM doctor;");
示例14: Database
include "../_includes/SSDA_librarydatabase.php";
//SSDA_menubar.php has the menu code for da_catalog, da_catalog_fielder(fielder collection) and 'archive reources'
// class for database connections
include "../_classes/class.Database.php";
$query = "select title.StudyNum, title.Title FROM title where title.Restricted <> '*' ORDER BY title.StudyNum";
// sql query statement
// NOTE: original query did not exclude the Restricted items
// $query = "select title.Title, title.StudyNum, shfull.subject, Left(shfull.subject,1) AS firstLetterIndex, count(*) as titlePerSubjectCount FROM (title INNER JOIN shcode ON title.tisort = shcode.tisort) INNER JOIN shfull ON shcode.subjectcode = shfull.subjectcode group by shfull.subject ORDER BY shfull.subject";
// echo "<br>$query<br>";
// class.Database.php is the class to make PDO connections
// initialize new db connection instance
$db = new Database();
// prepare query
$db->prepareQuery($query);
// execute query
$result = $db->executeQuery();
//$result = $db->resultset(); // execute the query
if (!$result) {
die("Could not query the database: <br />");
}
// else { echo "Successfully queried the database.<br>"; } // for debugging
// the index term list
$studynumberList = array();
echo "<form action='da_catalog_titleRecord.php' method='put' name='studynumber' target='_self'>";
echo "<select name='studynumber' class='alphaTitleList'>";
$row_index = 0;
while ($row = $db->getRow()) {
$title = $row['Title'];
$tempStudynumber = $row['StudyNum'];
// code to insure that the studynumbers sort correctly
$numeric_only = preg_replace('/[a-zA-Z]/', '', $tempStudynumber);
示例15: splitSql
$query = $_POST['sql'];
} else {
$query = "SELECT * FROM " . $_GET['tbl'] . " LIMIT " . $_POST['o'] . "," . $_POST['l'];
}
if (stristr($query, "limit")) {
$use_limit = true;
} else {
$use_limit = false;
}
$singleQueries = splitSql($query);
$num_queries = count($singleQueries);
$total = 0;
$tbl_view_rows = "";
for ($j = 0; $j < $num_queries; $j++) {
$localTotal = 0;
$res = $db->executeQuery($singleQueries[$j]);
$phase = "{tablec}";
$tbl_view_cols = "";
$list_colnames = $res->getColumnNames();
$numfields = count($list_colnames);
for ($i = 0; $i < $numfields; $i++) {
$field = $list_colnames[$i];
eval("\$tbl_view_cols .= \"" . gettemplate("table_view_colbit") . "\";");
}
eval("\$tbl_view_rows .= \"" . gettemplate("table_view_start_table") . "\";");
eval("\$tbl_view_rows .= \"" . gettemplate("table_view_rowbit") . "\";");
$phase = "{tablea}";
while ($res->next()) {
$tbl_view_cols = "";
$row = $res->getCurrentValues();
for ($i = 0; $i < count($row); $i++) {