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


PHP DBLayer::delete方法代码示例

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


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

示例1: delete_plugin

/**
 * This function is used in deleting plugins.
 * It removes the plugin from the codebase as well as
 * from the Database. When user request to delete a plugin
 * id of that plugin is sent in $_GET global variable.
 *
 * @author Shubham Meena, mentored by Matthew Lagoe
 */
function delete_plugin()
{
    // if logged in
    if (WebUsers::isLoggedIn()) {
        if (isset($_GET['id'])) {
            // id of plugin to delete after filtering
            $id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
            $db = new DBLayer('lib');
            $sth = $db->selectWithParameter("FileName", "plugins", array('id' => $id), "Id=:id");
            $name = $sth->fetch();
            if (is_dir("{$name['FileName']}")) {
                // removing plugin directory from the code base
                if (Plugincache::rrmdir("{$name['FileName']}")) {
                    $db->delete('plugins', array('id' => $id), "Id=:id");
                    //if result	successfull redirect and show success message
                    header("Cache-Control: max-age=1");
                    header("Location: index.php?page=plugins&result=2");
                    throw new SystemExit();
                } else {
                    // if result unsuccessfull redirect and show error message
                    header("Cache-Control: max-age=1");
                    header("Location: index.php?page=plugins&result=0");
                    throw new SystemExit();
                }
            }
        } else {
            // if result unsuccessfull redirect and show error message
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=plugins&result=0");
            throw new SystemExit();
        }
    }
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:41,代码来源:delete_plugin.php

示例2: update_plugin

/**
 * This function is used in installing updates for plugins.
 * It takes id of the plugin whose update is available using
 * $_GET global variable and then extract the update details
 * from db and then install it in the plugin.
 *
 * @author Shubham Meena, mentored by Matthew Lagoe
 */
function update_plugin()
{
    // if logged in
    if (WebUsers::isLoggedIn()) {
        if (isset($_GET['id'])) {
            // id of plugin to update
            $id = filter_var($_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
            $db = new DBLayer('lib');
            $sth = $db->executeWithoutParams("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id={$id}");
            $row = $sth->fetch();
            // replacing update in the  database
            Plugincache::rrmdir($row['FileName']);
            Plugincache::zipExtraction($row['UpdatePath'], rtrim($row['FileName'], strtolower($row['Name'])));
            $db->update("plugins", array('Info' => $row['UpdateInfo']), "Id={$row['Id']}");
            // deleting the previous update
            $db->delete("updates", array('id' => $row['s.no']), "s.no=:id");
            // if update is installed succesffully redirect to show success message
            header("Cache-Control: max-age=1");
            header("Location: index.php?page=plugins&result=8");
            throw new SystemExit();
        }
    }
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:31,代码来源:update_plugin.php

示例3: delete

 /**
  * deletes an existing 'assigned' entry.
  * this method will use the object's attributes for deleting an existing 'assigned' entry in the database.
  */
 public function delete()
 {
     $dbl = new DBLayer("lib");
     $dbl->delete("`assigned`", array('user_id' => $this->getUser(), 'ticket_id' => $this->getTicket()), "`User` = :user_id and `Ticket` = :ticket_id");
 }
开发者ID:ryzom,项目名称:ryzomcore,代码行数:9,代码来源:assigned.php

示例4: add_Attachment

 /**
  * function that creates a ticket Attachment.
  */
 public static function add_Attachment($TId, $filename, $author, $tempFile)
 {
     global $FILE_STORAGE_PATH;
     $length = mt_rand(20, 25);
     $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*\'(),';
     $randomString = '';
     for ($i = 0; $i < $length; $i++) {
         $randomString .= $characters[rand(0, strlen($characters) - 1)];
     }
     $targetFile = $FILE_STORAGE_PATH . $randomString . "/" . $filename;
     if (file_exists($targetFile)) {
         return self::add_Attachment($TId, $filename, $author, $tempFile);
     }
     $ticket = new Ticket();
     $ticket->load_With_TId($TId);
     //create the attachment!
     try {
         $dbl = new DBLayer("lib");
         $dbl->insert("`ticket_attachments`", array('ticket_TId' => $TId, 'Filename' => $filename, 'Filesize' => filesize($tempFile), 'Uploader' => $author, 'Path' => $randomString . "/" . $filename));
     } catch (Exception $e) {
         return $false;
     }
     mkdir($FILE_STORAGE_PATH . $randomString);
     $return = move_uploaded_file($tempFile, $targetFile);
     if ($return == false) {
         $dbl->delete("`ticket_attachments`", array('Path' => $randomString . "/" . $filename), "`Path` = :Path");
     }
     //write a log entry
     Ticket_Log::createLogEntry($TId, $author, 10);
     return $return;
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:34,代码来源:ticket.php

示例5: checkForUpdate

/**
 * function to check for updates or
 * if the same plugin already exists
 * also, if the update founds ,check for the UpdateInfo in the .info file.
 * Update is saved in the temp directory with pluginName_version.zip
 *
 * @param  $fileName file which is uploaded in .zip extension
 * @param  $findPath where we have to look for the installed plugins
 * @param  $tempFile path for the temporary file
 * @param  $tempPath path where we have to store the update
 * @return 2 if plugin already exists and update not found
 * @return 3 if update info tag not found in .info file
 */
function checkForUpdate($fileName, $findPath, $tempFile, $tempPath)
{
    // check for plugin if exists
    $file = scandir($findPath);
    foreach ($file as $key => $value) {
        if (strcmp($value, $fileName) == 0) {
            if (!file_exists($tempPath . "/test")) {
                mkdir($tempPath . "/test");
            }
            // extracting the update
            if (zipExtraction($tempFile, $tempPath . "/test/")) {
                $result = readPluginFile(".info", $tempPath . "/test/" . $fileName);
                // check for the version for the plugin
                $db = new DBLayer("lib");
                $sth = $db->select("plugins", array('Name' => $result['PluginName']), "Name = :Name");
                $info = $sth->fetch();
                $info['Info'] = json_decode($info['Info']);
                // the two versions from main plugin and the updated part
                $new_version = explode('.', $result['Version']);
                $pre_version = explode('.', $info['Info']->Version);
                // For all plugins we have used semantic versioning
                // Format: X.Y.Z ,X->Major, Y->Minor, Z->Patch
                // change in the X Y & Z values refer the type of change in the plugin.
                // for initial development only Minor an Patch MUST be 0.
                // if there is bug fix then there MUST be an increment in the Z value.
                // if there is change in the functionality or addition of new functionality
                // then there MUST be an increment in the Y value.
                // When there is increment in the X value , Y and Z MUST be 0.
                // comparing if there is some change
                if (!array_diff($new_version, $pre_version)) {
                    // removing the uploaded file
                    Plugincache::rrmdir($tempPath . "/test/" . $fileName);
                    return '2';
                    //plugin already exists
                } else {
                    // check for update info if exists
                    if (!array_key_exists('UpdateInfo', $result)) {
                        return '3';
                        //update info tag not found
                    } else {
                        // check if update already exists
                        if (pluginUpdateExists($info['Id'], $tempPath . "/" . trim($fileName, ".zip") . "_" . $result['Version'] . ".zip")) {
                            echo "Update already exists";
                            throw new SystemExit();
                        } else {
                            // removing the preivous update
                            $dbr = new DBLayer("lib");
                            $dbr->delete("updates", array('id' => $info['Id']), "PluginId=:id");
                            // storing update in the temp directory
                            // format of update save
                            if (move_uploaded_file($tempFile, $tempPath . "/" . trim($fileName, ".zip") . "_" . $result['Version'] . ".zip")) {
                                // setting update information in the database
                                $update['PluginId'] = $info['Id'];
                                $update['UpdatePath'] = $tempPath . "/" . trim($fileName, ".zip") . "_" . $result['Version'] . ".zip";
                                $update['UpdateInfo'] = json_encode($result);
                                $dbr->insert("updates", $update);
                                header("Cache-Control: max-age=1");
                                header("Location: index.php?page=plugins&result=7");
                                throw new SystemExit();
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:80,代码来源:install_plugin.php

示例6: api_key_management_hook_update_db

/**
 * Global Hook to update or delete the data from db
 */
function api_key_management_hook_update_db()
{
    global $var_set;
    global $API_key_management_return_set;
    $db = new DBLayer('lib');
    if (isset($_GET['delete_id'])) {
        // removes the registered key using get variable which contains the id of the registered key
        $db->delete('ams_api_keys', array('SNo' => $_GET['delete_id']), 'SNo = :SNo');
        // redirecting to the API_key_management plugins template with success code
        // 2 refers to the succssfull delete condition
        header("Location: index.php?page=layout_plugin&&name=API_key_management&&success=2");
        throw new SystemExit();
    }
}
开发者ID:ryzom,项目名称:ryzomcore,代码行数:17,代码来源:API_key_management.php

示例7: delete

 /**
  * deletes an existing 'forwarded' entry.
  * this method will use the object's attributes for deleting an existing 'forwarded' entry in the database.
  */
 public function delete()
 {
     $dbl = new DBLayer("lib");
     $dbl->delete("`forwarded`", array('group_id' => $this->getGroup(), 'ticket_id' => $this->getTicket(), "`Group` = :group_id and `Ticket` = :ticket_id"));
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:9,代码来源:forwarded.php

示例8: syncdata

 /**
  * performs the actions listed in the querycache.
  * All entries in the querycache will be read and performed depending on their type.
  * This is done because the shard could have been offline and we want changes made on the website (which is still online) to eventually hit the shard.
  * These changes are: createPermissions, createUser, change_pass, change_mail
  */
 public static function syncdata($display = false)
 {
     if (function_exists('pcntl_fork')) {
         $pid = pcntl_fork();
     }
     global $AMS_TMPDIR;
     $pidfile = $AMS_TMPDIR . '/ams_cron_pid';
     if (isset($pid) and function_exists('pcntl_fork')) {
         // We're the main process.
     } else {
         $pid = getmypid();
         if (Sync::check_for_pid(@file_get_contents($pidfile))) {
             $file = fopen($pidfile, 'w+');
             if (!$file) {
                 echo $pidfile . ' is not writeable.';
                 error_log($pidfile . ' is not writeable.');
                 throw new SystemExit();
             }
             fwrite($file, $pid);
             fclose($file);
             try {
                 $dbl = new DBLayer("lib");
                 $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache");
                 $rows = $statement->fetchAll();
                 foreach ($rows as $record) {
                     $db = new DBLayer($record['db']);
                     switch ($record['type']) {
                         case 'createPermissions':
                             $decode = json_decode($record['query']);
                             $values = array('username' => $decode[0]);
                             //make connection with and put into shard db & delete from the lib
                             $sth = $db->selectWithParameter("UId", "user", $values, "Login= :username");
                             $result = $sth->fetchAll();
                             /*foreach ($result as $UId) {
                                   $ins_values = array('UId' => $UId['UId']);
                                   $ins_values['ClientApplication'] = "r2";
                                   $ins_values['AccessPrivilege'] = "OPEN";
                                   $db->insert("permission", $ins_values);
                                   $ins_values['ClientApplication'] = 'ryzom_open';
                                   $db->insert("permission",$ins_values);
                               }*/
                             // FIXME: GARBAGE
                             break;
                         case 'change_pass':
                             $decode = json_decode($record['query']);
                             $values = array('Password' => $decode[1]);
                             //make connection with and put into shard db & delete from the lib
                             $db->update("user", $values, "Login = '{$decode['0']}'");
                             break;
                         case 'change_mail':
                             $decode = json_decode($record['query']);
                             $values = array('Email' => $decode[1]);
                             //make connection with and put into shard db & delete from the lib
                             $db->update("user", $values, "Login = '{$decode['0']}'");
                             break;
                         case 'createUser':
                             $decode = json_decode($record['query']);
                             $values = array('Login' => $decode[0], 'Password' => $decode[1], 'Email' => $decode[2]);
                             //make connection with and put into shard db & delete from the lib
                             $db->insert("user", $values);
                             break;
                     }
                     $dbl->delete("ams_querycache", array('SID' => $record['SID']), "SID=:SID");
                 }
                 if ($display == true) {
                     print 'Syncing completed';
                 }
             } catch (PDOException $e) {
                 if ($display == true) {
                     print 'Something went wrong! The shard is probably still offline!';
                     print_r($e);
                 }
             }
             unlink($pidfile);
         }
     }
 }
开发者ID:ryzom,项目名称:ryzomcore,代码行数:83,代码来源:sync.php

示例9: delete

 /**
  * deletes an existing 'support_group' entry.
  * this method will use the object's attributes for deleting an existing 'support_group' entry in the database.
  */
 public function delete()
 {
     $dbl = new DBLayer("lib");
     $dbl->delete("`support_group`", array('id' => $this->getSGroupId()), "`SGroupId` = :id");
 }
开发者ID:ryzom,项目名称:ryzomcore,代码行数:9,代码来源:support_group.php

示例10: delete

 /**
  * deletes an existing 'in_support_group' entry.
  * this method will use the object's attributes for deleting an existing 'in_support_group' entry in the database.
  */
 public function delete()
 {
     $dbl = new DBLayer("lib");
     $dbl->delete("`in_support_group`", array('user_id' => $this->getUser(), 'group_id' => $this->getGroup()), "`User` = :user_id and `Group` = :group_id");
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:9,代码来源:in_support_group.php


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