當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CI::db方法代碼示例

本文整理匯總了PHP中CI::db方法的典型用法代碼示例。如果您正苦於以下問題:PHP CI::db方法的具體用法?PHP CI::db怎麽用?PHP CI::db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CI的用法示例。


在下文中一共展示了CI::db方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTerm

 function getTerm($code)
 {
     CI::db()->select('term');
     $result = CI::db()->get_where('search', array('code' => $code));
     $result = $result->row();
     return $result->term;
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:7,代碼來源:Search.php

示例2: getVideos

 function getVideos($criteria = false)
 {
     $table = TABLE_PREFIX . 'masterdebate_videos';
     $q = " SELECT * FROM {$table} order by id DESC ";
     //print $q ;
     $query = CI::db()->query($q);
     $query = $query->result_array();
     return $query;
 }
開發者ID:Gninety,項目名稱:Microweber,代碼行數:9,代碼來源:masterdebate_model.php

示例3: delete

 public function delete($direction = false, $id = false)
 {
     if ($id) {
         \CI::db()->delete($this->_db_table[$direction], array('id' => $id));
     } else {
         //if they do not provide an id send them to the product list page with an error
         \CI::session()->set_flashdata('error', lang('error_not_found'));
     }
     redirect('admin/materials/' . $direction);
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:10,代碼來源:AdminMaterials.php

示例4: getAreaTaxRate

 public function getAreaTaxRate()
 {
     $rate = CI::db()->where(array('code' => $this->address['zip'], 'zone_id' => $this->address['zone_id']))->get('country_zone_areas')->row();
     if ($rate) {
         $rate = $rate->tax / 100;
     } else {
         $rate = 0;
     }
     return $rate;
 }
開發者ID:haouach,項目名稱:GoCart3,代碼行數:10,代碼來源:Tax.php

示例5: checkUserPassById

 function checkUserPassById($id, $pass)
 {
     global $cms_db_tables;
     $table = $cms_db_tables['table_users'];
     $q = " select count(*) as qty from {$table} where password like '%{$pass}%' and id='{$id}' ";
     $q = CI::db()->query($q);
     $q = $q->row_array();
     $q = intval($q['qty']);
     if ($q == 0) {
         return false;
     } else {
         return true;
     }
 }
開發者ID:Gninety,項目名稱:Microweber,代碼行數:14,代碼來源:_users_model.php

示例6: login

 function login()
 {
     $back_to = CI::model('core')->getParamFromURL('back_to');
     global $cms_db_tables;
     $table = $cms_db_tables['table_users'];
     $username = $this->input->post('username', TRUE);
     $password = $this->input->post('password', TRUE);
     $user_action = $this->input->post('user_action', TRUE);
     if ($user_action == 'register') {
         $q = "select username from " . $table . " where username='{$username}' ";
         $query = CI::db()->query($q);
         $query = $query->row_array();
         $query = array_values($query);
         $username = $query[0];
         if ($username != '') {
             $this->template['message'] = 'This user exists, try another one!';
         } else {
             $data = array('updated_on' => date("Y-m-d h:i:s"), 'is_active' => 0, 'username' => $username, 'password' => $password);
             $this->db->insert($table, $data);
             $this->template['message'] = 'Success, try login now!';
         }
     } else {
         $q = "select * from " . $table . " where username='{$username}' and password='{$password}' and is_active=1";
         $query = CI::db()->query($q);
         $query = $query->row_array();
         if (empty($query)) {
             $this->template['message'] = 'Wrong username or password, or user is disabled!';
         } else {
             CI::library('session')->set_userdata('user', $query);
             if ($back_to == false) {
                 redirect('dashboard');
             } else {
                 redirect(base64_decode($back_to));
             }
         }
     }
     $this->load->vars($this->template);
     $layout = CI::view('layout', true, true);
     $primarycontent = '';
     $secondarycontent = '';
     $primarycontent = CI::view('login', true, true);
     $layout = str_ireplace('{primarycontent}', $primarycontent, $layout);
     $layout = str_ireplace('{secondarycontent}', $secondarycontent, $layout);
     //CI::view('welcome_message');
     //CI::library('output')->set_output ( $layout );
 }
開發者ID:Gninety,項目名稱:Microweber,代碼行數:46,代碼來源:index.php

示例7: sendNotification

 public function sendNotification($gc_data)
 {
     CI::load()->helper('formatting_helper');
     $row = CI::db()->where('id', '1')->get('canned_messages')->row_array();
     // set replacement values for subject & body
     $row['subject'] = str_replace('{from}', $gc_data['from'], $row['subject']);
     $row['subject'] = str_replace('{site_name}', config_item('company_name'), $row['subject']);
     $row['content'] = str_replace('{code}', $gc_data['code'], $row['content']);
     $row['content'] = str_replace('{amount}', format_currency($gc_data['beginning_amount']), $row['content']);
     $row['content'] = str_replace('{from}', $gc_data['from'], $row['content']);
     $row['content'] = str_replace('{personal_message}', nl2br($gc_data['personal_message']), $row['content']);
     $row['content'] = str_replace('{url}', config_item('base_url'), $row['content']);
     $row['content'] = str_replace('{site_name}', config_item('company_name'), $row['content']);
     $config['mailtype'] = 'html';
     CI::load()->library('email');
     CI::email()->initialize($config);
     CI::email()->from(config_item('email'));
     CI::email()->to($gc_data['to_email']);
     CI::email()->subject($row['subject']);
     CI::email()->message($row['content']);
     CI::email()->send();
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:22,代碼來源:Giftcards.php

示例8: download

 public function download($fileId, $orderId)
 {
     //get the order.
     $order = \CI::db()->where('orders.id', $orderId)->join('customers', 'customers.id = orders.customer_id')->get('orders')->row();
     $file = \CI::db()->where('order_item_files.id', $fileId)->join('digital_products', 'digital_products.id = order_item_files.file_id')->get('order_item_files')->row();
     if ($order && $file) {
         if ($order->is_guest || $order->customer_id == $this->customer->id) {
             if ($file->max_downloads == 0 || $file->downloads_used < $file->max_downloads) {
                 \CI::DigitalProducts()->touchDownload($fileId);
                 \CI::DigitalProducts()->downloadFile($file->filename);
             }
         } else {
             //send to login page
             if (\CI::Login()->isLoggedIn(false, false)) {
                 redirect('login');
             } else {
                 throw_404();
             }
         }
     } else {
         //move along nothing to see here
         throw_404();
     }
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:24,代碼來源:DigitalProducts.php

示例9: get_manufacturers

 public function get_manufacturers($option = true)
 {
     if ($option) {
         $results = CI::db()->get('manufacturers')->result();
         $tmp[] = array();
         $tmp[0] = 'Select manufacturer';
         foreach ($results as $result) {
             $tmp[$result->id] = $result->name;
         }
         return $tmp;
     } else {
         return CI::db()->get('manufacturers')->result_array();
     }
 }
開發者ID:lekhang,項目名稱:gonline,代碼行數:14,代碼來源:Products.php

示例10: transaction

 public function transaction($transaction = false)
 {
     //no transaction provided? create a new one and return it.
     if (!$transaction) {
         $order_number = str_replace('.', '-', microtime(true)) . $this->cart->id;
         $transaction = ['order_id' => $this->cart->id, 'order_number' => $order_number, 'created_at' => date('Y-m-d H:i:s')];
         \CI::db()->insert('transactions', $transaction);
         $transaction['id'] = \CI::db()->insert_id();
         return (object) $transaction;
     } else {
         //we have a transaction, update it with the response
         \CI::db()->where('id', $transaction->id)->update('transactions', (array) $transaction);
     }
 }
開發者ID:berkapavel,項目名稱:GoCart3,代碼行數:14,代碼來源:GoCart.php

示例11: getProductOptions

 public function getProductOptions($product_id)
 {
     CI::db()->where('product_id', $product_id);
     CI::db()->order_by('sequence', 'ASC');
     $result = CI::db()->get('options');
     $return = [];
     foreach ($result->result() as $option) {
         $option->values = $this->getOptionValues($option->id);
         $return[] = $option;
     }
     return $return;
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:12,代碼來源:Productoptions.php

示例12: _backup

 /**
  * MySQL Export
  *
  * @access	private
  * @param	array	Preferences
  * @return	mixed
  */
 function _backup($params = array())
 {
     if (count($params) == 0) {
         return FALSE;
     }
     // Extract the prefs for simplicity
     extract($params);
     // Build the output
     $output = '';
     foreach ((array) $tables as $table) {
         // Is the table in the "ignore" list?
         if (in_array($table, (array) $ignore, TRUE)) {
             continue;
         }
         // Get the table schema
         $query = CI::db()->query("SHOW CREATE TABLE `" . $this->db->database . '`.' . $table);
         // No result means the table name was invalid
         if ($query === FALSE) {
             continue;
         }
         // Write out the table schema
         $output .= '#' . $newline . '# TABLE STRUCTURE FOR: ' . $table . $newline . '#' . $newline . $newline;
         if ($add_drop == TRUE) {
             $output .= 'DROP TABLE IF EXISTS ' . $table . ';' . $newline . $newline;
         }
         $i = 0;
         $result = $query->result_array();
         foreach ($result[0] as $val) {
             if ($i++ % 2) {
                 $output .= $val . ';' . $newline . $newline;
             }
         }
         // If inserts are not needed we're done...
         if ($add_insert == FALSE) {
             continue;
         }
         // Grab all the data from the current table
         $query = CI::db()->query("SELECT * FROM {$table}");
         if ($query->num_rows() == 0) {
             continue;
         }
         // Fetch the field names and determine if the field is an
         // integer type.  We use this info to decide whether to
         // surround the data with quotes or not
         $i = 0;
         $field_str = '';
         $is_int = array();
         while ($field = mysql_fetch_field($query->result_id)) {
             // Most versions of MySQL store timestamp as a string
             $is_int[$i] = in_array(strtolower(mysql_field_type($query->result_id, $i)), array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), TRUE) ? TRUE : FALSE;
             // Create a string of field names
             $field_str .= '`' . $field->name . '`, ';
             $i++;
         }
         // Trim off the end comma
         $field_str = preg_replace("/, \$/", "", $field_str);
         // Build the insert string
         foreach ($query->result_array() as $row) {
             $val_str = '';
             $i = 0;
             foreach ($row as $v) {
                 // Is the value NULL?
                 if ($v === NULL) {
                     $val_str .= 'NULL';
                 } else {
                     // Escape the data if it's not an integer
                     if ($is_int[$i] == FALSE) {
                         $val_str .= $this->db->escape($v);
                     } else {
                         $val_str .= $v;
                     }
                 }
                 // Append a comma
                 $val_str .= ', ';
                 $i++;
             }
             // Remove the comma at the end of the string
             $val_str = preg_replace("/, \$/", "", $val_str);
             // Build the INSERT string
             $output .= 'INSERT INTO ' . $table . ' (' . $field_str . ') VALUES (' . $val_str . ');' . $newline;
         }
         $output .= $newline . $newline;
     }
     return $output;
 }
開發者ID:Gninety,項目名稱:Microweber,代碼行數:92,代碼來源:mysql_utility.php

示例13: modify_column

 /**
  * Column Modify
  *
  * @access	public
  * @param	string	the table name
  * @param	string	the column name
  * @param	string	the column definition
  * @return	bool
  */
 function modify_column($table = '', $field = array())
 {
     if ($table == '') {
         show_error('A table name is required for that operation.');
     }
     // add field info into field array, but we can only do one at a time
     // so we cycle through
     foreach ($field as $k => $v) {
         $this->add_field(array($k => $field[$k]));
         if (count($this->fields) == 0) {
             show_error('Field information is required.');
         }
         $sql = $this->_alter_table('CHANGE', $this->db->dbprefix . $table, $this->fields);
         $this->_reset();
         if (CI::db()->query($sql) === FALSE) {
             return FALSE;
         }
     }
     return TRUE;
 }
開發者ID:Gninety,項目名稱:Microweber,代碼行數:29,代碼來源:DB_forge.php

示例14: touchDownload

 public function touchDownload($file_id)
 {
     CI::db()->where('id', $file_id)->set('downloads_used', 'downloads_used+1', false)->update('order_item_files');
 }
開發者ID:lekhangyahoo,項目名稱:gonline,代碼行數:4,代碼來源:Digitalproducts.php

示例15: fakeSend

 function fakeSend()
 {
     $table = TABLE_PREFIX . 'cacaomail_mails_to_send';
     $table2 = TABLE_PREFIX . 'cacaomail_mails_to_send_log';
     $q = " select * from {$table} where id NOT IN (SELECT mail_id FROM\n        {$table2} where mail_id is not null\n         group by mail_id)  \n         \n         and for_download = 0 and is_active = 1\n         ";
     $query = CI::db()->query($q);
     $query = $query->result_array();
     var_dump($query);
     foreach ($query as $i) {
     }
     return true;
 }
開發者ID:Gninety,項目名稱:Microweber,代碼行數:12,代碼來源:cacaomail_model.php


注:本文中的CI::db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。