codeigniter-2

Codeigniter form_validation create custom rule/filter

安稳与你 提交于 2019-12-11 03:55:00
问题 Codeigniters form_validation is great, however I need a custom filter that is specifically alpha space dash and apostrophe/single quote but.. they don't have that specifically in there existing set, so I am wondering how could I go about creating my own rule/filter and adding it to form_validation. 回答1: Callbac ks are your friend You'll just just a custom callback - and put a regex in there that does whatever rule you want. 回答2: Here is some documentation for CodeIgniter's form validation

codeigniter specifying limit to NULL not working in latest CI version 2.1.2

蹲街弑〆低调 提交于 2019-12-11 02:35:43
问题 I have following get_authors_list function in one of my Codeigniter model function get_authors_list($limit,$offset){ $data = array(); $this->db->select('*')->from('authors')->limit($limit,$offset)->order_by('id','desc'); $query = $this->db->get(); if ($query-> num_rows() > 0){ $data = $query->result_array(); } return $data; $q->free_result(); } Before upgrading to Codeigniter 2.1.2, I used call this method from my controller as $data['authors'] = $this->author_model->get_authors_list(NULL, 0)

Custom URI routing by query string with CodeIgniter?

坚强是说给别人听的谎言 提交于 2019-12-11 01:54:20
问题 I am looking to make a custom route using the CodeIgniter framework. I am trying to make the URL like so: http://localhost/accounts/Auth.dll?signin So far I have tried adding the following to my routes.php config file: $route['accounts/Auth.dll?signin'] = "accounts/signin"; but as you would guess, it doesn't work. I have also tried escaping the characters like this: $route['accounts/Auth\.dll\?signin'] = "accounts/signin"; and that doesn't work either. I've also tried including the leading

image uploading issue in codeigniter 2.1.0

99封情书 提交于 2019-12-11 01:45:13
问题 i am using CI 2.1.0 and mysql database for one of my projects. i am facing a problem with my image uploading method. the image i am uploading should be saved in uploads directory and create a thumbnail version of the image and the image path should be saved in database. the code i have done works fine but there is one problem that when i upload an image, in the upload directory i get two copies of the same image and in the thumbs directory a single copy of the uploaded image. i want to have

Compare two dates in Codeigniter and MySQL

廉价感情. 提交于 2019-12-11 00:49:27
问题 How can I get values between two dates in Codeigniter query function? Here is my model and sample code. function get_promo() { $today = date('Y-m-d'); $query = $this->db->query('SELECT FROM tbl_event WHERE event_id = $id AND event_startdate <= $today AND event_enddate >= $today'); return $query; } But it doesn't work, here is the error I got A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the

Codeigniter+PhpBB function redeclaration

痴心易碎 提交于 2019-12-10 23:03:30
问题 I am trying to integrate phpbb to codeigniter. I don't want that the users register for the forum. Site login/register controllers should handle the forum part as well, so I am writing a ci library to register/login to phpbb. I got an error because I have included phpbb functions and libraries inside my ci library: Fatal error: Cannot redeclare redirect() (previously declared in E:\xampp\htdocs\ci\system\helpers\url_helper.php:535) in Any idea how to solve this quickest way? phpbb files that

CodeIgniter - Autoload

只谈情不闲聊 提交于 2019-12-10 20:43:50
问题 I was wondering what the best practices for CodeIgniter's autoload are. Is it bad practice to just autoload everything I might ever need, or is it okay to do so? Does this put more load on the application? At the moment I'm just autoloading the libraries and helpers I'll be using throughout my application: $autoload['libraries'] = array('database', 'session', 'parser'); $autoload['helper'] = array('url', 'form'); So I'm basically wondering if this is 'okay' to do or if I should just load some

how to include a file inside a model in codeigniter?

半腔热情 提交于 2019-12-10 18:50:36
问题 I’m new to codeigniter and maybe my question is a bit stupid but..I cant understand how I can include a file inside a model. Inside del model folder I’ve a subfolder named include and inside this I’ve some php file. The structure is something like that: -models —mymodel.php —include —-file.php —-file1.php Inside mymodel.php how I can include the file.php? I’ve heard that the relative path is allways the index.php, so I’ve tried: include ‘models/include/file.php’ but it seems not working. I’ve

CodeIgniter Session spammed by bots

∥☆過路亽.° 提交于 2019-12-10 16:45:02
问题 I have a site with roughly 2000 visitors per day, and the site is spammed with the various search engine bots. I tried reducing the session expire time to 20 minutes, and still I get alot of mysql_slow_queries. So I was looking into the article, Google crawler, cron and codeigniter sessions, to fully ignore the bots from the sessions table , but the the way they do is, ignore the IPs , but as I was analyzing the database I see that the same bot uses different IPs . I noticed that the bots use

Codeigniter : Cant load database in my library.

非 Y 不嫁゛ 提交于 2019-12-10 15:49:21
问题 When I try to call $this->load->database(); yields the following error `"Call to a member function database() on a non-object" Autoloading the database doesnt help too... when I try to autoload it. all calls to database like $this->db->get('people'); it says get method is undefined... I have no clue what and where to start.. \ anyone ? 回答1: Go to autoload.php in application/config/autoload.php and add this $autoload['libraries'] = array('database'); // add database in array Make sure your