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


PHP Database::delete方法代码示例

本文整理汇总了PHP中Database::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::delete方法的具体用法?PHP Database::delete怎么用?PHP Database::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


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

示例1: testDeleteAll

 public function testDeleteAll()
 {
     $users = $this->database->select(User::class);
     $this->database->delete($users);
     $users = $this->database->select(User::class);
     $this->assertEquals(0, count($users));
 }
开发者ID:re222dv,项目名称:1DV408-Project,代码行数:7,代码来源:DatabaseE2E.php

示例2: load

 public function load()
 {
     $db = new Database();
     $db->delete('Users', 'StudentId is not null');
     $db->delete('Students', '1=1');
     $db->select('Settings', 'SrProjectUrl,SrProjectToken');
     $settings = $db->getResult();
     $students = json_decode(file_get_contents($settings['SrProjectUrl'] . '/getAll/' . $settings['SrProjectToken']));
     foreach ($students as $student) {
         $db->insert('Students', array('id' => $student->id, 'Project' => $student->projectTitle, 'Location' => 'TBA'));
         $db->insert('Users', array('Email' => $student->email . '@fiu.edu', 'FirstName' => ucfirst($student->firstName), 'LastName' => ucfirst($student->lastName), 'StudentId' => $student->id, 'Roles' => 'student', 'DefaultRole' => 'student'));
     }
     return true;
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:14,代码来源:Students.php

示例3: deleteEquip

function deleteEquip($id)
{
    $db = new Database();
    $link = $db->connect();
    $result = $db->delete($link, 'equip_type', 'type_id=' . $id);
    return $result;
}
开发者ID:xolodok373,项目名称:tit.biz,代码行数:7,代码来源:record.php

示例4: do_delete

 protected function do_delete($data)
 {
     $user = $this->user;
     $id = $data['id'];
     Database::delete('note', 'id_user = ? and id = ?', array($user, $id));
     return array('success' => true);
 }
开发者ID:4otaku,项目名称:draft,代码行数:7,代码来源:note.php

示例5: remove

 public function remove($id)
 {
     $db = new Database();
     $db->delete('Questions', 'id=' . $id);
     $res = $db->getResult();
     return array('success' => $res[0] === 1);
 }
开发者ID:M7ammed,项目名称:Mobile-Judge-App,代码行数:7,代码来源:Questions.php

示例6: deleteRevs

 /**
  * Delete one or more revisions from the database
  * Do this inside a transaction
  *
  * @param array $id Array of revision id values
  * @param Database $dbw Database class (needs to be a master)
  */
 private function deleteRevs($id, &$dbw)
 {
     if (!is_array($id)) {
         $id = [$id];
     }
     $dbw->delete('revision', ['rev_id' => $id], __METHOD__);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:deleteOrphanedRevisions.php

示例7: updateDependencyList

 /**
  * @since 2.3
  *
  * @param integer $sid
  * @param array $dependencyList
  */
 public function updateDependencyList($sid, array $dependencyList)
 {
     $this->connection->beginAtomicTransaction(__METHOD__);
     // Before an insert, delete all entries that for the criteria which is
     // cheaper then doing an individual upsert or selectRow, this also ensures
     // that entries are self-corrected for dependencies matched
     $this->connection->delete(SMWSQLStore3::QUERY_LINKS_TABLE, array('s_id' => $sid), __METHOD__);
     if ($sid == 0) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     $inserts = array();
     foreach ($dependencyList as $dependency) {
         $oid = $this->getIdForSubject($dependency);
         if ($oid < 1) {
             continue;
         }
         $inserts[$sid . $oid] = array('s_id' => $sid, 'o_id' => $oid);
     }
     if ($inserts === array()) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     // MW's multi-array insert needs a numeric dimensional array but the key
     // was used with a hash to avoid duplicate entries hence the re-copy
     $inserts = array_values($inserts);
     wfDebugLog('smw', __METHOD__ . ' insert for SID ' . $sid . "\n");
     $this->connection->insert(SMWSQLStore3::QUERY_LINKS_TABLE, $inserts, __METHOD__);
     $this->connection->endAtomicTransaction(__METHOD__);
 }
开发者ID:kimcollin,项目名称:SemanticMediaWiki,代码行数:34,代码来源:EmbeddedQueryDependencyLinksStore.php

示例8: updateDependencyList

 /**
  * @since 2.3
  *
  * @param integer $sid
  * @param array $dependencyList
  */
 public function updateDependencyList($sid, array $dependencyList)
 {
     $this->connection->beginAtomicTransaction(__METHOD__);
     // Before an insert, delete all entries that for the criteria which is
     // cheaper then doing an individual upsert or selectRow, this also ensures
     // that entries are self-corrected for dependencies matched
     $this->connection->delete(SMWSQLStore3::QUERY_LINKS_TABLE, array('s_id' => $sid), __METHOD__);
     if ($sid == 0) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     $inserts = array();
     foreach ($dependencyList as $dependency) {
         $oid = $this->getIdForSubject($dependency);
         // If the ID_TABLE didn't contained an valid ID then we create one ourselves
         // to ensure that object entities are tracked from the start
         // This can happen when a query is added with object reference that have not
         // yet been referenced as annotation and therefore do not recognized as
         // value annotation
         if ($oid < 1 && ($oid = $this->tryToMakeIdForSubject($dependency)) < 1) {
             continue;
         }
         $inserts[$sid . $oid] = array('s_id' => $sid, 'o_id' => $oid);
     }
     if ($inserts === array()) {
         return $this->connection->endAtomicTransaction(__METHOD__);
     }
     // MW's multi-array insert needs a numeric dimensional array but the key
     // was used with a hash to avoid duplicate entries hence the re-copy
     $inserts = array_values($inserts);
     wfDebugLog('smw', __METHOD__ . ' insert for SID ' . $sid . "\n");
     $this->connection->insert(SMWSQLStore3::QUERY_LINKS_TABLE, $inserts, __METHOD__);
     $this->connection->endAtomicTransaction(__METHOD__);
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:39,代码来源:EmbeddedQueryDependencyLinksStore.php

示例9: process

 public function process(array $documents, &$context)
 {
     $doc = $documents[self::URL_HISTORY];
     $dom = self::getDOM($doc);
     $xpath = new DOMXPath($dom);
     Database::delete('userhistory', ['user_id' => $context->user->id]);
     $data = [];
     $nodes = $xpath->query('//table//td[@class = \'borderClass\']/..');
     foreach ($nodes as $node) {
         //basic info
         $link = $node->childNodes->item(0)->childNodes->item(0)->getAttribute('href');
         preg_match('/(\\d+)\\/?$/', $link, $matches);
         $media = strpos($link, 'manga') !== false ? Media::Manga : Media::Anime;
         $mediaMalId = intval($matches[0]);
         $progress = Strings::makeInteger($node->childNodes->item(0)->childNodes->item(2)->nodeValue);
         //parse time
         //That's what MAL servers output for MG client
         if (isset($doc->headers['Date'])) {
             date_default_timezone_set('UTC');
             $now = strtotime($doc->headers['Date']);
         } else {
             $now = time();
         }
         date_default_timezone_set('America/Los_Angeles');
         $hour = date('H', $now);
         $minute = date('i', $now);
         $second = date('s', $now);
         $day = date('d', $now);
         $month = date('m', $now);
         $year = date('Y', $now);
         $dateString = $node->childNodes->item(2)->nodeValue;
         if (preg_match('/(\\d*) seconds? ago/', $dateString, $matches)) {
             $second -= intval($matches[1]);
         } elseif (preg_match('/(\\d*) minutes? ago/', $dateString, $matches)) {
             $second -= intval($matches[1]) * 60;
         } elseif (preg_match('/(\\d*) hours? ago/', $dateString, $matches)) {
             $minute -= intval($matches[1]) * 60;
         } elseif (preg_match('/Today, (\\d*):(\\d\\d) (AM|PM)/', $dateString, $matches)) {
             $hour = intval($matches[1]);
             $minute = intval($matches[2]);
             $hour += ($matches[3] == 'PM' and $hour != 12) ? 12 : 0;
         } elseif (preg_match('/Yesterday, (\\d*):(\\d\\d) (AM|PM)/', $dateString, $matches)) {
             $hour = intval($matches[1]);
             $minute = intval($matches[2]);
             $hour += ($matches[3] == 'PM' and $hour != 12) ? 12 : 0;
             $hour -= 24;
         } elseif (preg_match('/(\\d\\d)-(\\d\\d)-(\\d\\d), (\\d*):(\\d\\d) (AM|PM)/', $dateString, $matches)) {
             $year = intval($matches[3]) + 2000;
             $month = intval($matches[1]);
             $day = intval($matches[2]);
             $hour = intval($matches[4]);
             $minute = intval($matches[5]);
             $hour += ($matches[6] == 'PM' and $hour != 12) ? 12 : 0;
         }
         $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
         date_default_timezone_set('UTC');
         $data[] = ['user_id' => $context->user->id, 'mal_id' => $mediaMalId, 'media' => $media, 'progress' => $progress, 'timestamp' => date('Y-m-d H:i:s', $timestamp)];
     }
     Database::insert('userhistory', $data);
 }
开发者ID:BrokenSilence,项目名称:malgraph4,代码行数:60,代码来源:UserSubProcessorHistory.php

示例10: process

 public function process(array $documents, &$context)
 {
     $document = $documents[self::URL_MEDIA];
     $dom = self::getDOM($document);
     $xpath = new DOMXPath($dom);
     Database::delete('mediarelation', ['media_id' => $context->media->id]);
     $data = [];
     foreach ($xpath->query('//table[@class=\'anime_detail_related_anime\']/tr') as $node) {
         $typeMal = strtolower(Strings::removeSpaces($node->childNodes[0]->textContent));
         $type = Strings::makeEnum($typeMal, ['adaptation' => MediaRelation::Adaptation, 'alternative setting' => MediaRelation::AlternativeSetting, 'alternative version' => MediaRelation::AlternativeVersion, 'character' => MediaRelation::Character, 'full story' => MediaRelation::FullStory, 'other' => MediaRelation::Other, 'parent story' => MediaRelation::ParentStory, 'prequel' => MediaRelation::Prequel, 'sequel' => MediaRelation::Sequel, 'side story' => MediaRelation::SideStory, 'spin-off' => MediaRelation::SpinOff, 'summary' => MediaRelation::Summary], null);
         if ($type === null) {
             throw new BadProcessorDocumentException($document, 'unknown relation type: ' . $typeMal);
         }
         $links = $node->childNodes[1]->getElementsByTagName('a');
         foreach ($links as $link) {
             $link = $link->getAttribute('href');
             if (preg_match('#^/(anime|manga)/([0-9]+)/#', $link, $matches)) {
                 $idMal = Strings::makeInteger($matches[2]);
                 if ($matches[1] === 'anime') {
                     $media = Media::Anime;
                 } elseif ($matches[1] === 'manga') {
                     $media = Media::Manga;
                 }
                 $data[] = ['media_id' => $context->media->id, 'mal_id' => $idMal, 'media' => $media, 'type' => $type];
             }
         }
     }
     Database::insert('mediarelation', $data);
     $context->relationData = $data;
 }
开发者ID:Juviette,项目名称:graph,代码行数:30,代码来源:MediaSubProcessorRelations.php

示例11: delete

 /**
  * Delete a named variable value.
  * @param string $name Name of the variable to delete.
  */
 public static function delete($name)
 {
     $db = new Database();
     $db->delete('variables', array('name' => $name));
     $cache = Cache::instance();
     $cache->delete("variable-{$name}");
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:11,代码来源:variable.php

示例12: mergePage

 /**
  * Merge page histories
  *
  * @param integer $id The page_id
  * @param Title $newTitle The new title
  * @return bool
  */
 private function mergePage($row, Title $newTitle)
 {
     $id = $row->page_id;
     // Construct the WikiPage object we will need later, while the
     // page_id still exists. Note that this cannot use makeTitleSafe(),
     // we are deliberately constructing an invalid title.
     $sourceTitle = Title::makeTitle($row->page_namespace, $row->page_title);
     $sourceTitle->resetArticleID($id);
     $wikiPage = new WikiPage($sourceTitle);
     $wikiPage->loadPageData('fromdbmaster');
     $destId = $newTitle->getArticleID();
     $this->beginTransaction($this->db, __METHOD__);
     $this->db->update('revision', ['rev_page' => $destId], ['rev_page' => $id], __METHOD__);
     $this->db->delete('page', ['page_id' => $id], __METHOD__);
     $this->commitTransaction($this->db, __METHOD__);
     /* Call LinksDeletionUpdate to delete outgoing links from the old title,
      * and update category counts.
      *
      * Calling external code with a fake broken Title is a fairly dubious
      * idea. It's necessary because it's quite a lot of code to duplicate,
      * but that also makes it fragile since it would be easy for someone to
      * accidentally introduce an assumption of title validity to the code we
      * are calling.
      */
     DeferredUpdates::addUpdate(new LinksDeletionUpdate($wikiPage));
     DeferredUpdates::doUpdates();
     return true;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:35,代码来源:namespaceDupes.php

示例13: removeVote

 public function removeVote($user)
 {
     if (is_object($user) && is_numeric($user->id)) {
         $user = $user->id;
     }
     foreach ($this->possibilities as $possibility) {
         Database::delete('votes', array('possibility' => $possibility->id, 'user' => $user));
     }
 }
开发者ID:xdidx,项目名称:demago-webservices,代码行数:9,代码来源:Idea.php

示例14: delete

    /**
     * Delete a skill profile
     * @param int $id The skill profile id
     * @return boolean Whether delete a skill profile
     */
    public function delete($id) {
        Database::delete(
            $this->table_rel_profile,
            array(
                'profile_id' => $id
            )
        );

        return parent::delete($id);
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:15,代码来源:skill.lib.php

示例15: onProcessingError

 public function onProcessingError(&$context)
 {
     if ($context->exception instanceof BadProcessorKeyException) {
         Database::delete('userfriend', ['user_id' => $context->user->id]);
         Database::delete('userhistory', ['user_id' => $context->user->id]);
         Database::delete('usermedia', ['user_id' => $context->user->id]);
         Database::delete('user', ['id' => $context->user->id]);
     }
     throw $context->exception;
 }
开发者ID:Lucas8x,项目名称:graph,代码行数:10,代码来源:UserProcessor.php


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