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


PHP connection函数代码示例

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


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

示例1: dumpData

 function dumpData($table, $style, $query)
 {
     if ($_POST["format"] == "json") {
         if ($this->database) {
             echo ",\n";
         } else {
             $this->database = true;
             echo "{\n";
             register_shutdown_function(array($this, '_database'));
         }
         $connection = connection();
         $result = $connection->query($query, 1);
         if ($result) {
             echo '"' . addcslashes($table, "\r\n\"\\") . "\": [\n";
             $first = true;
             while ($row = $result->fetch_assoc()) {
                 echo $first ? "" : ", ";
                 $first = false;
                 foreach ($row as $key => $val) {
                     json_row($key, $val);
                 }
                 json_row("");
             }
             echo "]";
         }
         return true;
     }
 }
开发者ID:ly95,项目名称:adminer,代码行数:28,代码来源:dump-json.php

示例2: join

 public function join($guild_name, $player_name)
 {
     $guild_name = (int) $guild_name;
     $player_name = (int) $player_name;
     $ide = new IDE();
     if (empty($guild_name) or empty($player_name)) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     $ots = POT::getInstance();
     $ots->connect(POT::DB_MYSQL, connection());
     $guild = $ots->createObject('Guild');
     $guild->load($guild_name);
     if (!$guild->isLoaded()) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     $player = new OTS_Player();
     $player->load($player_name);
     if (!$player->isLoaded()) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     if ($player->getAccount()->getId() != $_SESSION['account_id']) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     require_once 'system/application/libraries/POT/InvitesDriver.php';
     new InvitesDriver($guild);
     $invited_list = $guild->listInvites();
     if (!in_array($player->getId(), $invited_list)) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     $guild->acceptInvite($player);
     $ide->redirect(WEBSITE . "/index.php/guilds/view/" . $guild->getId() . "/1");
 }
开发者ID:Alexy234,项目名称:modernaac,代码行数:32,代码来源:guilds.php

示例3: createGuild

 public function createGuild($name, $character)
 {
     $ots = POT::getInstance();
     $ots->connect(POT::DB_MYSQL, connection());
     $player = new OTS_Player();
     $player->load($character);
     $new_guild = new OTS_Guild();
     $new_guild->setCreationData(time());
     $new_guild->setName($name);
     $new_guild->setOwner($player);
     $new_guild->save();
     $new_guild->setCustomField('motd', 'New guild. Leader must edit this text :)');
     $new_guild->setCustomField('creationdata', time());
     $new_guild->setCustomField('world_id', $player->getWorld());
     $ranks = $new_guild->getGuildRanksList();
     $ranks->orderBy('level', POT::ORDER_DESC);
     foreach ($ranks as $rank) {
         if ($rank->getLevel() == 3) {
             $player->setRank($rank);
             $player->save();
         }
     }
     $ide = new IDE();
     $ide->redirect(WEBSITE . "/index.php/guilds/view/" . $new_guild->getId());
     success("{$name} has been created.");
 }
开发者ID:Alexy234,项目名称:modernaac,代码行数:26,代码来源:guilds_model.php

示例4: create

 function create()
 {
     $ide = new IDE();
     if ($ide->isLogged()) {
         $ide->redirect('../account');
     }
     $this->load->helper('form');
     if ($_POST) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('name', 'Account Name', 'required|min_length[4]|max_length[32]|callback__account_exists|alpha');
         $this->form_validation->set_rules('password', 'Password', 'required|matches[repeat]|min_length[4]|max_length[255]');
         $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
         if ($this->form_validation->run() == TRUE) {
             require APPPATH . 'config/ide_default.php';
             $ots = POT::getInstance();
             $ots->connect(POT::DB_MYSQL, connection());
             $account = new OTS_Account();
             $name = $account->createNamed($_POST['name']);
             $account->setPassword($_POST['password']);
             $account->setEmail($_POST['email']);
             $account->setCustomField('premdays', PREMDAYS);
             try {
                 $account->save();
                 $_SESSION['logged'] = 1;
                 $_SESSION['name'] = $_POST['name'];
                 $ide->redirect('../account');
             } catch (Exception $e) {
                 error($e->getMessage());
             }
         }
     }
     #Load view of creating account
     $this->load->view('create');
 }
开发者ID:Alexy234,项目名称:modernaac,代码行数:34,代码来源:account.php

示例5: connection

function connection($conn_id, $ftp_user_name, $ftp_user_pass)
{
    if (ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
        echo "Login was successfull";
    } else {
        echo "Login failed";
        connection($conn_id, $ftp_user_name, $ftp_user_pass);
    }
}
开发者ID:axovel,项目名称:easycarcare,代码行数:9,代码来源:bundle_summer.php

示例6: deleteMod

function deleteMod($id)
{
    $db = connection();
    // tungod wala gi include sa index ang delete.php mao di makita ang conn()
    $sql = "UPDATE agency_user SET status = 'I' WHERE agencyUserId = {$id} ";
    $s = $db->prepare($sql);
    $s->execute();
    $db = null;
}
开发者ID:phDirectory,项目名称:phdirectory,代码行数:9,代码来源:database.php

示例7: run

 /**
  * Executa a exclusão no banco de dados
  * @return boolean
  */
 public function run()
 {
     try {
         $delete = connection()->prepare($this->sql());
         $delete->bindValue(':' . $this->data->getReference(), $this->data->getValue(), $this->data->getType());
         return $delete->execute();
     } catch (\PDOException $exc) {
         echo $exc->getMessage();
     }
 }
开发者ID:fernandopetry,项目名称:pwork,代码行数:14,代码来源:Delete.php

示例8: messageQuery

 function messageQuery($query)
 {
     //! doesn't work with sql.inc.php
     $connection = connection();
     $result = $connection->query('SHOW MASTER STATUS');
     if ($result) {
         restart_session();
         $_SESSION["master"] = $result->fetch_assoc();
     }
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:10,代码来源:master-slave.php

示例9: retrieve_subcategory

function retrieve_subcategory($id)
{
    $db = connection();
    $sql = "select * from sub_category where category_id=?";
    $st = $db->prepare($sql);
    $st->execute(array($id));
    $result = $st->fetchAll();
    return $result;
    $db = null;
}
开发者ID:Rednough,项目名称:Phnompenhapple,代码行数:10,代码来源:ajax_retrieve.php

示例10: selectEmailProcess

 function selectEmailProcess($where, $foreignKeys)
 {
     $connection = connection();
     if ($_POST["email_id"]) {
         $result = $connection->query("SELECT {$this->subject}, {$this->message} FROM {$this->table} WHERE {$this->id} = " . q($_POST["email_id"]));
         $row = $result->fetch_row();
         $_POST["email_subject"] = $row[0];
         $_POST["email_message"] = $row[1];
     }
 }
开发者ID:ly95,项目名称:adminer,代码行数:10,代码来源:email-table.php

示例11: mappedConnection

function mappedConnection($mappedName)
{
    static $configs;
    if (null === $configs) {
        $configs = (include_once APP_DIR . '/config/mapping.php');
    }
    if (array_key_exists($mappedName, $configs)) {
        return connection($configs[$mappedName]);
    }
    return null;
}
开发者ID:Ezaki113,项目名称:expl-3,代码行数:11,代码来源:database.php

示例12: query

function query($query_string)
{
    if (DATABASE_TYPE == "mysql") {
        $query = mysqli_query(connection(), $query_string);
    } elseif (DATABASE_TYPE == "sqlite") {
        $query = sqlite_query(connection(), $query_string);
    } elseif (DATABASE_TYPE == "pgsql") {
        $query = pg_query(connection(), $query_string);
    }
    return $query;
}
开发者ID:Alamantus,项目名称:PHP-App-Base,代码行数:11,代码来源:helpers.php

示例13: echo_all_db_user_data

function echo_all_db_user_data()
{
    connection();
    mysql_query(" SET NAMES 'utf8'");
    $user_name = $_SESSION["user"];
    $result_query = mysql_query("SELECT user_name, mark, date FROM stats WHERE user_name='{$user_name}'");
    $row = mysql_fetch_array($result_query);
    do {
        printf("<p><table id='restab'>\n                                        <tr>\n                                            <td colspan='2'><strong>%s %s</strong></td>\n                                        </tr>\n                                        <tr>\n                                             <td>Оценка:</td>\n                                             <td>%s</td>\n                                        </tr>\n                                        <tr>\n                                            <td>Дата сдачи</td>\n                                            <td>%s</td>\n                                        </tr>\n                 </table></p>", $row['user_name'], $row['id_stat'], $row['mark'], $row['date']);
    } while ($row = mysql_fetch_array($result_query));
}
开发者ID:AntonSh23,项目名称:MyFirstSite,代码行数:11,代码来源:lib.php

示例14: selectAll

function selectAll()
{
    include '../connection.php';
    $mysqli = connection();
    $result = $mysqli->query('SELECT id, ref, des, qte, sa, dim, sdp, ger FROM tableau');
    $tableau = $sql->fetchAll();
    foreach ($tableau as $row) {
        foreach ($row as $fieldname => $field) {
            echo $fieldname . ' => ' . $field . '<br/>';
        }
    }
}
开发者ID:Baraas,项目名称:applicationLogistique,代码行数:12,代码来源:functions.php

示例15: dumpData

 function dumpData($table, $style, $query)
 {
     if ($_POST['format'] == 'php') {
         $connection = connection();
         $result = $connection->query($query, 1);
         if ($result) {
             while ($row = $result->fetch_assoc()) {
                 $this->output[$table][] = $row;
             }
         }
         return true;
     }
 }
开发者ID:ly95,项目名称:adminer,代码行数:13,代码来源:dump-php.php


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