当前位置: 首页>>代码示例>>PHP>>正文


PHP db_do函数代码示例

本文整理汇总了PHP中db_do函数的典型用法代码示例。如果您正苦于以下问题:PHP db_do函数的具体用法?PHP db_do怎么用?PHP db_do使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_do函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: image_zap

function image_zap($image_id)
{
    $filename = db_getOne("SELECT filename FROM image WHERE id=?", $image_id);
    db_do("DELETE FROM image WHERE id=?", $image_id);
    db_commit();
    unlink(image_path($filename));
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:7,代码来源:image.php

示例2: force_login

function force_login($id)
{
    $_SESSION['user'] = $id;
    $user = User::getUser($id);
    $_SESSION['user_level'] = $user->getTheme();
    ActivityLog::log('login', $user, false, array());
    db_do("INSERT INTO activity_log(user_id, action, whenit) VALUES('" . $user->getID() . "', 'login', NOW())");
    return $user;
}
开发者ID:negativeview,项目名称:Velour-1.5,代码行数:9,代码来源:core.php

示例3: do_split

function do_split($from_ref, $new_from_ref, $split_pubs, $to_ref)
{
    $actions = array();
    if ($new_from_ref != $from_ref) {
        // rename the source journo
        db_do("UPDATE journo SET ref=? WHERE ref=?", $new_from_ref, $from_ref);
        $actions[] = sprintf("Renamed journo %s -> %s", $from_ref, admJournoLink($new_from_ref));
        $from_ref = $new_from_ref;
    }
    $fromj = db_getRow("SELECT id,ref,prettyname,lastname,firstname,status FROM journo WHERE ref=?", $from_ref);
    $toj = db_getRow("SELECT id,ref,prettyname,lastname,firstname,status FROM journo WHERE ref=?", $to_ref);
    if (!$toj) {
        // need to create new journo (just take a copy of 'from' journo)
        $toj = $fromj;
        unset($toj['id']);
        $toj['ref'] = $to_ref;
        journoCreate($toj);
        // TODO: copy journo_alias entries too...
        $actions[] = sprintf("Created new journo: %s", admJournoLink($to_ref));
    }
    // move articles
    $orglist = implode(',', $split_pubs);
    if ($orglist) {
        $sql = <<<EOD
UPDATE journo_attr SET journo_id=?
    WHERE journo_id=? AND article_id IN
        (
        SELECT a.id
            FROM (article a INNER JOIN journo_attr attr ON a.id=attr.article_id)
            WHERE journo_id=? AND a.srcorg IN ({$orglist})
        )
EOD;
        $rows_affected = db_do($sql, $toj['id'], $fromj['id'], $fromj['id']);
        $actions[] = sprintf("reassigned %d articles from %s to %s", $rows_affected, $from_ref, $to_ref);
    }
    // leave all other data attached to from_ journo (links, email etc)
    // Clear the htmlcache for the to and from journos
    db_do("DELETE FROM htmlcache WHERE name=?", 'j' . $fromj['id']);
    db_do("DELETE FROM htmlcache WHERE name=?", 'j' . $toj['id']);
    db_commit();
    return $actions;
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:42,代码来源:journo-split.php

示例4: DisapproveOtherArticle

    case "disapprove_otherarticle":
        DisapproveOtherArticle($journo_id, get_http_var('otherarticle_id'));
        EmitJourno($journo_id);
        break;
    case "update_admin_notes":
        $admin_notes = get_http_var('admin_notes');
        db_do("UPDATE journo SET admin_notes=? WHERE id=?", $admin_notes, $journo_id);
        db_commit();
        EmitActionMsg("Admin notes changed\n");
        EmitJourno($journo_id);
        break;
    case "update_admin_tags":
        $admin_tags = strtolower(get_http_var('admin_tags'));
        $admin_tags = preg_replace("/[^a-z0-9_]/", " ", $admin_tags);
        $admin_tags = preg_replace('/\\s+/', " ", $admin_tags);
        db_do("UPDATE journo SET admin_tags=? WHERE id=?", $admin_tags, $journo_id);
        db_commit();
        EmitActionMsg("Admin tags changed\n");
        EmitJourno($journo_id);
        break;
    default:
        if ($journo_id) {
            EmitJourno($journo_id);
        } else {
            print "<h2>Journalists</h2>\n";
            EmitJournoFilterForm();
        }
        break;
}
admPageFooter();
/********************************/
开发者ID:bcampbell,项目名称:journalisted,代码行数:31,代码来源:journo.php

示例5: perform

 function perform($action)
 {
     if ($action == 'delete') {
         $this->state = 'delete_requested';
     } elseif ($action == 'confirm_delete') {
         //ZAP!
         db_do("DELETE FROM journo_weblink WHERE id=?", $this->id);
         db_commit();
         $this->state = 'deleted';
     } else {
         if ($action == 'edit') {
             $this->state = 'editing';
         } else {
             if ($action == 'update') {
                 // update the db to reflect the changes
                 /*            db_do( "UPDATE journo_other_articles SET url=?, title=?, pubdate=?, publication=? WHERE id=?",
                                 $this->url,
                                 $this->title,
                                 $this->pubdate->format(DateTime::ISO8601),
                                 $this->publication,
                                 $this->id );
                             db_commit();
                 */
                 // back to non-editing mode
                 $this->state = '';
             } else {
                 if ($action == 'approve') {
                     $this->approved = TRUE;
                     db_do("UPDATE journo_weblink SET approved=? WHERE id=?", $this->approved, $this->id);
                     db_commit();
                 } else {
                     if ($action == 'unapprove') {
                         $this->approved = FALSE;
                         db_do("UPDATE journo_weblink SET approved=? WHERE id=?", $this->approved, $this->id);
                         db_commit();
                     }
                 }
             }
         }
     }
 }
开发者ID:bcampbell,项目名称:journalisted,代码行数:41,代码来源:weblink_widget.php

示例6: handle_pingback

function handle_pingback($method, $params, $extra)
{
    list($sourceURI, $targetURI) = $params;
    // fetch the source URI to verify that the source does indeed link to the target
    $html = file_get_contents($sourceURI);
    if ($html === FALSE) {
        CRAPLOG("0x10\n");
        return 0x10;
        // "The source URI does not exist."
    }
    // cheesy conversion to utf-8
    $html = mb_convert_encoding($html, 'UTF-8', mb_detect_encoding($html, 'UTF-8, ISO-8859-1, windows-1252', true));
    $html = html_entity_decode($html, ENT_COMPAT, 'UTF-8');
    if (strpos($html, $targetURI) === FALSE) {
        CRAPLOG("0x11\n");
        return 0x11;
        // "The source URI does not contain a link to the target URI, and so cannot be used as a source."
    }
    // check URL, try and extract journo ref
    $bits = crack_url($targetURI);
    $path = $bits['path'];
    $m = array();
    $ref = null;
    if (preg_match("%([a-zA-Z0-9]+-[-a-zA-Z0-9]+)/?%", $path, $m)) {
        $ref = $m[1];
    }
    if ($ref === null) {
        CRAPLOG("0x21\n");
        return 0x21;
        // "The specified target URI cannot be used as a target."
    }
    // valid journo?
    $journo = db_getRow("SELECT * FROM journo WHERE ref=? AND status='a'", $ref);
    if ($journo === null) {
        CRAPLOG("0x21 (invalid journo)\n");
        return 0x21;
        // "The specified target URI cannot be used as a target."
    }
    // try and extract title to use as description
    $desc = $sourceURI;
    $m = array();
    if (preg_match('!<title>(.*?)</title>!i', $html, $m)) {
        $desc = $m[1];
        $desc = preg_replace('/\\s+/', ' ', $desc);
    }
    // already got this pingback?
    if (db_getOne("SELECT id FROM journo_weblink WHERE journo_id=? AND url=? AND approved=true", $journo['id'], $sourceURI)) {
        CRAPLOG("0x30\n");
        return 0x30;
        // "The pingback has already been registered."
    }
    // OK. time to add it!
    $sql = <<<EOT
INSERT INTO journo_weblink
    (journo_id, url, description, approved, kind, rank)
    VALUES ( ?,?,?,true,'pingback',500)
EOT;
    db_do($sql, $journo['id'], $sourceURI, $desc);
    db_commit();
    CRAPLOG("added.\n");
    return "Ping registered - thanks";
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:62,代码来源:pingback.php

示例7: addUser

function addUser($newUser)
{
    $username = $newUser['username'];
    $domainId = $newUser['domainId'];
    $pass = $newUser['pass'];
    $repPass = $newUser['repPass'];
    $name = $newUser['name'];
    $active = $newUser['active'];
    $errors = array();
    $foundError = FALSE;
    if (!$username) {
        $foundError = TRUE;
        $errors['username'] = 'This field is required';
    }
    if (!$domainId) {
        $foundError = TRUE;
        $errors['domain'] = 'This field is required';
    }
    if (!$pass) {
        $foundError = TRUE;
        $errors['password'] = 'This field is required';
    }
    if (!$repPass) {
        $foundError = TRUE;
        $errors['reppassword'] = 'This field is required';
    }
    if (!$active) {
        $foundError = TRUE;
        $errors['active'] = 'This field is required';
    }
    if ($foundError) {
        print json_encode(array('success' => false, 'errors' => $errors));
        return;
    }
    $username = strtolower($username);
    if (!validUserName($username)) {
        $foundError = TRUE;
        $errors['username'] = 'Invalid username';
    }
    $domain = getDomain($domainId);
    if (!$domain) {
        $foundError = TRUE;
        $errors['domain'] = 'Invalid domain';
    }
    if ($foundError) {
        print json_encode(array('success' => false, 'errors' => $errors));
        return;
    }
    $email = $username . '@' . $domain;
    $errors = array();
    $foundError = FALSE;
    if (userExists($email) || localForwardExists($email)) {
        $foundError = TRUE;
        $errors['username'] = 'Username already exists';
    }
    if (strlen($pass) < 8) {
        $foundError = TRUE;
        $errors['password'] = 'Password must be at least 8 characters long';
    }
    if ($pass != $repPass) {
        $foundError = TRUE;
        $errors['reppassword'] = 'Passwords do not match';
    }
    $adminDomains = getAdminDomains();
    if (!in_array($domain, $adminDomains)) {
        $foundError = TRUE;
        $errors['domain'] = 'Permission denied on domain: ' . $domain;
    }
    // TODO add password complexity requirements here
    if ($foundError) {
        print json_encode(array('success' => false, 'errors' => $errors));
        return;
    }
    if (!$name) {
        $name = '';
    }
    if ($active == 'true') {
        $active = 't';
    } else {
        $active = 'f';
    }
    $sql = 'INSERT INTO virtual_users (' . '    username,' . '    domain_id,' . '    password,' . '    role_id,' . '    description,' . '    active' . '  ) VALUES (?, ?, CRYPT(?, GEN_SALT(\'bf\', 8)), ?, ?, ?)';
    $params = array($username, $domainId, $pass, getRoleId('user'), $name, $active);
    beginTransaction();
    $rs = db_do($sql, $params);
    if (!$rs) {
        cancelTransaction();
        print json_encode(array('success' => false, 'errors' => array('username' => 'Unknown Error')));
        return;
    }
    $userId = getUserId($email);
    if (!$userId) {
        cancelTransaction();
        print json_encode(array('success' => false, 'errors' => array('username' => 'Unknown Error')));
        return;
    }
    $alias = array('username' => $username, 'domain_id' => $domainId, 'destination' => $email, 'active' => $active);
    $aliasId = db_insert('virtual_aliases', $alias, 'alias_id');
    if (!$aliasId) {
        cancelTransaction();
//.........这里部分代码省略.........
开发者ID:rubixconsulting,项目名称:postfixweb,代码行数:101,代码来源:user.inc.php

示例8: json_decode

        /* there is cached data - yay! */
        $data = json_decode($cached_json, true);
        if ($can_edit_page && $journo['modified'] == 't') {
            /* journo is logged in and the page is out of date...
             * update the cached data with some fresh quick-n-nasty data
             * (which covers most of what a journo might be editing via their profile page, say)
             */
            $old_quick_n_nasty = $data['quick_n_nasty'];
            $newdata = journo_collectData($journo, true);
            $data = array_merge($data, $newdata);
            /* if there was non-quick-n-nasty data there, this makes sure it'll still be used in the template */
            $data['quick_n_nasty'] = $old_quick_n_nasty;
            /* store it in the cache for other users to enjoy too :-) */
            $updated_json = json_encode($data);
            db_do("DELETE FROM htmlcache WHERE name=?", $cacheid);
            db_do("INSERT INTO htmlcache (name,content) VALUES(?,?)", $cacheid, $updated_json);
            db_commit();
        }
    }
}
// HACK:
// fields that we've recently added, which might not be in cached versions
if (!array_key_exists('num_alerts', $data)) {
    $data['num_alerts'] = 0;
}
if (!array_key_exists('admired_by', $data)) {
    $data['admired_by'] = array();
}
// some stuff we don't cache:
$data['can_edit_page'] = $can_edit_page;
// recent editing changes (from the eventlog) - would be fine to cache this list, but we'd
开发者ID:bcampbell,项目名称:journalisted,代码行数:31,代码来源:journo.php

示例9: save

 function save()
 {
     db_do("UPDATE article_error SET url=?, reason_code=?, submitted=?, submitted_by=?, article_id=?, expected_journo=? WHERE id=?", $this->url, $this->status, $this->when_submitted, is_null($this->submitted_by) ? null : $this->submitted_by->id, is_null($this->article) ? null : $this->article->id, is_null($this->expected_journo) ? null : $this->expected_journo->id, $this->id);
 }
开发者ID:bcampbell,项目名称:journalisted,代码行数:4,代码来源:submitted_article.php

示例10: handleSubmit

 function handleSubmit()
 {
     $email = get_http_var('email');
     $phone = get_http_var('phone');
     $address = get_http_var('address');
     $twitter = get_http_var('twitter');
     $twitter = preg_replace("/^@+/", "", $twitter);
     // address
     db_do("DELETE FROM journo_address WHERE journo_id=?", $this->journo['id']);
     if ($address) {
         db_do("INSERT INTO journo_address (journo_id,address) VALUES (?,?)", $this->journo['id'], $address);
     }
     // phone
     db_do("DELETE FROM journo_phone WHERE journo_id=?", $this->journo['id']);
     if ($phone) {
         db_do("INSERT INTO journo_phone (journo_id,phone_number) VALUES (?,?)", $this->journo['id'], $phone);
     }
     // email
     db_do("DELETE FROM journo_email WHERE journo_id=? AND srctype=''", $this->journo['id']);
     if ($email) {
         db_do("INSERT INTO journo_email (journo_id,email,srctype,srcurl,approved) VALUES (?,?,?,?,?)", $this->journo['id'], $email, '', '', TRUE);
     }
     // twitter
     db_do("DELETE FROM journo_weblink WHERE journo_id=? AND kind='twitter'", $this->journo['id']);
     if ($twitter) {
         $twitter_url = 'http://twitter.com/' . $twitter;
         $twitter_desc = $this->journo['prettyname'] . ' on Twitter';
         db_do("INSERT INTO journo_weblink (journo_id,url,description,approved,kind) VALUES (?,?,?,true,'twitter')", $this->journo['id'], $twitter_url, $twitter_desc);
     }
     db_commit();
     eventlog_Add('modify-contact', $this->journo['id']);
 }
开发者ID:bcampbell,项目名称:journalisted,代码行数:32,代码来源:profile_contact.php

示例11: genericStoreItem

 function genericStoreItem($tablename, $fieldnames, &$item)
 {
     if ($item['id']) {
         /* update existing entry */
         $frags = array();
         $params = array();
         foreach ($fieldnames as $f) {
             $frags[] = "{$f}=?";
             $params[] = $item[$f];
         }
         /* note, restrict by journo id to stop people hijacking others entries! */
         $sql = "UPDATE {$tablename} SET " . implode(',', $frags) . " WHERE id=? AND journo_id=?";
         $params[] = $item['id'];
         $params[] = $this->journo['id'];
         db_do($sql, $params);
         eventlog_Add("modify-{$this->pageName}", $this->journo['id'], $item);
     } else {
         /* insert new entry */
         $frags = array('?');
         $params = array($this->journo['id']);
         foreach ($fieldnames as $f) {
             $frags[] = "?";
             $params[] = $item[$f];
         }
         $sql = "INSERT INTO {$tablename} (journo_id," . implode(",", $fieldnames) . ") " . "VALUES (" . implode(',', $frags) . ")";
         db_do($sql, $params);
         $item['id'] = db_getOne("SELECT lastval()");
         eventlog_Add("add-{$this->pageName}", $this->journo['id'], $item);
     }
     db_commit();
     return $item['id'];
 }
开发者ID:bcampbell,项目名称:journalisted,代码行数:32,代码来源:editprofilepage.php

示例12: do_reallychangeemail

function do_reallychangeemail()
{
    $person_id = get_http_var("person_id");
    $person = db_getRow("SELECT * FROM person WHERE id=?", get_http_var('person_id'));
    $old_email = $person['email'];
    $new_email = get_http_var("new_email");
    db_do("UPDATE person SET email=? WHERE id=?", $new_email, $person_id);
    db_commit();
    ?>
<div class="action_summary">
Changed email address<br/>from: <code><?php 
    echo $old_email;
    ?>
<br/></code> to: <code><?php 
    echo $new_email;
    ?>
</code>
</div>
<?php 
    emit_details($person_id);
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:21,代码来源:useraccounts.php

示例13: save

 function save()
 {
     // NOTE: expects member fk objects to already have been saved
     if ($this->pk()) {
         // update existing entry
         $frags = array();
         $params = array();
         foreach ($this->fields as $f => $def) {
             if (!$def['pk']) {
                 switch ($def['type']) {
                     case 'fk':
                         $frags[] = "{$f}=?";
                         $params[] = is_null($this->{$f}) ? null : $this->{$f}->pk();
                         break;
                     case 'datetime':
                         $frags[] = "{$f}=?";
                         $params[] = $this->{$f} ? $this->{$f} : null;
                         break;
                     default:
                         $frags[] = "{$f}=?";
                         $params[] = $this->{$f};
                         break;
                 }
             }
         }
         $sql = "UPDATE {$this->table} SET " . implode(',', $frags) . " WHERE id=?";
         $params[] = $this->{$this->pk};
         db_do($sql, $params);
         //           eventlog_Add( "modify-{$this->pageName}", $this->journo['id'], $item );
     } else {
         /* insert new entry */
         $frags = array();
         $params = array();
         $insert_fields = array();
         foreach ($this->fields as $f => $def) {
             if (!$def['pk']) {
                 switch ($def['type']) {
                     case 'fk':
                         $insert_fields[] = $f;
                         $frags[] = "?";
                         $params[] = is_null($this->{$f}) ? null : $this->{$f}->pk();
                         break;
                     case 'datetime':
                         $insert_fields[] = $f;
                         $frags[] = "?";
                         $params[] = $this->{$f} ? $this->{$f} : null;
                         break;
                     default:
                         $insert_fields[] = $f;
                         $frags[] = "?";
                         $params[] = $this->{$f};
                         break;
                 }
             }
         }
         $sql = "INSERT INTO {$this->table} (" . implode(",", $insert_fields) . ") " . "VALUES (" . implode(',', $frags) . ")";
         //print $sql;
         db_do($sql, $params);
         $this->{$this->pk} = db_getOne("SELECT lastval()");
         //            eventlog_Add( "add-{$this->pageName}", $this->journo['id'], $item );
     }
     db_commit();
 }
开发者ID:bcampbell,项目名称:journalisted,代码行数:63,代码来源:jlmodel.php

示例14: SetActions

function SetActions($srcids, $val)
{
    $sqlbits = array();
    $sqlparams = array($val);
    foreach ($srcids as $id) {
        $sqlbits[] = '?';
        $sqlparams[] = $id;
    }
    $sql = "UPDATE error_articlescrape SET action=? WHERE srcid IN (" . implode(',', $sqlbits) . ")";
    $cnt = db_do($sql, $sqlparams);
    db_commit();
    printf("<div class=\"action_summary\">set %d articles to '%s'</div><br />\n", $cnt, $val == 's' ? 'skip' : 'undecided');
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:13,代码来源:scrape-errors.php

示例15: create_journo

    function create_journo($params)
    {
        $f = substr(metaphone($params['firstname']), 0, 4);
        $l = substr(metaphone($params['lastname']), 0, 4);
        if (!$f) {
            $f = '';
        }
        if (!$l) {
            $l = '';
        }
        db_do("INSERT INTO journo (ref,prettyname,firstname,lastname,status,firstname_metaphone, lastname_metaphone,created) VALUES (?,?,?,?,?,?,?,NOW())", $params['ref'], $params['prettyname'], $params['firstname'], $params['lastname'], 'a', $f, $l);
        db_commit();
        ?>
        <p>Created new journo: <a href="/<?php 
        echo $params['ref'];
        ?>
"><?php 
        echo $params['ref'];
        ?>
</a>
            [<a href="/adm/<?php 
        echo $params['ref'];
        ?>
">admin page</a>]</p>
<?php 
    }
开发者ID:bcampbell,项目名称:journalisted,代码行数:26,代码来源:journo-create.php


注:本文中的db_do函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。