codeigniter-2

How do I efficiently load multiple has_many relationships in CodeIgniter DataMapper ORM?

左心房为你撑大大i 提交于 2019-12-13 02:08:37
问题 Given the following models: Category: has_many(‘template’) Template: has_many(‘tag’, ‘procedure’) What is the most efficient way to load ALL objects related to ALL categories? For instance, I’m currently doing the following, but hopefully there is a better way: // Load all Category objects $categories = new Category(); $categories->get(); // Load all Template objects related to each Category foreach($categories as $category) { $category->templates->get(); // Load all the Tag and Procedure

Cannot show view without index.php in a url except in the default controller in Codeigniter

房东的猫 提交于 2019-12-13 01:54:27
问题 I have a routing issue in CodeIgniter, i have searched and tried other links on stackoverflow including Removing index.php in CodeIgniter just works for the default controller URL but my problem did'nt solved. When i run from this url http://localhost/MyProject/ it successfully gives output the view page of test.php page, but the problem is suppose there is test2 view and controller also, so i can't load it directly by this url http://localhost/MyProject/test2 , but i can load it through http

codeigniter login check for all functions(tabs)

前提是你 提交于 2019-12-13 01:47:38
问题 i have a function for login controls. if user didnt login it redirects to login.php in my controller i have to many functions and this functions represents pages in website. so do i have to call $this->is_logged_in(); function in each function. for example: class Admin extends CI_Controller{ function index(){ $this->is_logged_in(); // works fine like this $this->load->view('admin/welcome_message'); } function users(){ $this->is_logged_in(); // works fine like this $this->load->view('admin

get the requested controller in hook precontroller in codeigniter

杀马特。学长 韩版系。学妹 提交于 2019-12-13 01:34:01
问题 I'm trying to make a simple routing rule to allow only authenticated users to certain controllers. To achieve this, I would like to run precontroller hook and check if the user is logged in using ci session. However, I have to know which controller the user wants to access. How do I know this in a hook function? 回答1: $this->router->fetch_class(); Extend CI_Controller and this should work. 回答2: I dont think that hooks are best practice for what you want to achieve here you may try the

Codeigniter Image Manipulation Class : Resize and Crop on multiple files

*爱你&永不变心* 提交于 2019-12-13 01:13:06
问题 I'm struggling to get the CodeIgniter Image Manipulation working correctly. Either it's a bug or I'm just not seeing it. I hope someone can help me with it. Thanks in advance! On the script: I want to create thumbnails (176w x 132h). The input images are in different sizes and ratios. In order to always get this size I first resize them to fit the max width or height (depending on image orientation) and then crop in the center. I've tried to do it all in 1 method. That didn't work, so I

Class Model not found in Doctrine 2.2 + CodeIgniter 2.1

浪尽此生 提交于 2019-12-13 00:41:14
问题 I have set up a project with CodeIgniter 2.1 and Doctrine 2.2, following the instruction on Doctrine cookbook. The EntityManager works, but when I try to load entity models, it gives me error Fatal error: Class 'Users' not found in /Volumes/Data/Projects/myproject/application/controllers/home.php on line 10 This is my home.php file: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); //require_once(APPPATH.'models/Users.php'); class Home extends CI_Controller { public

Database connection settings with DB_DEBUG set as FALSE

我们两清 提交于 2019-12-12 20:35:20
问题 I'm trying to connect to my database but i get the following message: Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 So after reading a lot, I found that setting $db['default']['db_debug'] to FALSE in database connection solves it. I did that and the error message disappeared; the website's first page loaded too but it had no database calls. From then on I started getting errors during my database calls, the query were

Codeigniter Session class disable for particular controller

孤者浪人 提交于 2019-12-12 17:04:51
问题 I'm having application in codeigniter already, now i'm developing the android from this application. Using this application as a server side and doing client console in android. In server i'm maintained the session. But in android request i can't maintain the session. Instead of that i'm creating GUID in server at the first request of login request and storing at client side and also storing at customer table, afterwards for each request client will send the GUID for authentication. Now what

codeigniter 2.1.4 support for http methods custom routings?

放肆的年华 提交于 2019-12-12 16:02:15
问题 I know that codeigniter supports custom routing to another class / method e.g. $route['product/(:any)'] = "catalog/product_lookup"; However does it support routings based on the type of http request calling the url like in laravel ? e.g. using get method reroute like in Laravel Read PUT /users/X Route::post('users/{id}','UsersController@update'); 回答1: The official, production version does not. Not a single word on that in docs. But... This feature is implemented in the development branch. It

Can I set Ion auth to login by username OR Email

妖精的绣舞 提交于 2019-12-12 12:17:54
问题 I know I can set ion auth to login by username in the config, I also know I can set it to login by email in the config. Is there a simple way to set it it to use either automatically? 回答1: If by automatic, you mean try one and then the other to see if either gives a valid return: The login occurs in ion_auth_model line: 899 ->where($this->identity_column, $this->db->escape_str($identity)) so you could change this to do an "or" and try both columns. You would need to do this throughout the