本文整理汇总了PHP中db_getRow函数的典型用法代码示例。如果您正苦于以下问题:PHP db_getRow函数的具体用法?PHP db_getRow怎么用?PHP db_getRow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_getRow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public static function dispatch()
{
$id = get_http_var('id');
$action = get_http_var('action');
$sql = <<<EOT
SELECT m.id,m.journo_id, j.ref, j.prettyname, j.oneliner, m.url, m.submitted, m.reason
FROM missing_articles m LEFT JOIN journo j ON m.journo_id=j.id
WHERE m.id=?;
EOT;
$row = db_getRow($sql, $id);
$w = new MissingArticleWidget($row);
// perform whatever action has been requested
$w->perform($action);
// is request ajax?
$ajax = get_http_var('ajax') ? true : false;
if ($ajax) {
$w->emit_core();
} else {
// not an ajax request, so output a full page
admPageHeader("Missing Article", "MissingArticleWidget::emit_head_js");
print "<h2>Missing article</h2>\n";
$w->emit_full();
admPageFooter();
}
}
示例2: display
function display()
{
$action = get_http_var("action");
if ($action == 'edit') {
$id = get_http_var('id');
$entry = db_getRow("SELECT * FROM journo_awards WHERE journo_id=? AND id=?", $this->journo['id'], $id);
?>
<h2>Edit award</h2>
<?php
$this->showForm($entry);
?>
<a class="remove" href="<?php
echo $this->pagePath;
?>
?ref=<?php
echo $this->journo['ref'];
?>
&remove_id=<?php
echo h($entry['id']);
?>
">Remove this award</a>
<?php
}
if ($action == 'new') {
?>
<h2>Add award</h2>
<?php
$this->showForm(null);
}
}
示例3: fetch_one
public static function fetch_one($id)
{
$sql = <<<EOT
SELECT o.id, o.journo_id, o.url, o.title, o.pubdate, o.publication, o.status, j.ref AS journo_ref, j.prettyname as journo_prettyname
FROM journo_other_articles o
JOIN journo j ON o.journo_id=j.id
WHERE o.id=?
EOT;
return db_getRow($sql, $id);
}
示例4: display
function display()
{
$action = get_http_var("action");
if ($action == 'edit') {
$edu_id = get_http_var('id');
$edu = db_getRow("SELECT * FROM journo_education WHERE journo_id=? AND id=?", $this->journo['id'], $edu_id);
if ($edu['kind'] == 's') {
?>
<h2>Edit education (school)</h2>
<?php
$this->showSchoolForm($edu);
?>
<a class="remove" href="<?php
echo $this->pagePath;
?>
?ref=<?php
echo $this->journo['ref'];
?>
&remove_id=<?php
echo h($edu['id']);
?>
">Remove this school</a>
<?php
} else {
?>
<h2>Edit education (university)</h2>
<?php
$this->showUniForm($edu);
?>
<a class="remove" href="<?php
echo $this->pagePath;
?>
?ref=<?php
echo $this->journo['ref'];
?>
&remove_id=<?php
echo h($edu['id']);
?>
">Remove this university</a>
<?php
}
}
if ($action == 'new_school') {
?>
<h2>Add education (school)</h2>
<?php
$this->showSchoolForm(null);
}
if ($action == 'new_uni') {
?>
<h2>Add education (university)</h2>
<?php
$this->showUniForm(null);
}
}
示例5: display
function display()
{
?>
<h2>Contact Information</h2><?php
$email = db_getRow("SELECT * FROM journo_email WHERE journo_id=? AND approved=true AND srctype='' LIMIT 1", $this->journo['id']);
$phone = db_getRow("SELECT * FROM journo_phone WHERE journo_id=? LIMIT 1", $this->journo['id']);
$address = db_getRow("SELECT * FROM journo_address WHERE journo_id=? LIMIT 1", $this->journo['id']);
$twitter_id = journo_fetchTwitterID($this->journo['id']);
$contact = array('email' => $email, 'phone' => $phone, 'address' => $address, 'twitter' => $twitter_id);
$this->showForm($contact);
}
示例6: __construct
function __construct()
{
$ref = get_http_var('ref');
$this->journo = db_getRow("SELECT * FROM journo WHERE ref=?", $ref);
$r = array('reason_web' => "Edit Journalisted profile for {$this->journo['prettyname']}", 'reason_email' => "Edit Journalisted profile for {$this->journo['prettyname']}", 'reason_email_subject' => "Edit {$this->journo['prettyname']} on Journalisted");
if (get_http_var('ajax')) {
$this->P = person_if_signed_on();
} else {
// if not ajax, it's ok to redirect to login screen
$this->P = person_signon($r);
}
}
示例7: cache_emit
function cache_emit($cacheid, $genfunc = null, $maxage = null)
{
$sql = <<<EOT
SELECT EXTRACT(EPOCH FROM NOW()-gentime) as elapsed, content
\tFROM htmlcache
\tWHERE name=?
EOT;
$valid = false;
$content = '';
$row = db_getRow($sql, $cacheid);
if ($row) {
if ($maxage === null || $row['elapsed'] < $maxage) {
$valid = true;
}
}
if ($valid) {
printf("<!-- cache: '%s' fetched from cache -->\n", $cacheid);
print $row['content'];
printf("<!-- cache: end '%s' -->\n", $cacheid);
} else {
/* if we got this far the cache entry is missing or expired, so
* we want to rebuild it (if we can) */
if ($genfunc) {
/* very first thing - update the gentime to prevent other requests
* trying to regenerate the cache!
* There is still a small window between the SELECT and here where
* another request could sneak in, but it's probably not a big risk
* in practice.
* TODO: look again at getting the SELECT to lock the row!
*/
db_do("UPDATE htmlcache SET gentime=NOW() WHERE name=?", $cacheid);
db_commit();
printf("<!-- cache: '%s' regenerated -->\n", $cacheid);
ob_start();
cache_gen_annotated($cacheid, $genfunc);
$content = ob_get_contents();
ob_flush();
printf("<!-- cache: end '%s' -->\n", $cacheid);
db_do("DELETE FROM htmlcache WHERE name=?", $cacheid);
db_do("INSERT INTO htmlcache (name,content) VALUES(?,?)", $cacheid, $content);
db_commit();
} else {
printf("<!-- cache: '%s' not found. uhoh. -->\n", $cacheid);
}
}
}
示例8: display
function display()
{
$action = get_http_var("action");
if ($action == 'edit') {
$emp_id = get_http_var('id');
$emp = db_getRow("SELECT * FROM journo_employment WHERE journo_id=? AND id=?", $this->journo['id'], $emp_id);
$emp['current'] = $emp['current'] == 't' ? TRUE : FALSE;
if ($emp['kind'] == 'e') {
?>
<h2>Edit employment</h2>
<?php
$this->showEmploymentForm($emp);
}
if ($emp['kind'] == 'f') {
?>
<h2>Edit freelance experience</h2>
<?php
$this->showFreelanceForm($emp);
}
?>
<a class="remove" href="<?php
echo $this->pagePath;
?>
?ref=<?php
echo $this->journo['ref'];
?>
&remove_id=<?php
echo h($emp['id']);
?>
">Remove this experience</a>
<?php
}
if ($action == 'new_employment') {
?>
<h2>Add employment</h2>
<?php
$this->showEmploymentForm(null);
}
if ($action == 'new_freelance') {
?>
<h2>Add freelance experience</h2>
<?php
$this->showFreelanceForm(null);
}
}
示例9: view
function view()
{
$P = person_if_signed_on();
if (is_null($P)) {
// only for logged-in users
header("Location: /");
return;
}
/* they might have multiple profiles, thus option to specify one here */
$ref = strtolower(get_http_var('ref'));
$journo = NULL;
if ($ref) {
$journo = db_getRow("SELECT * FROM journo WHERE ref=?", $ref);
if (!$journo) {
header("HTTP/1.0 404 Not Found");
return;
}
}
if (is_null($journo)) {
// no journo given - if person is logged on, see if they are associated with a journo (or journos)
$editables = db_getAll("SELECT j.* FROM ( journo j INNER JOIN person_permission p ON p.journo_id=j.id) WHERE p.person_id=? AND p.permission='edit'", $P->id());
if (sizeof($editables) == 0) {
header("Location: /");
return;
} elseif (sizeof($editables) > 1) {
/* let user pick which one... */
tmpl_pickjourno($editables);
return;
} else {
// sizeof($editables) == 1
$journo = $editables[0];
// just one journo.
}
}
// is this person allowed to edit this journo?
if (!db_getOne("SELECT id FROM person_permission WHERE person_id=? AND journo_id=? AND permission='edit'", $P->id(), $journo['id'])) {
// nope
$journo = null;
}
if (!is_null($journo)) {
header("Location: /{$journo['ref']}");
} else {
header("Location: /fuck");
}
}
示例10: __construct
function __construct()
{
$this->pageName = "photo";
$this->pageTitle = "Photo";
$this->pagePath = "/profile_photo";
$this->pageParams = array('head_extra_fn' => array(&$this, 'extra_head'));
$this->uploadError = NULL;
parent::__construct();
// fetch the current photo, if any
$sql = <<<EOT
SELECT p.id, p.image_id, p.is_thumbnail, i.width, i.height, i.filename, i.created
FROM (journo_photo p INNER JOIN image i ON i.id=p.image_id )
WHERE p.journo_id=?
LIMIT 1
EOT;
$this->photo = db_getRow($sql, $this->journo['id']);
if (!is_null($this->photo)) {
$this->photo['is_thumbnail'] = $this->photo['is_thumbnail'] == 't' ? TRUE : FALSE;
}
}
示例11: OLD_api_getJourno_invoke
function OLD_api_getJourno_invoke($params)
{
$j = $params['journo'];
if (is_null($j)) {
api_error("missing required parameter: 'journo'");
return;
}
$jfield = is_numeric($j) ? 'id' : 'ref';
$sql = "SELECT id,ref,prettyname,firstname,lastname,oneliner FROM journo WHERE status='a' AND {$jfield}=?";
$r = db_getRow($sql, $j);
if (is_null($r)) {
api_error("No matching journalist found");
return;
}
$journo = array();
foreach (array('id', 'ref', 'prettyname', 'firstname', 'lastname', 'oneliner') as $field) {
$journo[$field] = $r[$field];
}
$output = array('results' => $journo);
api_output($output);
}
示例12: publication_collect
function publication_collect($pub_id)
{
$p = db_getRow("SELECT * FROM organisation WHERE id=?", $pub_id);
if (0) {
/* recent articles */
$arts = db_getAll("SELECT id,title,pubdate,permalink FROM article WHERE srcorg=? ORDER BY pubdate DESC LIMIT 10", $pub_id);
foreach ($arts as &$a) {
article_augment($a);
}
unset($a);
$p['recent_articles'] = $arts;
}
/* principles */
if ($p['sop_url']) {
$p['principles'] = array('name' => $p['sop_name'], 'url' => $p['sop_url']);
} else {
$p['principles'] = null;
}
unset($p['sop_url']);
unset($p['sop_name']);
/* recent journos */
$sql = <<<EOT
SELECT DISTINCT j.ref, j.prettyname, j.lastname FROM
( ( journo j INNER JOIN journo_attr attr ON j.id=attr.journo_id )
INNER JOIN article a ON a.id=attr.article_id)
WHERE a.srcorg=?
AND a.status='a'
AND a.pubdate > NOW() - INTERVAL '1 week'
ORDER BY j.lastname;
EOT;
$journos = db_getAll($sql, $pub_id);
$p['recent_journos'] = $journos;
/* address (vcard adr fields) */
$foo = db_getOne("SELECT adr FROM pub_adr WHERE pub_id=?", $pub_id);
$p['adr'] = $foo ? vcard_parse_adr($foo) : NULL;
/* telephone (assume type='voice' for now) */
$p['tel'] = db_getOne("SELECT phone FROM pub_phone WHERE pub_id=?", $pub_id);
return $p;
}
示例13: view
function view()
{
if (!admCheckAccess()) {
exit;
}
// should return error code?
$j = get_http_var('j');
$j = strtolower($j);
$journo = db_getRow("SELECT id,ref,prettyname,oneliner,status FROM journo WHERE ref=?", $j);
if (is_null($journo)) {
// TODO: 404
return;
}
$sql = <<<EOT
SELECT p.id,p.email,p.name,perm.permission
FROM person p INNER JOIN person_permission perm ON perm.person_id=p.id
WHERE perm.permission='edit' AND perm.journo_id=?
EOT;
$users = db_getAll($sql, $journo['id']);
$journo['arts'] = journo_collectArticles($journo, 5);
$journo['num_arts'] = db_getOne("SELECT COUNT(*) FROM journo_attr WHERE journo_id=?", $journo['id']);
$journo['linked_users'] = $users;
template($journo);
}
示例14: DoRemoveAlert
function DoRemoveAlert($P, $journo_ref)
{
$journo = db_getRow("SELECT id,prettyname FROM journo WHERE ref=?", $journo_ref);
if (!$journo) {
err("bad journalist ref");
}
$url = "/{$journo_ref}";
$journo_id = $journo['id'];
db_query("DELETE FROM alert WHERE journo_id=? AND person_id=?", $journo_id, $P->id);
db_commit();
print "<p class=\"infomessage\"><a href=\"{$url}\">{$journo['prettyname']}</a> was removed from your list.</p>\n";
}
示例15: handleSubmit
function handleSubmit()
{
$admired = $this->entriesFromHTTPVars();
// add ids of journos in the database
foreach ($admired as &$a) {
$a['admired_id'] = null;
if ($a['admired_ref']) {
$foo = db_getRow("SELECT id,prettyname FROM journo WHERE ref=?", $a['admired_ref']);
if ($foo) {
$a['admired_id'] = $foo['id'];
$a['admired_name'] = $foo['prettyname'];
}
}
}
unset($a);
db_do("DELETE FROM journo_admired WHERE journo_id=?", $this->journo['id']);
foreach ($admired as &$a) {
db_do("INSERT INTO journo_admired (journo_id,admired_name,admired_id) VALUES (?,?,?)", $this->journo['id'], $a['admired_name'], $a['admired_id']);
// $id = db_getOne( "SELECT lastval()" );
}
db_commit();
eventlog_Add("modify-admired", $this->journo['id']);
}