codeigniter

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" ),

Re-populate checkbox if it fails in validation in an edit form in Codeigniter

倖福魔咒の 提交于 2019-12-30 15:02:03
问题 I works on the an data-edit form in codeigintier. And the problem is about re-populate checkbox It works if it is an add form (that means I need not concern about the value in database): <?= set_checkbox('is_default', '1'); ?> for checkbox The problem is, in the edit form: I can't repopulate the checkbox <?php if ($customer_group[0]['is_default'] == "1") echo "checked"; set_checkbox('is_default', '1'); ?> The checkbox will check even I have not check it in the edit => fail to validate in the

How to modify CodeIgniter calendar to handle multiple events per day?

只谈情不闲聊 提交于 2019-12-30 14:43:35
问题 I am creating a calendar without jquery calendar plugin. I could retrieve the data which is in the database to the calendar. But when there are multiple data per day only one data comes to the calendar view. I want it to be like this when there is multiple data. But what i am getting is this when there are multiple data the day 16 has every four data.but it shows only one. If anyone has an idea about this it would be help me. following are my code Controller <?php class My_calendar extends CI

Check if user is on page

ⅰ亾dé卋堺 提交于 2019-12-30 13:38:33
问题 I'm building a one on one chat application that allows users to host rooms. Just to give a little more feedback: User creates room (rooms are public, anybody can view but if user hasn't signed up, chat will be disabled and user will be prompted to sign up for chat.) Other users sign up for room Users chat with host based on order they signed up I would like to show if the host is online or not. Or to go one step further, show if the host is in the room. I'm not sure how to do this. 回答1:

Query log in codeigniter using hook

自闭症网瘾萝莉.ら 提交于 2019-12-30 13:26:30
问题 I need to create a query log in my project. So I created a post_controller hook. It saves all the executed queries in both a text file and a database. But it works only for SELECT queries. I know it is repeated question, but after a lot of search, I couldn't find solution. Here is my code: config/hooks.php: $hook['post_controller'] = array( 'class' => 'LogQueryHook', 'function' => 'log_queries', 'filename' => 'log_queries.php', 'filepath' => 'hooks' ); hooks/log_queries.php class LogQueryHook

CodeIgniter - uploading multiple files with one input

半世苍凉 提交于 2019-12-30 13:11:52
问题 I'm trying to upload several files at once from ONE input : <input type="file" name="form-image[]" id="form-image" multiple="true" /> Which itself without CodeIgniter works fine. In my attempt to do the same thing with CodeIgniters file helper; I get an error (is_uploaded_file() expects parameter 1 to be string, array given), which indicates that I am doing something wrong, or CodeIgniter simply doesn't support multiple files? My faulty code so far: //Iterate through each file uploaded for (

CodeIgniter - uploading multiple files with one input

北城以北 提交于 2019-12-30 13:11:35
问题 I'm trying to upload several files at once from ONE input : <input type="file" name="form-image[]" id="form-image" multiple="true" /> Which itself without CodeIgniter works fine. In my attempt to do the same thing with CodeIgniters file helper; I get an error (is_uploaded_file() expects parameter 1 to be string, array given), which indicates that I am doing something wrong, or CodeIgniter simply doesn't support multiple files? My faulty code so far: //Iterate through each file uploaded for (

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 - Best way for checking true result

痞子三分冷 提交于 2019-12-30 11:33:08
问题 What’s the best way for checking if some method in model or anywhere else was correctly carried out? Is this a good way? Model: $data['field1'] = $this->input->post('field1'); $data['field2'] = $this->input->post('field2'); $data['field3'] = $this->input->post('field3'); if ($this->db->insert('table', $data)) { return TRUE; } else { return FALSE; } Controller: if ($this->form_validation->run() == FALSE) { $this->load->view('page_view', $data); } else { if ($this->Model->Insert_data()) { $this

Uploading zip and rar file not working in codeigniter

纵然是瞬间 提交于 2019-12-30 11:29:33
问题 setting i have created for allowed type: $config['allowed_types'] = 'doc|docx|pdf|xls|xlsx|rtf|txt|rar|zip'; and in my mine.php 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed','application/force-download'), 'rar' => array('application/x-rar', 'application/rar','application/x-rar-compressed','application/force-download'), this is all i have configured but when i do the zip or rar upload its shows me error that "The filetype you are attempting to upload is