codeigniter-2

CI - show database error or fail

試著忘記壹切 提交于 2019-11-28 11:51:31
问题 I've developed a simple login system which works ok but fails, and I need to know why QUESTION: How to show what is causing the fail. This is not a validation error but an error either with the data being passed to MySQL or the query somehow failing here's the db function: function login($email,$password) { $this->db->where("email",$email); $this->db->where("password",$password); $query=$this->db->get("users"); if($query->num_rows()>0) { foreach($query->result() as $rows) { //add all data to

Codeigniter Setting Homepage ( Default Controller )

╄→гoц情女王★ 提交于 2019-11-28 11:16:49
I'm trying to implement page templating in my codeigniter application, templating is working fine for instance, i have a blog page, which i'm trying to assign as my homepage, with different view and pagination and so on. When i write www.mywebsite.com/blog, it gets opened in homepage template, or assume that i have a page www.mywebsite.com/about , it gets opened in page template too. But when i try to access my website via www.mywebsite.com, i have a 404 error page. How can i assign my blog page as the homepage ? Page Controller : class Page extends Frontend_Controller { public function _

Codeigniter & HTML5 - Trying to Upload Multiple Images at Once

↘锁芯ラ 提交于 2019-11-28 08:50:18
View Looks Like This <?=form_open_multipart('upload/process');?> <input type="file" multiple="multiple" name="userfile[]" id="userfile" /> <?=form_submit('upload', 'Upload');?> <?=form_close();?> i want the user to be able to upload multiple images at once. once uploaded i want to make an entry of the image details in the database, and finally move the image to the uploads folder. i have basic knowledge of codeigniter ps: i dont want to use uploadify or similar image uploading plugins. trying to keep it as light weight as possible Update this is the kind of array i am getting when i try var

Always show Previous & Next links using CodeIgniter Pagination Class

泄露秘密 提交于 2019-11-28 08:46:00
Problem Description When I'm at the first page, the previous link is not showing up and so do the next link when I'm at the last page. I set $config['prev_link']='previous' and $config['next_link']='next' . Question How to always present, using the CodeIgniter pagination class, the Previous and Next links as <p> tags when they are not in used? Update End up Solving it myself. See solution below. Working on v2.1.3 Here is the Solution: Extend Codeigniter pagination class by creating a new file: MY_Pagination.php and placing it in the application/library folder. Change all variables and classes

combining mysql AND OR queries in Codeigniter

六月ゝ 毕业季﹏ 提交于 2019-11-28 08:04:30
I want to combine AND OR mysql queries in CI. I have already seen this thread: http://codeigniter.com/forums/viewthread/92818/ . But they don't provide the exact solution there. How do I create the following query using strictly the CI framework? (I can create the query easily without the brackets but then it is not the same query.) SELECT * FROM `Persons` WHERE LastName='Svendson' AND Age="12" AND (FirstName='Tove' OR FirstName='Ola' OR Gender="M" OR Country="India") P.S.: This is just a sample query even if it makes no sense & Do not suggest writing the entire OR part of the query inside a

CSV Import Library for CodeIgniter [closed]

瘦欲@ 提交于 2019-11-28 06:38:49
Need to implement csv or xls import into Application created using CodeIgniter. Is there any library for this? Any suggestion appreciated. Muhammad Raheel Here is an easy way to do this. I don't know what people do but i use this This is my csv reader library <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class CSVReader { var $fields; /** columns names retrieved after parsing */ var $separator = ';'; /** separator used to explode each line */ var $enclosure = '"'; /** enclosure used to decorate each field */ var $max_row_size = 4096; /** maximum row size to be used

CodeIgniter 2.1 issue with show_404() and 404_override

十年热恋 提交于 2019-11-28 06:27:35
I have been working with CodeIgniter for quite a while now and I'm currently doing a project for a client that would like a custom 404 page. Everything is fine and the 404_override it works great. My issue comes when a visitor is trying to access a article that do not exist I would like to call the show_404() function, but this shows me the "out of box" 404 page and not the one written in the 404_override. I have seen some fixes for older versions, but I can't get it to work in 2.1 . So if anyone can help me out of this I would be really grateful. Redirect is cleanest; loading a view could

CodeIgniter: How to get Controller, Action, URL information

社会主义新天地 提交于 2019-11-28 02:53:16
I have these URLs: http://backend.domain.com/system/setting/edit/12 http://backend.domain.com/product/edit/1 How to get controller name, action name from these URLs. I'm CodeIgniter newbie. Are there any helper function to get this info Ex: $params = helper_function( current_url() ) Where $params becomes something like array ( 'controller' => 'system/settings', 'action' => 'edit', '...'=>'...' ) Sampson You could use the URI Class : $this->uri->segment(n); // n=1 for controller, n=2 for method, etc I've also been told that the following work, but am currently unable to test: $this->router-

Update query increment field plus 1 codeigniter

我与影子孤独终老i 提交于 2019-11-28 01:43:09
问题 I got a problem when trying to increment by 1 on given field in my db. I tried with and without active records. My functions look like this (in my model) function _set_reads($id){ $this->db->set('reads', 'reads+1', FALSE) $this->db->where('id', $id); $this->db->update('article'); } and function _set_reads($id){ $sql = 'update article set reads=reads+1 where id=?'; $this->db->query($sql, array($id)); } I get the same error in both cases and it's the following error message: Error Number: 1064

CodeIgniter Validation: possible to validate GET query strings?

送分小仙女□ 提交于 2019-11-28 01:37:05
问题 The form validation library seems to only work on POST. I need to use query strings and would like to use CI to validate the passed values. Is there a way to do this? 回答1: The current Codeigniter 3.0 development branch provides an option to insert your own variable instead of $_POST. So you could start using 3.0. Alternatively, the only way in CI2.1 is to do $_POST=$_GET before you run the validation. 回答2: See this page for the CodeIgniter 3 solution:- http://www.codeigniter.com/userguide3