codeigniter-2

Getting error while placing pagination on search in codeigniter

痴心易碎 提交于 2019-12-31 05:39:06
问题 I am getting an error while placing pagination on search in Codeigniter. I tried the following code. on moving to next page it showing an error page. $search = $this->input->get('query'); $data['snippets'] = $this->Constant_model->search($search); $config = array(); $config["base_url"] = base_url() . "search?query=".$search; $config["total_rows"] = $this->Constant_model->search_query_result_count($search); $config["per_page"] = 12; $config["uri_segment"] = 2; $config['full_tag_open'] = '<ul

Storing specific Date/Time values for users in different time zones

蹲街弑〆低调 提交于 2019-12-31 04:31:27
问题 I'm working on a PHP(CodeIgniter)/MySQL application that allows users select when their blog post will be published. How I have designed it to work so far is as below: User sets the timezone in his/her profile. User sets the publish date of the blog post. This date/time is assumed to be based on user's timezone. Based on user's timezone, the publish date is converted to UTC (00:00). The converted date is stored as DATETIME in mysql. Server frequently converts the stored DATETIME values to

Create Unique field in Codeigniter DBForge Migration

假如想象 提交于 2019-12-30 17:41:26
问题 How can I make the financial_year field as unique using Codeigniter Dbforge migration? function up() { $this->dbforge->add_field(array( 'id' => array( 'type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE ), 'financial_year' => array( 'type' => 'VARCHAR', 'constraint' => 20 ), 'start_date' => array( 'type' => 'DATE' ), 'end_date' => array( 'type' => 'DATE' ), 'status' => array( 'type' => "ENUM", 'constraint' => "'Active','Inactive'", 'default' => "Active" ),

CodeIgniter: custom validation rules can't be in a helper?

心已入冬 提交于 2019-12-30 12:04:52
问题 I've created a "validation helper" that was supposed to have all my custom validation rules. The problem is that when I use them in my form validation, they seem to be ignored. If I move the functions in the controller that is doing the form validation, everything works like a charm. My validation helper is autoloaded. Is there any reason why I can't seem to use these validation functions if I put them in a helper? Thanks. 回答1: A function in a helper and a controller are different obviously.

CodeIgniter: Parse dynamic language captions located in javascript

ⅰ亾dé卋堺 提交于 2019-12-30 07:19:08
问题 I have a javascript code that needs localisation, ie. function js_proc() { var some_data = 'this text needs to be translated dynamically at runtime'; } So I re-wrote like this: function js_proc() { var some_data = <?php echo $this->lang->line('some_data_id'); ?>; } In the view, I wrote the js link like this: <script type="text/javascript" src="www.domain.com/codeigniter/get_js/file-1/"></script> which calls the function get_js() in the controller. The idea is to have the get_js() function

How to implement dynamic subdomains in codeigniter with .htaccess?

落花浮王杯 提交于 2019-12-29 13:31:50
问题 How can I implement dynamic subdomains in codeigniter with .htaccess ? 回答1: Make sure that subdomains are enabled on your site. When you enter test.yoursite.com it should take you to the welcome page of your site. If instead it gives DNS lookup error then it means subdomains is not enabled on your site. To enable subdomains on your site add *.yoursite.com entry to the DNS Zone records. Second insert the following code in your .htaccess file and replace yoursite appropriately. <IfModule mod

creating a core class that extends another core class codeigniter [duplicate]

こ雲淡風輕ζ 提交于 2019-12-29 08:23:42
问题 This question already has answers here : Codeigniter extending extended MY_Controller (5 answers) Closed 5 years ago . class Settings extends USER_Controller {...} class USER_Controller extends MY_Controller {...}//limit access to user and define some params and functions that is user depended class MY_Controller extends CI_Controller {...}//provide extra functionality accross all controllers well if i try to create above 3 class's this will not work. yet if i just use settings extends MY

SQL query escaping + codeigniter

南楼画角 提交于 2019-12-29 06:25:18
问题 I'm using codeigniter and most of the time use active record for my queries (which automatically escapes them), but this query doesn't seem to fit neatly into it because of the variable. So I need to figure out how to escape the query manually. Codeigniter docs suggest escaping the queries this way: $sql = "INSERT INTO table (title) VALUES(".$this->db->escape($title).")"; My original query $sql = "SELECT * FROM (`user_language`) WHERE `user_id` = '{$id}'"; My escaped query $sql = "SELECT *

Where to place global functions in codeigniter

徘徊边缘 提交于 2019-12-29 03:40:08
问题 I have created a few utility functions like one h() that acts as echo htmlentities($var) . I want theses functions to be available everywhere . so where do i put it. 回答1: As @david barker said, you might use an helper. Create a file named, for example, "site_helper", that contains all the functions. be aware you need to check if the function already exists, though, or you'll get an "function already declared" error. So, something like: file site_helper.php (in application/helpers/ ) if(

I want to convert this query in codeigniter to Ignited datatable query

不想你离开。 提交于 2019-12-29 01:53:10
问题 I dont know how to convert this long model function to ignited datatable query. I have done small select functions with ignited datatables.Anybody know??? I have no idea about how to covert it. Is there any functions to do it? public function fetch_data() { $this->db->from('jil_requirements'); $this->db->join('jil_users', 'jil_requirements.rqm_userid=jil_users.usr_id', 'left'); $this->db->join('jil_merchants', 'jil_requirements.rqm_createdempid=jil_merchants.mer_id', 'left'); $this->db->where