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


PHP DB函数代码示例

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


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

示例1: set

 public function set($key, $value, $process = 'from_admin_interface', $app = 'system')
 {
     $datetime = get_instance()->date->datetime();
     $key = strtolower($key);
     if ($process == 'from_install_interface') {
         $config = $_SESSION['db_datas'];
         $this->db = DB($config, TRUE);
     } else {
         if ($process == "form_admin_interface") {
             $this->db = get_db();
             // Refreshing
         }
     }
     $query = $this->db->where('KEY', $key)->where('USER', '')->get('tendoo_meta');
     // Convert value
     if (is_array($value)) {
         $value = json_encode($value, JSON_FORCE_OBJECT);
     } else {
         if (is_bool($value)) {
             $value = $value === true ? 'true' : 'false';
         }
     }
     // ELSE $value keep his form
     // Conversion ended
     if (count($query->result_array()) > 0) {
         return $this->db->where('KEY', $key)->where('USER', '')->update('tendoo_meta', array('VALUE' => $value, 'APP' => $app, 'DATE' => $datetime));
     } else {
         return $this->db->insert('tendoo_meta', array('KEY' => $key, 'VALUE' => $value, 'APP' => $app, 'DATE' => $datetime));
     }
 }
开发者ID:RodolfoSilva,项目名称:tendoo-cms,代码行数:30,代码来源:Meta.Class.php

示例2: postback

    function postback($VAR)
    {
        # needed for return
        $ret['invoice_id'] = $VAR['option1'];
        $ret['transaction_id'] = $VAR['order_id'];
        $ret['amount'] = $VAR['amount'];
        $ret['currency'] = DEFAULT_CURRENCY;
        # get the processor details:
        $db =& DB();
        $q = "SELECT id,active,plugin_data FROM " . AGILE_DB_PREFIX . "checkout WHERE\n\t\t\t        site_id \t\t= " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t        checkout_plugin\t= " . $db->qstr($this->name);
        $rs = $db->Execute($q);
        while (!$rs->EOF) {
            $ret['checkout_id'] = $rs->fields["id"];
            $do = true;
            $this->cfg = unserialize($rs->fields["plugin_data"]);
            if ($do) {
                include_once PATH_MODULES . 'checkout/checkout.inc.php';
                $checkout = new checkout();
                $checkout->postback($ret);
                echo '<SCRIPT LANGUAGE="JavaScript">
                            window.location="' . $this->success_url . $ret['invoice_id'] . '";
                          </script>';
                return true;
            }
            $rs->MoveNext();
        }
        echo '<SCRIPT LANGUAGE="JavaScript">
                    window.location="' . $this->decline_url . $ret['invoice_id'] . '";
                  </script>';
    }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:30,代码来源:PAYSYSTEMS_PRO.php

示例3: getLogDb

 private function getLogDb()
 {
     if (empty($this->logDb)) {
         $this->logDb = DB('log');
     }
     return $this->logDb;
 }
开发者ID:gtyd,项目名称:jira,代码行数:7,代码来源:DbLog.php

示例4: update_user_feed

function update_user_feed($user_id, $username)
{
    global $bb_cfg;
    $file_path = $bb_cfg['atom']['path'] . '/u/' . floor($user_id / 5000) . '/' . $user_id % 100 . '/' . $user_id . '.atom';
    $sql = "\n\t\tSELECT\n\t\t\tt.topic_id, t.topic_title, t.topic_status,\n\t\t\tu1.username AS first_username,\n\t\t\tp1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,\n\t\t\tp2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,\n\t\t\ttor.size AS tor_size, tor.tor_status\n\t\tFROM      " . BB_TOPICS . " t\n\t\tLEFT JOIN " . BB_USERS . " u1  ON(t.topic_poster = u1.user_id)\n\t\tLEFT JOIN " . BB_POSTS . " p1  ON(t.topic_first_post_id = p1.post_id)\n\t\tLEFT JOIN " . BB_POSTS . " p2  ON(t.topic_last_post_id = p2.post_id)\n\t\tLEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)\n\t\tWHERE t.topic_poster = {$user_id}\n\t\tORDER BY t.topic_last_post_time DESC\n\t\tLIMIT 50\n\t";
    $topics_tmp = DB()->fetch_rowset($sql);
    $topics = array();
    foreach ($topics_tmp as $topic) {
        if (isset($topic['topic_status'])) {
            if ($topic['topic_status'] == TOPIC_MOVED) {
                continue;
            }
        }
        if (isset($topic['tor_status'])) {
            if (isset($bb_cfg['tor_frozen'][$topic['tor_status']])) {
                continue;
            }
        }
        $topics[] = $topic;
    }
    if (!count($topics)) {
        @unlink($file_path);
        return false;
    }
    if (create_atom($file_path, 'u', $user_id, wbr($username), $topics)) {
        return true;
    } else {
        return false;
    }
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:30,代码来源:functions_atom.php

示例5: getLogDb

 private static function getLogDb()
 {
     if (!isset(self::$logDb)) {
         self::$logDb = DB('log');
     }
     return self::$logDb;
 }
开发者ID:gtyd,项目名称:jira,代码行数:7,代码来源:LogMonitor.php

示例6: CORE_database_delete

/**
 * AgileBill - Open Billing Software
 *
 * This body of work is free software; you can redistribute it and/or
 * modify it under the terms of the Open AgileBill License
 * License as published at http://www.agileco.com/agilebill/license1-4.txt
 * 
 * For questions, help, comments, discussion, etc., please join the
 * Agileco community forums at http://forum.agileco.com/ 
 *
 * @link http://www.agileco.com/
 * @copyright 2004-2008 Agileco, LLC.
 * @license http://www.agileco.com/agilebill/license1-4.txt
 * @author Tony Landis <tony@agileco.com> 
 * @package AgileBill
 * @version 1.4.93
 */
function CORE_database_delete($VAR, &$construct, $type)
{
    global $C_debug, $C_translate;
    # set the id
    $id = $construct->table . '_id';
    # generate the full query
    $q = "DELETE FROM\n\t\t\t" . AGILE_DB_PREFIX . "{$construct->table}\n\t\t\tWHERE\n\t\t\tid \t\t= '" . $db->qstr($VAR["id"], get_magic_quotes_gpc()) . "'\n\t\t\tAND\n\t\t\tsite_id = '" . DEFAULT_SITE . "'";
    # execute the query
    $db =& DB();
    $result = $db->Execute($q);
    # Alert
    $C_debug->value["id"] = $VAR[$id];
    $C_debug->value["module_name"] = $C_translate->translate('menu', $construct->module, "");
    $alert = $C_translate->translate('alert_delete_id', "", "");
    $C_debug->alert($alert);
    # error reporting
    if ($result === false) {
        global $C_debug;
        $C_debug->error('database.inc.php', 'delete', $db->ErrorMsg());
        if (isset($construct->trigger["{$type}"])) {
            include_once PATH_CORE . 'trigger.inc.php';
            $trigger = new CORE_trigger();
            $trigger->trigger($construct->trigger["{$type}"], 0, $VAR);
        }
    } else {
        if (isset($construct->trigger["{$type}"])) {
            include_once PATH_CORE . 'trigger.inc.php';
            $trigger = new CORE_trigger();
            $trigger->trigger($construct->trigger["{$type}"], 0, $VAR);
        }
    }
}
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:49,代码来源:database_delete.inc.php

示例7: smarty_block_group

function smarty_block_group($params, $resource, &$smarty)
{
    if (empty($resource)) {
        return;
    }
    @($id = $params["id"]);
    $do = false;
    $db =& DB();
    $sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE
            site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
            status      = ' . $db->qstr('1') . ' AND
            id          = ' . $db->qstr($id);
    @($result = $db->Execute($sql));
    $do = false;
    if (@$result->RecordCount() > 0) {
        global $C_auth;
        @($arr = unserialize($result->fields['group_avail']));
        for ($i = 0; $i < count($arr); $i++) {
            if ($do == false && $C_auth->auth_group_by_id($arr[$i])) {
                $do = true;
            }
        }
    }
    if ($do) {
        echo $resource;
    } else {
        echo @$params["msg"];
    }
}
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:29,代码来源:block.group.php

示例8: list_radio

/**
 * AgileBill - Open Billing Software
 *
 * This body of work is free software; you can redistribute it and/or
 * modify it under the terms of the Open AgileBill License
 * License as published at http://www.agileco.com/agilebill/license1-4.txt
 * 
 * For questions, help, comments, discussion, etc., please join the
 * Agileco community forums at http://forum.agileco.com/ 
 *
 * @link http://www.agileco.com/
 * @copyright 2004-2008 Agileco, LLC.
 * @license http://www.agileco.com/agilebill/license1-4.txt
 * @author Tony Landis <tony@agileco.com> 
 * @package AgileBill
 * @version 1.4.93
 */
function list_radio($input_id, $name, $table, $field, $id, $class)
{
    global $C_translate;
    $db =& DB();
    $sql = "SELECT id, {$field} FROM " . AGILE_DB_PREFIX . "{$table} WHERE site_id = '" . DEFAULT_SITE . "' ORDER BY {$field}";
    $result = $db->Execute($sql);
    if ($result === false) {
        global $C_debug;
        $C_debug->error('list.inc.php', 'radio', $db->ErrorMsg());
    }
    if ($result->RecordCount() >= 5) {
        $count = 5;
    } else {
        $count = $result->RecordCount();
    }
    if ($id == "all") {
        $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value=""> All <BR>';
    }
    $i = 0;
    while (!$result->EOF) {
        if ($id == $result->fields["id"]) {
            $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value="' . $result->fields["id"] . '" checked> ' . $result->fields["{$field}"] . '<BR>';
        } else {
            $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value="' . $result->fields["id"] . '"> ' . $result->fields["{$field}"] . '<BR>';
        }
        $i++;
        $result->MoveNext();
    }
    if ($i == 0) {
        $return .= '<input id="' . $input_id . '" type="radio" name="' . $name . '" class="' . $class . '" value="">' . $C_translate->translate('lists_none_defined', 'CORE', '');
    }
    return $return;
}
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:50,代码来源:list_radio.inc.php

示例9: database

 public function database($params = '', $return = FALSE, $active_record = NULL)
 {
     // Grab the super object
     $CI =& get_instance();
     // Do we even need to load the database class?
     if (class_exists('CI_DB') and $return == FALSE and $active_record == NULL and isset($CI->db) and is_object($CI->db)) {
         return FALSE;
     }
     require_once BASEPATH . 'database/DB.php';
     $db = DB($params, $active_record);
     // Load extended DB driver
     $custom_db_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver';
     $custom_db_driver_file = APPPATH . 'core/' . $custom_db_driver . '.php';
     if (file_exists($custom_db_driver_file)) {
         require_once $custom_db_driver_file;
         $db = new $custom_db_driver(get_object_vars($db));
     }
     // Return DB instance
     if ($return === TRUE) {
         return $db;
     }
     // Initialize the db variable. Needed to prevent reference errors with some configurations
     $CI->db = '';
     $CI->db =& $db;
 }
开发者ID:raghavenc5,项目名称:rentnroam,代码行数:25,代码来源:MY_Loader.php

示例10: database

 /**
  * Function for right load database
  *
  * @access    public
  * @param    string    the DB credentials
  * @param    bool    whether to return the DB object
  * @param    bool    whether to enable active record (this allows us to override the config setting)
  * @return    object
  */
 function database($params = '', $return = FALSE, $query_builder = NULL)
 {
     // Do we even need to load the database class?
     if (class_exists('CI_DB') and $return == FALSE and $query_builder == NULL) {
         return FALSE;
     }
     require_once BASEPATH . 'database/DB' . '.php';
     // Load the DB class
     $db =& DB($params, $query_builder);
     $my_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver';
     $my_driver_file = APPPATH . 'libraries/System/' . $my_driver . '.php';
     if (file_exists($my_driver_file)) {
         log_message('debug', 'Extended DB driver class instantiated!');
         require_once $my_driver_file;
         $db_obj = new $my_driver(get_object_vars($db));
         $db =& $db_obj;
     }
     if ($return === TRUE) {
         return DB($params, $query_builder);
     }
     // Grab the super object
     $CI =& get_instance();
     // Initialize the db variable.  Needed to prevent
     // reference errors with some configurations
     $CI->db = '';
     $CI->db = $db;
     return $this;
     // Assign the DB object to any existing models
     //$this->_ci_assign_to_models();
 }
开发者ID:reg2005,项目名称:CI_HMVC_SECURITY,代码行数:39,代码来源:MY_Loader.php

示例11: __construct

 public function __construct($orgcode, $enableSlaves = 'false')
 {
     $this->orgcode = $orgcode == null ? 'config' : $orgcode;
     $this->_current_date = date("Y-m-d H:i:s");
     $this->db = DB($this->orgcode);
     $this->db->enableSlaves = $enableSlaves;
 }
开发者ID:gtyd,项目名称:jira,代码行数:7,代码来源:DALBase.php

示例12: smarty_function_html_select_affiliate

function smarty_function_html_select_affiliate($params, &$smarty)
{
    $id = $params['id'];
    $name = $params['name'];
    $default = $params['default'];
    $type = $params['type'];
    if (empty($id)) {
        $id = $name . "_id";
    }
    if (!empty($default)) {
        $db =& DB();
        $p = AGILE_DB_PREFIX;
        $q = "SELECT DISTINCT\n\t          {$p}affiliate.id,\n\t          {$p}account.first_name,\n\t          {$p}account.last_name,\n\t          {$p}account.username\n\t          FROM \n\t          {$p}account\n\t          LEFT JOIN\n\t          {$p}affiliate              \t\n\t          ON\n\t          {$p}account.id = {$p}affiliate.account_id\n\t          WHERE  \n\t          {$p}affiliate.id = '{$default}' AND\n\t          {$p}affiliate.site_id = " . DEFAULT_SITE . " AND\n\t          {$p}account.site_id = " . DEFAULT_SITE;
        $result = $db->Execute($q);
        if ($result != false && $result->RecordCount() > 0) {
            $val = $result->fields['first_name'] . ' ' . $result->fields['last_name'];
        }
    } else {
        $val = '';
    }
    echo '   	
    <input type="hidden" id="' . $id . '_hidden" name="' . $name . '" value="' . $default . '" />
    <input type="text" autocomplete="off" id="' . $id . '" name="affiliate_search" size="35" value="' . $val . '" /> 
    <div class="auto_complete" id="' . $id . '_auto_complete"></div>  
    <script type="text/javascript">new Ajax.Autocompleter("' . $id . '", "' . $id . '_auto_complete", "ajax.php?do[]=affiliate:autoselect", { })</script>
    ';
    if (!empty($val)) {
        // display unselect option
        echo '<a href="#" OnClick="document.getElementById(\'' . $id . '\').value=\'\'; document.getElementById(\'' . $id . '_hidden\').value=\'\'"> - </a>';
    }
}
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:31,代码来源:function.html_select_affiliate.php

示例13: CORE_weblog

 /**
  * Logs the sesson variables.
  * 
  * @return 	void
  * @since 	Version 1.0
  */
 function CORE_weblog()
 {
     global $current_module, $VAR;
     if ($current_module == '') {
         $module = '';
     } else {
         $module = $current_module;
     }
     if (!isset($VAR['_page']) || $VAR['_page'] == '') {
         $page = '';
     } else {
         @($pagearr = explode(':', $VAR['_page']));
         @($page = $pagearr["1"]);
     }
     ### browser type:
     $arr_browser = $this->get_browser();
     $browser = $arr_browser["type"] . ' ' . $arr_browser["ver"];
     ### product:
     if (isset($VAR['prid'])) {
         $product = $VAR['prid'];
     } else {
         $product = '';
     }
     ### log the current hit to the database
     $db =& DB();
     $id = $db->GenID(AGILE_DB_PREFIX . "" . 'weblog_id');
     $sql = "INSERT INTO " . AGILE_DB_PREFIX . "weblog SET\n\t\t\t\tid      \t= " . $db->qstr($id) . ",\n\t\t\t\tdate_orig   = " . $db->qstr(time()) . ",\n\t\t\t\tsite_id\t\t= " . $db->qstr(DEFAULT_SITE) . ",\n\t\t\t\tsession_id\t= " . $db->qstr(SESS) . ",\n\t\t\t\taccount_id\t= " . $db->qstr(SESS_ACCOUNT) . ",\n\t\t\t\taffiliate_id= " . $db->qstr(SESS_AFFILIATE) . ",\n\t\t\t\treseller_id\t= " . $db->qstr(SESS_RESELLER) . ",\n\t\t\t\tcampaign_id\t= " . $db->qstr(SESS_CAMPAIGN) . ",\n\t\t\t\tproduct_id\t= " . $db->qstr($product) . ",\n\t\t\t\tmodule\t\t= " . $db->qstr($module) . ",\n\t\t\t\tpage\t\t= " . $db->qstr($page) . ",\n\t\t\t\treferrer\t= " . $db->qstr($this->get_referrer()) . ",\n\t\t\t\tbrowser\t\t= " . $db->qstr($browser) . ",\n\t\t\t\tos\t\t\t= " . $db->qstr($this->get_os());
     $result = $db->Execute($sql);
     # error reporting:
     if ($result === false) {
         global $C_debug;
         $C_debug->error('weblog.inc.php', 'weblog', $db->ErrorMsg());
     }
     return;
 }
开发者ID:nicsopon,项目名称:agilebill,代码行数:41,代码来源:weblog.inc.php

示例14: database_s

 function database_s($params = '', $return = FALSE, $active_record = NULL)
 {
     // Do we even need to load the database class?
     if (class_exists('CI_DB') and $return == FALSE and $active_record == NULL and isset($CI->db) and is_object($CI->db)) {
         return FALSE;
     }
     require_once BASEPATH . 'database/DB' . EXT;
     // Load the DB class
     $db =& DB($params, $active_record);
     $my_driver = config_item('subclass_prefix') . 'DB_' . $db->dbdriver . '_driver';
     $my_driver_file = APPPATH . 'libraries/' . $my_driver . EXT;
     if (file_exists($my_driver_file)) {
         require_once $my_driver_file;
         $db = new $my_driver(get_object_vars($db));
     }
     if ($return === TRUE) {
         return $db;
     }
     // Grab the super object
     $CI =& get_instance();
     // Initialize the db variable.  Needed to prevent
     // reference errors with some configurations
     $CI->db = '';
     // Load the DB class
     $CI->db = $db;
     if (!empty($_REQUEST['MemFlush']) && $_REQUEST['MemFlush'] == 1) {
         $CI->db->MemFlush = TRUE;
     }
 }
开发者ID:Bingle-labake,项目名称:coollive.com.cn,代码行数:29,代码来源:20140216_MY_Loader.php

示例15: import

 function import($VAR)
 {
     global $C_debug;
     if (empty($VAR['asset_pool_id'])) {
         $C_debug->alert("No asset pool specified");
         return;
     }
     $db =& DB();
     if (is_uploaded_file($_FILES['datafile']['tmp_name'])) {
         # Got a file to import
         $fp = fopen($_FILES['datafile']['tmp_name'], "r");
         if ($fp) {
             $counter = 0;
             $skipped = 0;
             while (!feof($fp)) {
                 $line = fgets($fp, 128);
                 $cols = explode(",", $line);
                 if (!empty($cols[0])) {
                     $fields = array('date_orig' => time(), 'date_last' => time(), 'status' => 0, 'service_id' => 0, 'pool_id' => $VAR['asset_pool_id'], 'asset' => @$cols[0], 'misc' => @$cols[1]);
                     $db->Execute(sqlInsert($db, "asset", $fields));
                     $counter++;
                 } else {
                     $skipped++;
                 }
             }
             $C_debug->alert("Imported {$counter} new Asset(s) and skipped {$skipped} Asset(s)!");
         } else {
             $C_debug->alert('Unable to fopen the file sent.');
         }
     } else {
         $C_debug->alert('Unable to process the uploaded file.');
     }
 }
开发者ID:chiranjeevjain,项目名称:agilebill,代码行数:33,代码来源:asset.inc.php


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