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


PHP DBLayer::insert方法代码示例

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


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

示例1: createTicketUser

 /**
  * create a new ticket user.
  * @param $extern_id the id of the user account in the www version (drupal,...)
  * @param $permission the permission that will be given to the user. 1=user, 2=mod, 3=admin
  */
 public static function createTicketUser($extern_id, $permission)
 {
     try {
         //make connection with and put into db
         $dbl = new DBLayer("lib");
         $dbl->insert("ticket_user", array('TUserId' => $extern_id, 'Permission' => $permission, 'ExternId' => $extern_id));
     } catch (PDOException $e) {
         //oh noooz...
         //error_log(print_r($e, true));
         //print_r($e);
         echo "Problem creating user in database!";
     }
 }
开发者ID:ryzom,项目名称:ryzomcore,代码行数:18,代码来源:ticket_user.php

示例2: send_mail

 /**
  * send mail function that will add the email to the db.
  * this function is being used by the send_ticketing_mail() function. It adds the email as an entry to the `email` table in the database, which will be sent later on when we run the cron job.
  * @param $recipient if integer, then it refers to the id of the user to whom we want to mail, if it's a string(email-address) then we will use that.
  * @param $subject the subject of the email
  * @param $body the body of the email
  * @param $ticket_id the id of the ticket
  * @param $from the sending support_group's id (NULL in case the default group is sending))
  */
 public static function send_mail($recipient, $subject, $body, $ticket_id = 0, $from = NULL)
 {
     $id_user = NULL;
     if (is_numeric($recipient)) {
         $id_user = $recipient;
         $recipient = NULL;
     }
     $db = new DBLayer($db);
     $db->insert("email", array('Recipient' => $recipient, 'Subject' => $subject, 'Body' => $body, 'Status' => 'NEW', 'Attempts' => 0, 'Sender' => $from, 'UserId' => $id_user, 'MessageId' => 0, 'TicketId' => $ticket_id));
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:19,代码来源:mail_handler.php

示例3: create

 /**
  * creates a new 'assigned' entry.
  * this method will use the object's attributes for creating a new 'assigned' entry in the database.
  */
 public function create()
 {
     $dbl = new DBLayer("lib");
     $dbl->insert("`assigned`", array('User' => $this->getUser(), 'Ticket' => $this->getTicket()));
 }
开发者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: setAmsEmail

 /**
  * sets the shards email.
  * in case the shard is offline, the entry will be stored in the ams_querycache.
  * @param $user the usersname of the account of which we want to change the emailaddress.
  * @param $mail the new email address
  * @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
  */
 protected static function setAmsEmail($user, $mail)
 {
     $values = array('Email' => $mail);
     try {
         //make connection with and put into shard db
         $dbs = new DBLayer("shard");
         $dbs->update("user", $values, "Login = '{$user}'");
         return "ok";
     } catch (PDOException $e) {
         //oh noooz, the shard is offline! Put in query queue at ams_lib db!
         try {
             error_log($e);
             $dbl = new DBLayer("lib");
             $dbl->insert("ams_querycache", array("type" => "change_mail", "query" => json_encode(array($user, $mail)), "db" => "shard"));
             return "shardoffline";
         } catch (PDOException $e) {
             return "liboffline";
         }
     }
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:27,代码来源:users.php

示例6: 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

示例7: api_key_management_hook_store_db

/**
 * Hook to store data to database which is sent as post
 * method from the forms in this plugin
 * It also calls the local hook
 */
function api_key_management_hook_store_db()
{
    global $var_set;
    global $API_key_management_return_set;
    // if the form been submited move forward
    if (@hook_validate($_POST['gen_key'])) {
        // local hook to validate the POST variables
        hook_variables();
        // if validation successfull move forward
        if ($API_key_management_return_set['gen_key_validate'] == 'true' && $_GET['plugin_action'] == 'generate_key') {
            // this part generated the access token
            include 'generate_key.php';
            $var_set['AccessToken'] = generate_key::randomToken(56, false, true, false);
            // database connection
            $db = new DBLayer('lib');
            // insert the form data to the database
            $db->insert('ams_api_keys', $var_set);
            // redirect to the the main page with success code
            // 1 refers to the successfull addition of key to the database
            header("Location: index.php?page=layout_plugin&&name=API_key_management&&success=1");
            throw new SystemExit();
        }
    }
}
开发者ID:ryzom,项目名称:ryzomcore,代码行数:29,代码来源:API_key_management.php

示例8: create

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

示例9: createTicketCategory

 /**
  * creates a ticket_Catergory in the DB.   
  * @param $name name we want to give to the new category.
  */
 public static function createTicketCategory($name)
 {
     $dbl = new DBLayer("lib");
     $dbl->insert("ticket_category", array('Name' => $name));
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:9,代码来源:ticket_category.php

示例10: 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

示例11: create

 /**
  * creates a new 'support_group' entry.
  * this method will use the object's attributes for creating a new 'support_group' entry in the database.
  */
 public function create()
 {
     $dbl = new DBLayer("lib");
     $dbl->insert("support_group", array('Name' => $this->getName(), 'Tag' => $this->getTag(), 'GroupEmail' => $this->getGroupEmail(), 'IMAP_MailServer' => $this->getIMAP_MailServer(), 'IMAP_Username' => $this->getIMAP_Username(), 'IMAP_Password' => $this->getIMAP_Password()));
 }
开发者ID:ryzom,项目名称:ryzomcore,代码行数:9,代码来源:support_group.php

示例12: create

 /**
  * creates a new 'ticket_info' entry.
  * this method will use the object's attributes for creating a new 'ticket_info' entry in the database.
  */
 public function create()
 {
     $dbl = new DBLayer("lib");
     $values = array('Ticket' => $this->getTicket(), 'ShardId' => $this->getShardId(), 'UserPosition' => $this->getUser_Position(), 'ViewPosition' => $this->getView_Position(), 'ClientVersion' => $this->getClient_Version(), 'PatchVersion' => $this->getPatch_Version(), 'ServerTick' => $this->getServer_Tick(), 'ConnectState' => $this->getConnect_State(), 'LocalAddress' => $this->getLocal_Address(), 'Memory' => $this->getMemory(), 'OS' => $this->getOS(), 'Processor' => $this->getProcessor(), 'CPUID' => $this->getCPUId(), 'CpuMask' => $this->getCpu_Mask(), 'HT' => $this->getHT(), 'NeL3D' => $this->getNel3D(), 'UserId' => $this->getUser_Id());
     $dbl->insert("ticket_info", $values);
 }
开发者ID:ryzom,项目名称:ryzomcore,代码行数:10,代码来源:ticket_info.php

示例13: createLogEntry

 /**
  * create a new log entry.
  * It will check if the $TICKET_LOGGING global var is true, this var is used to turn logging on and off. In case it's on, the log message will be stored.
  * the action id and argument (which is -1 by default), will be json encoded and stored in the query field in the db.
  * @param $ticket_id the id of the ticket related to the new log entry
  * @param $author_id the id of the user that instantiated the logging.
  * @param $action the action id (see the list in the class description)
  * @param $arg argument for the action (default = -1)
  */
 public static function createLogEntry($ticket_id, $author_id, $action, $arg = -1)
 {
     global $TICKET_LOGGING;
     if ($TICKET_LOGGING) {
         $dbl = new DBLayer("lib");
         $values = array('Query' => json_encode(array($action, $arg)), 'Ticket' => $ticket_id, 'Author' => $author_id);
         $dbl->insert("ticket_log", $values, array('Timestamp' => 'now()'));
     }
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:18,代码来源:ticket_log.php

示例14: create

 /**
  * creates a new 'in_support_group' entry.
  * this method will use the object's attributes for creating a new 'in_support_group' entry in the database.
  */
 public function create()
 {
     $dbl = new DBLayer("lib");
     $dbl->insert("`in_support_group`", array('User' => $this->user, 'Group' => $this->group));
 }
开发者ID:cls1991,项目名称:ryzomcore,代码行数:9,代码来源:in_support_group.php


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