codeigniter-2

Two field as one unique field in Grocery Crud

[亡魂溺海] 提交于 2019-12-07 21:49:06
问题 I have one problem in GroceryCrud. I want to insert the data in one table. Table is like this: id, card_no, site_code, site_no card_no is unique and i have implemented it. However; my problem is that site_code and site_no should be unique only is both values match. Which means that is site_code is 101 and site_no is 102 and we try to insert identical values for both again is should reject it. If we one of the values is different it should allow it. In this case we are treating both values as

Codeigniter Class Inheritance between modules (wiredesigns)

与世无争的帅哥 提交于 2019-12-07 16:29:24
My CI2 app is using the wiredesigns modular layout. I have a two modules called item and product in a a folder called modules like so: /application /modules /item /product In Item I have a controller called item which starts like this. class Item extends MX_Controller { //code here } What do I need to do to make my products controller extend my item controller in a different module My guess is you are trying to keep your code "DRY" (http://en.wikipedia.org/wiki/Don't_repeat_yourself) which in CI means using a common controller like a My_Controller (see: http://ellislab.com/codeigniter/user

CodeIgniter: unset all userdata, but not destroy the session

别说谁变了你拦得住时间么 提交于 2019-12-07 14:13:36
问题 Is there a way to unset ALL userdata in a session without having to use session destroy? I'm trying to log my user out and need to unset all userdata one at a time. It's becoming tedious to keep track of all possible userdata set in session. I just want to unset everything that might have been set in userdata. 回答1: This is very simple! $this->session->unset_userdata('some_name'); or $array_items = array('username' => '', 'email' => ''); $this->session->unset_userdata($array_items); I hope

DATE_FORMAT within a query in CodeIgniter using Active Record don't work

大城市里の小女人 提交于 2019-12-07 12:41:09
问题 coders. I'm running a little problem here and can't find the solution. I'm building a query using Active Record from CI. This is the code for the query: $this->db->select("u.id AS user_id, u.email, p.display_name, p.first_name, p.last_name, s.status_id, s.message"); $this->db->select("DATE_FORMAT(s.created_at, `Publicado el %d/%m/%Y a las %h:%i %p`) AS created_at", FALSE); $this->db->join($this->_table_users . ' u', 'u.id = s.user_id'); $this->db->join($this->_table_profiles . ' p', 'p.user

Codeigniter CIBonfire how to change mode from development to production?

人走茶凉 提交于 2019-12-07 10:13:12
问题 I'm creating my first app using CIBonfire and i'm ready to push it to production, but i'm not sure how to change the mode from development to production so that it does not show the profiler stuff in the footer. I was not able to find it in any of the settings menus or in the documentation. Any help is appreciated. 回答1: In your index.php file in your CI-Bonfire. you can find this spot here, just change the define('ENVIRONMENT', 'development') into define('ENVIRONMENT', 'production') * You can

What is proper way to secure CodeIgniter 2 application with authentication?

99封情书 提交于 2019-12-07 09:10:17
问题 I have Ion Auth properly installed and working on my server. I also have the default CodeIgniter 2 "news" tutorial working in the same CI installation. I'm just playing around and curious about the proper way to use the authentication system to "enclose" or protect an entire application. For this question, let's use the "news" tutorial that comes with CI. Inside the index() function in my news.php controller, I added conditional code to check if the user is logged in. If not, the user is just

Codeigniter Extend custom model produces FATAL ERROR

橙三吉。 提交于 2019-12-07 08:37:11
问题 I've seen a few different posts on this, but none of them seem to be working for me. I have one class that extends CI_Model: class Users_Model extends CI_Model { public function __construct(){ parent::__construct(); } and then: class Students_Model extends Users_Model { private $_students; public function __construct(){ parent::__construct(); $this->_students = $this->get_students(); } However I then receive this error message: PHP Fatal error: Class 'Users_Model' not found in /Users

How to disable direct access to callback functions?

淺唱寂寞╮ 提交于 2019-12-07 06:42:57
问题 <? if ( ! defined('BASEPATH')) exit(); class Registration extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('registration_model'); } public function index() { $this->load->library('form_validation'); $this->form_validation->set_rules('email', 'E-mail', 'trim|required|valid_email|callback_email_available'); if($this->form_validation->run() == FALSE) { $this->load->view('registration'); } else { $this->registration_model->add_user(); } } # Check E

Custom error pages with templates in CodeIgniter

天涯浪子 提交于 2019-12-07 05:04:06
问题 I'm using the template library for CodeIgniter, http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html, and now I want to implement custom error pages too. I found one method involving a MY_Router extending the default router: http://maestric.com/doc/php/codeigniter_404 but that only treats 404 errors. I want all errors to show a simple user-friendly page, including database errors etc, and I want it to go through a controller, partly so I can use the template library,

How to retrieve the third uri segment in a codeigniter hook

北城余情 提交于 2019-12-07 03:54:25
问题 I'm writing a custom post_controller hook. As we know, codeigniter uri structure is like this: example.com/class/function/id/ and my code: function hook_acl() { global $RTR; global $CI; $controller = $RTR->class; // the class part in uri $method = $RTR->method; // the function part in uri $id = ? // how to parse this? // other codes omitted for brevity } I've browsed the core Router.php file, which puzzled me a lot. thanks. 回答1: Using CodeIgniter URI core class Generally within CodeIgniter