codeigniter-3

Mysql error handling/Try catch

…衆ロ難τιáo~ 提交于 2019-12-25 09:27:55
问题 If table column does not exist mysql shows error .How to fix it using try catch or error handling method Thanks 回答1: you can handle the mysql error in this way if ( ! $this->db->query('SELECT `name`,`age` FROM `example`')) { $error = $this->db->error(); // Has keys 'code' and 'message' } 来源: https://stackoverflow.com/questions/44732546/mysql-error-handling-try-catch

How to check email address or username is valid or exist through same post?

假装没事ソ 提交于 2019-12-25 08:00:09
问题 How to check email address or username is valid or exist through same post? HTML <form action="/index" method="post"> <input name="post" type="text" value="Username or Email" /> <input name="submit" name="send" value="Submit" /> </form> PHP public function index($post) { $results = $this->db->where('username', $post) ->where('email', $post) ->get('users'); if($results->num_rows() > 0) { //The user has an email or username echo "valid"; } else { echo "Invalid"; } } 回答1: Change the second -

“Undefined property” error in CodeIgniter code

让人想犯罪 __ 提交于 2019-12-25 05:43:50
问题 I am following a TutsPlus "Build a CMS" tutorial for Codeigniter. It includes this bit of code: if (!count($this->db->ar_orderby)) { $this->db->order_by($this->_order_by); } Which results in this message: Undefined property: CI_DB_mysqli_driver::$ar_orderby. Filename: core/MY_Model.php Line Number: 29 How can I fix this error? Here is the code in MY_Model.php : <?php class MY_Model extends CI_Model { protected $_table_name = ''; protected $_primary_key = 'id'; protected $_primary_filter =

Login sessions data and can we delete session from db in code igniter

时光毁灭记忆、已成空白 提交于 2019-12-25 05:18:40
问题 I made login app using codeigniter 3.0.1, i'm facing couple of problems. First is things are not working when i don't check the 'remember me' check box and it still logs the user in when i close the browser and open it again with direct link "localhost/ci_login_app/index.php/account" seems like $config['sess_expire_on_close'] = TRUE; have no effect on it :/ i have configured config.php like this $config['sess_driver'] = 'database'; #$config['sess_cookie_name'] = 'ci_session'; $config['sess

How to check the date type in array in PHP

拜拜、爱过 提交于 2019-12-25 04:55:16
问题 I'm using PHPExcel to read the data, and then validating the data. Problem I'm getting is all the data is validating except I don't know how to check the array if it has a date or not. Problem is not a format, problem is I'm unable to find a way to check whether it is a date or another string or integer. These are one of my value in a date cell in Excel file. i.e ; 1/2/15 17:24 1/7/15 12:00 1/9/15 11:57 回答1: For each cell you can check if this is a date : if(PHPExcel_Shared_Date::isDateTime(

how to view individual field of the table in codeigniter

喜夏-厌秋 提交于 2019-12-25 02:19:08
问题 I have created following table in mysql I want to retrieve one of the field i.e abstract or author or Title by using id dynamically in view field. These are my model, controller and view code. Model:This is my model $this->db->select("*"); $this->db->limit(10); $this->db->from("abcde"); $query = $this->db->query("SELECT * FROM abcde ORDER BY DocumentID ASC"); Controller: this is my controller here $this->load->model("Sample_model"); $data["fetch_data"] = $this->Sample_model->fetch_data();

How to use pagination in codeigniter with $this->db->query()?

浪尽此生 提交于 2019-12-25 01:49:39
问题 I am developing a project on codeigniter , I am facing difficulty while creating pagination of records. Actually, when I user $this->db->get() then its okay, pagination work fine. But when do pagination using $this->db->query() then pagination is nor working, following is the code in my controller . $this->load->library('pagination'); $pagination_config['base_url'] = base_url().'welcome/index'; $pagination_config['per_page'] = 3; $pagination_config['num_links'] = 3; $pagination_config['total

Codeigniter Clone Data from table and update it

无人久伴 提交于 2019-12-25 01:12:45
问题 What i am trying to do: Try to Clone Data (Update) from Table "Payment" to "Payment History" Payment Table Payment_ID Payment_Amount Payment_Method Payment_Remark Payment History Table Payment_ID PaymentHistory_ID Payment_Amount Payment_Method Payment_Remark Both have the same column and same data type My Code: Controller public function updateHistory($Payment_ID){ $this->db->select('*'); $this->db->from('Payment'); $this->db->where('Payment_ID', $Payment_ID); $query = $this->db->get(); $this

codeigniter inner join error

早过忘川 提交于 2019-12-24 20:56:16
问题 I want to equal some table with Inner Join in Codeigniter. But I give some errors. I put below some codes in my controller. But I give an error like that: A Database Error Occurred Error Number: HY000/1096 No tables used SELECT * Filename: C:/xampp/htdocs/erp/system/database/DB_driver.php Line Number: 691 My Controller Inner Join Here: public function edit($cusId) { $this->lang->load('content', $this->session->userdata('people_lang')); $viewData = new stdClass(); $viewData->customer = $this-

CodeIgniter 3.x - Reload View with Different CSS File Using User Input

两盒软妹~` 提交于 2019-12-24 20:50:27
问题 Problem: I created a static page view (in its own view folder) that demos the new Sakura.css framework. The framework comes with four CSS themes. I want to be able to select a theme from a list of links and reload the same view with the associated CSS theme file via the controller. I also need the view to default to the 'standard.css' theme. Finally, I'd like to avoid JavaScript/jQuery solutions. I'm struggling to grasp the relationship between controller function names, custom routing, and