codeigniter

CodeIgniter3 - supporting both API & Web requests in Controllers?

偶尔善良 提交于 2020-01-02 09:59:55
问题 I'm currently working with a CodeIgniter3 application, and have built the basis for a standard blog-like system. The structure is standard CI - User requests a page, page loads controller method, controller method calls any relevant DB functions from its model, and then a view is loaded. However, I'm looking to also make this view accessible via an API. So, instead of the $data array being filled with information to populate into HTML, I would instead pass it to a different view which would

What path do I use to call a background image in codeigniter

佐手、 提交于 2020-01-02 09:39:06
问题 This is my root structure: And under the folder css, I have the file style.css I load my CSS file like this: <link rel="stylesheet" href="<?php print asset_url()?>css/style.css"> I created a helper asset_url_helper that has this function: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); if ( ! function_exists('asset_url()')) { function asset_url() { return base_url().'assets/'; } } And my .htacces file: Deny from all RewriteEngine on RewriteCond $1 !^(index\.php

PHP: Get data from array

浪子不回头ぞ 提交于 2020-01-02 08:00:29
问题 I have this query on my controller: $this->db->select('t1.act_id, t2.login, t1.cust_name, t1.act_type, t1.act_detail, t1.date_added, t1.date_modified, t1.act_notes, ' . 't3.category, t1.total_time, sum(t1.total_time) as total') ->from('activity as t1') ->join('user as t2', 't1.user_id = t2.user_id', 'LEFT') ->join('customer as t3', 't1.cust_name = t3.cust_name', 'LEFT') ->where('t2.login', $user) ->where('MONTH(t1.date_added)', $month) ->order_by('t1.date_added', "desc"); $query = $this->db-

Using models in CodeIgniter

柔情痞子 提交于 2020-01-02 07:07:13
问题 Can somebody explain to me when it's a good practice to use models in CI? An article in wikipedia was referring to CI models as "entirely optional and are rarely needed" is that true in any way? 回答1: Say you needed to call a function called get_user_info that retrieves the users info from a database. You could have a function like this: class Home extends Controller { function __construct() { parent::__construct(); } function index() { $user = $this->get_user_info($_SESSION['user_id']); echo

Uploadify FOLDER

梦想与她 提交于 2020-01-02 06:51:10
问题 I am using Uploadify to upload Files and using Codeigniter framework. Here is my Uploadify code : $("#change_profile_icon").uploadify({ 'uploader' : '/project/style/scripts/crop/uploadify/uploadify.swf', 'script' : 'http://localhost/project/pages/profile_icon', 'cancelImg' : '/project/style/scripts/crop/uploadify/cancel.png', 'buttonText' :'Upload image', 'width' : '110', 'height' : '30', 'queueID' : 'fileQueue', 'auto' : true, 'scriptData' :{username :"<?php echo $this->session->userdata(

`enable_query_strings` is Not Working Properly

只谈情不闲聊 提交于 2020-01-02 06:10:16
问题 I'm trying to use CodeIgniter, and xdebug. When I type in the following URL: http://localhost/redux/index.php xdbug works well. When I go to following URL: http://localhost/redux/index.php? I receive the following 404 error message: XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=124466969367132 Eclipse lanches Firefox with the second, wrong URL, and then I have to change it. I'm using enable_query_strings = TRUE , but I'm still getting the error. How do I solve this problem? 回答1: To get this working

Codeigniter Pagination: Run the Query Twice?

自古美人都是妖i 提交于 2020-01-02 06:07:19
问题 I'm using codeigniter and the pagination class. This is such a basic question, but I need to make sure I'm not missing something. In order to get the config items necessary to paginate results getting them from a MySQL database it's basically necessary to run the query twice is that right? In other words, you have to run the query to determine the total number of records before you can paginate. So I'm doing it like: Do this query to get number of results $this->db->where('something',

Codeigniter Pagination: Run the Query Twice?

筅森魡賤 提交于 2020-01-02 06:07:10
问题 I'm using codeigniter and the pagination class. This is such a basic question, but I need to make sure I'm not missing something. In order to get the config items necessary to paginate results getting them from a MySQL database it's basically necessary to run the query twice is that right? In other words, you have to run the query to determine the total number of records before you can paginate. So I'm doing it like: Do this query to get number of results $this->db->where('something',

How to send custom HTTP header in response?

大城市里の小女人 提交于 2020-01-02 05:57:27
问题 I want to send json data in my HTTP Header. I am using Codeigniter PHP, so I did this in my controller: header('Content-Type: application/json');' This is my code: $request = array( 'request' => $_GET['request'], 'device_id' => $_GET['device_id'], 'launch_date'=> $_GET['launch_date'], 'allowed_hours'=>$_GET['allowed_hours'], 'site_id'=>$_GET['site_id'], 'product'=>$_GET['product'], 'software_version'=>$_GET['software_version'], 'platform_os'=>$_GET['platform_os'], 'platform'=>$_GET['platform'

Unable to send email using SMTP gmail config in codeigniter 3

空扰寡人 提交于 2020-01-02 05:47:08
问题 Below are my code and I refer all examples in stack overflow and codeigniter user guide. still I unable to solve this public function send() { $config['protocol'] = 'smtp'; $config['smtp_crypto'] = 'ssl'; $config['smtp_host'] = 'smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_user'] = '**********@gmail.com'; $config['smtp_pass'] = '********'; $config['mailtype'] = 'html'; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n"; $config['wordwrap'] = TRUE; $config['smtp_timeout'