本文整理汇总了PHP中dbExec函数的典型用法代码示例。如果您正苦于以下问题:PHP dbExec函数的具体用法?PHP dbExec怎么用?PHP dbExec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbExec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setvar
function setvar(&$id, $tag, &$val)
{
if (getField("vars", "count(*)", "where uid={$id} and tag='{$tag}'") < 1) {
dbExec("insert into vars (uid, tag, val) values({$id}, '{$tag}', 0)");
}
dbExec("update vars set val={$val} where uid={$id} and tag='{$tag}'");
}
示例2: group_name
function group_name($gid)
{
if (!isset($group_name_cache[$gid])) {
$rs = dbExec("select name from groups where id={$gid} limit 1");
$group_name_cache[$gid] = $rs->fields("name");
}
return $group_name_cache[$gid];
}
示例3: sql2csv
function sql2csv($sql, $pretty_headers = true)
{
$csv = "";
$rs = dbExec($sql);
$quote = array();
$r = "";
$fc = $rs->FieldCount();
for ($i = 0; $i < $fc; $i++) {
if ($i != 0) {
$r .= ",";
}
$fld = $rs->FetchField($i);
$h = $fld->name;
if ($pretty_headers) {
$h = ucwords(str_replace('_', ' ', $fld->name));
}
$h = addslashes($h);
$r .= "\"" . $h . "\"";
$type = $fld->type;
if ($type == "int" || $type == "float") {
$quote[$i] = "";
} else {
$quote[$i] = "\"";
}
}
$csv .= "{$r}\n";
while (!$rs->EOF) {
$r = "";
for ($i = 0; $i < $fc; $i++) {
if ($i != 0) {
$r .= ",";
}
$r .= $quote[$i] . csvesc($rs->fields[$i]) . $quote[$i];
}
$csv .= "{$r}\n";
$rs->MoveNext();
}
return $csv;
}
示例4: insertRecord
function insertRecord($table, $fields, $values)
{
$sql = "insert into {$table} (";
$numf = count($fields);
$numv = count($values);
for ($i = 0; $i < $numf; $i++) {
if ($i != 0) {
$sql .= ", ";
}
$sql .= $fields[$i];
}
$sql .= ") values (";
for ($i = 0; $i < $numv; $i++) {
if ($i != 0) {
$sql .= ", ";
}
$sql .= $values[$i];
}
$sql .= ")";
return dbExec($sql);
}
示例5: intval
$semester = $sy[0];
$md = $semester == 'Fall' ? '0701' : '0101';
$year = intval($sy[1] . $md);
$currDate = intval(date('Ymd'));
$cutoffDate = $currDate - 40000;
if ($year >= $cutoffDate && $year < $currDate) {
echo '<br>' . $year . ' >= ' . $cutoffDate . '<br>';
$statement .= 'update users set ineligible = "Won in ' . $semester . ' ' . $sy[1] . '" where user_type = "s" and (';
foreach ($v as $s) {
$name = $s[0];
$city = $s[1];
$state = $s[2];
echo '<br>Won in ' . $k . ' => ' . $name . ', ' . $city . ', ' . $state . '<br>';
$codes = dbExec('
select distinct code from schools where
name = "' . $name . '" and
city = "' . $city . '" and
state = "' . $state . '"
');
while (!$codes->EOF) {
$o = $codes->FetchNextObj();
$c = $o->code;
echo ' ' . $c;
$statement .= 'school_code = ' . $c . ' or ';
}
}
$statement = substr($statement, 0, -4);
$statement .= ');';
dbExec($statement);
}
}
示例6: dbExec
<?php
} else {
$sql = "select code from schools where city=\"{$school_city}\" and state=\"{$school_state}\" and name=\"{$school_name}\"";
$rs = dbExec($sql);
if ($rs->RecordCount() > 1) {
// xxx this is OK for now - there are multiple entries for many schools, but that's OK.
//fail("unexpected record count: ".$rs->RecordCount());
}
if ($rs->RecordCount() < 1) {
assert(false);
// shouldn't get here right now because all selections are drop-downs - user can't actually enter any data that doesn't already exist in db.
// add school record and generate school code
$school_code = gen_school_code();
$sql = "insert into schools (code, name,city,state,country) values ({$school_code}, \"{$school_name}\", \"{$school_city}\", \"{$school_state}\", \"USA\")";
$rs = dbExec($sql);
dbg("New school added to db with code {$school_code}");
} else {
$school_code = $rs->fields("code");
}
$user_type = "t";
include "teachreg.php";
}
}
}
}
} else {
if ($week > 0) {
?>
Registration for the most recent challenge is now closed.
示例7: dbExec
$td = dbExec("select * from users where user_type='t' and teacher_code={$tc}");
$tn = $td->fields("first_name") . ' ' . $td->fields("last_name");
$te = $td->fields("email");
$tp = $td->fields("phone");
$rst = dbExec("select * from users where group_id={$gid} and active = 1");
while (!$rst->EOF) {
$studentArray[] = $rst->fields("first_name") . ' ' . $rst->fields("last_name");
if ($rst->fields("ineligible") != "") {
$ineligible = $rst->fields("ineligible");
}
$rst->MoveNext();
}
$rst = dbExec("select school_code from users where active=1 and user_type='t' and teacher_code={$tc}");
$sc = $rst->fields("school_code");
if ($sc != "") {
$rst = dbExec("select name,city,state from schools where code={$sc}");
$sn = $rst->fields("name");
$city = $rst->fields("city");
$state = $rst->fields("state");
$rank = $rs->CurrentRow() + 1;
$tid = "tc";
if ($rank <= 20) {
$tid = "top20";
}
$rslt = "";
if ($ineligible == "") {
$rslt = placeStr($winrank);
if ($winrank <= 3) {
$rslt .= "";
$tid = "gold";
?>
示例8: rt
<br>
MAX task set to <?php
echo $w;
?>
<br>
<br>
<?php
} else {
if ($action == "setweekmin") {
$w = (int) rt("w");
$sql = "update config set val={$w} where tag='weekmin'";
dbExec($sql);
$sql = "update users set week={$w} where week < {$w}";
dbExec($sql);
$sql = "update groups set week={$w} where week < {$w}";
dbExec($sql);
getconfig();
?>
<br>
MIN task set to <?php
echo $w;
?>
<br>
<br>
<?php
}
}
}
?>
</div>
示例9: dbExec
$cr = $rs->CurrentRow() - 1;
if (!isset($lastval) || $o->val != $lastval) {
$below = $cr;
$above = $rc - $below - 1;
$bp = $below * 100 / $total;
$ap = 100 - $above * 100 / $total;
$p = ($bp + $ap) / 2;
//$p = floor(($bp + $ap) / 2);
$lastval = $o->val;
$same = 0;
//dbg("val=".$o->val." cr=$cr below=$below above=$above bp=$bp ap=$ap p=$p");
} else {
$same++;
//dbg("(val=".$o->val." cr=$cr below=$below above=$above bp=$bp ap=$ap p=$p)");
}
//dbg($o->uid.": ".$o->val." - ".$p);
dbExec("update results set p_uber={$p} where uid=" . $o->uid);
//setvar($o->uid, 'UBER_pcntl', $p);
if ($cr % $j == 0) {
echo $cr . "—";
}
ob_flush();
flush();
}
p("Done");
b("updating final scores/ranking for students");
dbExec("update results set p_final=((p_raised+p_uber)/2) where p_final is NULL");
p("Done");
b("Marking Previous Winners");
include "previous_winners.php";
b("<br>SCORING COMPLETE");
示例10: deleteRecord
function deleteRecord($id)
{
dbExec("DELETE FROM list WHERE id={$id}");
}
示例11: array
<tr>
<td class=sutdh > Since </td>
<td class=sutdh > Records </td>
<td class=sutdh > Green </td>
<td class=sutdh > Yellow </td>
<td class=sutdh > Red </td>
<td class=sutdh > Port 80 </td>
<td class=sutdh > Port 443 </td>
<td class=sutdh > Port 2714 </td>
<td class=sutdh > Port 27140 </td>
</tr>
<?php
//$dates = array("01/01", "09/19", "09/27");
$dates = array("2012-06-01");
foreach ($dates as $dt) {
$rs = dbExec("select\n\t\t\t\t\tcount(*) as c,\n\t\t\t\t\tsum(port_80) as p80,\n\t\t\t\t\tsum(port_443) as p443,\n\t\t\t\t\tsum(port_2714) as p2714,\n\t\t\t\t\tsum(port_27140) as p27140,\n\t\t\t\t\tsum(green) as g,\n\t\t\t\t\tsum(yellow) as y,\n\t\t\t\t\tsum(red) as r\n\t\t\t\t\tfrom hwtest\n\t\t\t\t\twhere stamp >= '{$dt} 00:00:00'\n\t\t\t\t\t");
$o = $rs->FetchNextobj();
if ($o->c > 0) {
$green = (int) ($o->g * 100 / $o->c);
$yellow = (int) ($o->y * 100 / $o->c);
$red = (int) ($o->r * 100 / $o->c);
$p80 = (int) ($o->p80 * 100 / $o->c);
$p443 = (int) ($o->p443 * 100 / $o->c);
$p2714 = (int) ($o->p2714 * 100 / $o->c);
$p27140 = (int) ($o->p27140 * 100 / $o->c);
?>
<tr>
<td class=sutd><?php
echo $dt;
?>
</td>
示例12: getconfig
function getconfig()
{
global $config, $dbg;
if (false) {
$o = cacheGet("vtc.config");
if (!$o) {
//dbg("fetching config ...");
$config = array();
$rs = dbExec("select * from config");
while ($o = $rs->FetchNextObj()) {
$config[$o->tag] = $o->val;
}
cacheSet("vtc.config", $config, 10);
} else {
//dbg("returning cached config ...");
$config = array();
foreach ($o as $k => $v) {
$config[$k] = $v;
}
}
} else {
$config = array();
$rs = dbExec("select * from config");
while ($o = $rs->FetchNextObj()) {
$config[$o->tag] = $o->val;
}
}
//dbg($config);
}
示例13: vrfy
function vrfy($sid, $jp = "", $xm = 30)
{
$rs = dbExec("select * from auth_users where sid=\"{$sid}\"");
if ($rs->RecordCount() == 1) {
dbg("sid freshened: {$sid}");
setcook("sid", $sid, $xm);
// freshen sid
return true;
}
dbg("*** bad sid: {$sid}");
if ($jp != "") {
jmp($jp);
}
return false;
}
示例14: wl
$rc = $rs->RecordCount();
wl("Analyzing {$rc} user records ...");
$found = 0;
$list = array();
while (!$rs->EOF) {
$p = floor($rs->CurrentRow() * 100 / $rc);
if ($rs->CurrentRow() % 100 == 0) {
w("\n{$p}%: ");
}
$on = $rs->FetchNextObj();
//wl($num." [".$p."%]: ".$on->school_code.": ".$on->last_name.", ".$on->first_name);
$rs2 = dbExec("\n\t\tselect\n\t\t\tid,\n\t\t\tfirst_name,\n\t\t\tlast_name,\n\t\t\tteacher_code,\n\t\t\tschool_code,\n\t\t\temail\n\t\tfrom\n\t\t\tusers\n\t\twhere\n\t\t\tschool_code = '" . $on->school_code . "'\n\t\t\tand\n\t\t\tflag3=0\n\t\t\tand\n\t\t\tflag2=1\n\t\t\tand\n\t\t\tlast_name like '%" . $on->last_name . "%'\n\t\t\tand\n\t\t\tfirst_name like '%" . $on->first_name . "%'\n\t");
if ($rs2->RecordCount() > 1) {
$found++;
array_push($list, $on);
dbExec("update users set flag3=1 where id={$on->id}");
w("[" . $on->id . "]");
} else {
//w(".");
}
}
wl("\nfound {$found} possible dupes");
?>
<style>
#x_table {
border-collapse: collapse;
}
#x_head, #x_cell {
padding: 2px 8px 2px 8px;
border: solid 1px #aaa;
}
示例15: move_uploaded_file
<?php
include 'model.php';
$name = 'image';
if (!empty($_FILES)) {
if (isset($_FILES[$name])) {
if (0 == $_FILES[$name]['error']) {
$newFileName = $_FILES[$name]['name'];
$newFilePath = __DIR__ . '/img/' . $_FILES[$name]['name'];
move_uploaded_file($_FILES[$name]['tmp_name'], $newFilePath);
$title = 'Test image';
dbExec("\n INSERT INTO `images`(`title`, `file`)\n VALUES ('{$title}', '{$newFileName}')\n ");
}
}
}
header('Location: /lesson8/index.php');