codeigniter-2

Codeigniter Database Based Configuration Settings

眉间皱痕 提交于 2019-12-03 17:26:42
I am building an application using the latest copy of Codeigniter 2.0. My application is dynamic and is kind of like a custom CMS I guess you could say. I have a database table called 'settings' with the following fields: id name value Basically what I am currently doing is using a helper function to retrieve specific settings from my settings table like the site name or current theme. However I've started thinking that maybe the constant amount of database calls for retrieving settings is a bit too much on the database. Is there a way of retrieving settings for my application from the

How to route 2 parameters to a controller?

三世轮回 提交于 2019-12-03 16:12:50
问题 This seems really basic but i can't get the hang of it. I'm trying to send more then one parameter to a method in the controller, like this : http://localhost/ci/index.php/subjects/3/state This is the routings i've tried : $route['subjects/(:num)'] = 'subjects/view/$1'; $route['subjects/(:num)/{:any}'] = 'subjects/view/$1/$2'; the method accepted 2 paremeters : public function view($slug, $id = null){ } but i seem to get a 404. How can i get this to work? i need the view method to always

passing data from hook to view in codeigniter

两盒软妹~` 提交于 2019-12-03 15:23:25
can i passing data from hook to view, If is it possible please explain. for example $hook['post_controller_constructor'][] = array( 'class' => 'Varify_user', 'function' => 'user_project', 'filename' => 'varify_project.php', 'filepath' => 'hooks', 'params' => array('') ); i want send some array data varify_project.php(hook file) to view. splash58 I do so application/core/MY_Loader.php class MY_Loader extends CI_Loader { static $add_data = array(); public function view($view, $vars = array(), $return = FALSE) { self::$add_data = array_merge($vars, self::$add_data); return $this->_ci_load(array('

CodeIgniter Upload image and then resize it

☆樱花仙子☆ 提交于 2019-12-03 15:02:26
I am trying to upload images and resize them, so far the upload is working and also the creation of thumb nail images. But I cant get the original image to be resized. All that is happening is the file is directly uploaded to the folder in its original size. I guess I am trying to take this image resize it then overwrite the originally uploaded file. Here is my code what am I missing: //Initialise the upload file class $config['upload_path'] = './image_uploads/'; $config['allowed_types'] = 'jpg|jpeg|gif|png'; $config['max_size'] = '6048'; $this->load->library('upload', $config); $userfile = "

How to pass validation error data through redirect()?

寵の児 提交于 2019-12-03 14:41:07
I have a page that contains a form and when any user submits it, the data goes to a controller and the controller checks the validation, if there is any error it redirects the user to the previous page( the page that contains the form), otherwise it sends data to models. To redirect to the previous page from controller (if there is any validation error), I have the following code redirect($this->input->post('redirect')); The above code is working fine but the problem is after it redirects the user to the previous page(The page that contains the form) it is not displaying the validation errors.

Update Database Field Error CodeIgniter

馋奶兔 提交于 2019-12-03 10:03:10
问题 I am getting the following error message in CodeIgniter 2.1: A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: database/DB_active_rec.php Line Number: 1407 I'm trying to update fields in my database. I have this code and every tutorial are just the same for batch upload. It works anyway but the thing is it display such an error. this what i have in my model: function update2($data){ $this->db->update_batch('users',$data, "id"); } This what i have in my

Codeigniter: does $this->db->last_query(); execute a query?

不羁的心 提交于 2019-12-03 09:20:20
Does query execution happen at the get_where() clause of the following codeigniter active record statement? $this->db->select('*'); $q = $this->db->get_where('Contacts', array('id' => $contact_id)); $sql = $this->db->last_query(); Or does it happens once you call the result_array() ? And is $this->db->last_query(); a reliable way in getting the query string. Muhammad Raheel The query execution happens on all get methods like $this->db->get('table_name'); $this->db->get_where('table_name',$array); While last_query contains the last query which was run $this->db->last_query(); If you want to get

Authentication in jQuery Mobile and PhoneGap

那年仲夏 提交于 2019-12-03 09:03:50
I have a web application built with jQuery Mobile and PHP (CodeIgniter framework). Now I'm trying to make a PhoneGap version of it as well, to make it distributable as a standalone app. However, the PHP web app. version uses Ion Auth, a CodeIgniter plugin for authentication. So when you go to a page that requires authentication, the app redirects you to the authentication controller login method. And after authentication it redirects you back to the home page (the jQuery Mobile page in this case). This works fine in the web app., since the home page is opened by the home controller in the

Codeigniter - How to get url variable value inside contoller function?

戏子无情 提交于 2019-12-03 08:59:59
I have URL like this: http://localhost/sitename/some-post-title/code=24639204963309423 Now I have one findUser function in my controller file public function findUser() { // I have tried with $_GET['code'] } and I am trying to get code variable value inside this function. I have tried with $_GET['code'] but did not worked. Any Idea how to get value inside controller function? Thanks. Are you trying to get a path segment variable or a GET variable? It looks like you're going for a bit of both. Natively in CI, you can use $this->input->get if you update your url to look more like http:/

Codeigniter URL: How to display id and article title in the URL

故事扮演 提交于 2019-12-03 08:51:33
问题 Please see the following link structure http://stackoverflow.com/questions/10672712/voting-system-like-stackoverflow In the above link the 10672712 is the question id I guess, because if you check the following link you will get to the same location as above: http://stackoverflow.com/questions/10672712 Now if you use the above link then you will notice that in the browser's address bar the link automatically adds the question title (as slug) after the question id and it appears just like the