codeigniter

Check number of affected rows in CodeIgniter

 ̄綄美尐妖づ 提交于 2019-12-23 07:39:17
问题 I am trying to check in my model method if there was affected any rows if so return true else return false, but I don't know how to get it?: class User_model extends CI_Model { function __construct() { parent::__construct(); } function save_new_user ($name, $email, $password) { $data = array( 'name' => $name, 'email' => $email, 'password' => $password, 'time' => time() ); $this->db->insert('users', $data); // if (affected rows > 0) return true else return false if ([AFFECTED_ROWS] > 0) return

How can I access a CodeIgniter configuration variable from a model/controller?

早过忘川 提交于 2019-12-23 07:39:05
问题 I would like to access the $db['default']['dbprefix'] variable from /application/config/database.php (CodeIgniter configuration file) from within a model so I can write my own queries using the value from the file. How can this be done? 回答1: Try: $this->load->database(); echo $this->db->dbprefix; Normally you can use $this->config->item but I think that only allows variables set in $config 回答2: The documentation says you should be using: $this->db->dbprefix('tablename'); Doesn't make a huge

CodeIgniter - Private functions

£可爱£侵袭症+ 提交于 2019-12-23 07:16:11
问题 I have started playing with CodeIgniter now. And I use their user guide and other third-party tutorials available for learning. I'm a bit stuck at the naming of private functions. Based on the user guide, I have to prefix a _ in the name of private functions. But in this tutorial, check the Add Logout section. In it, there is a private function: private function check_isvalidated() . Here, it is not prefixed with the character _ . So that's also an accepted naming convention ? At the same

Codeigniter:$query->free_result() when using active record?

老子叫甜甜 提交于 2019-12-23 07:07:38
问题 after i have finished with my result set from a active record query in a CodeIgniter model, should I use $query->free_result() or does ActiveRecord automatically do that? 回答1: PHP will clean up everything after your script is done. However, if you have lots of queries in, say, a loop, the results will not be cleaned up after each iteration. So, if you run lots of queries in a loop, you probably will want to free_result() to clear up memory. Otherwise, it's not necessary. See here for details:

Linking wordpress blog to CodeIgniter View

天大地大妈咪最大 提交于 2019-12-23 06:26:05
问题 Well, here's the deal. I have this site with a framework called codeigniter. It's a MVC framework in PHP. I'm trying to use the wordpress API in order to set up a view in CodeIgnite that uses the wordpress API to get blog posts. so the blog is in /wp-blog/ , and the codeigniter framework is set up in /system/ . so in the codeigniter view, I call require_once('/wp-blog/wp-load.php'); the wp-load file opens a config file with the database info on it. However, when i call it from my view, it

Validation is not working in codeigniter

老子叫甜甜 提交于 2019-12-23 06:19:07
问题 Validation is not working. All the form fields are coming dynamically. It depends on the user how many fields he chooses.If he chooses 2 and it will display 2 fields in the view. If select 3 then it will display 3 fields and so on.I have more than 30 fields I set 3 arrays(for testing purpose I set only 3. It will be total no of fields ) in my form validation page. If I remove the last array than validation is working because I am getting only 2 fields in the view. I am not able to use the

Validation is not working in codeigniter

给你一囗甜甜゛ 提交于 2019-12-23 06:19:06
问题 Validation is not working. All the form fields are coming dynamically. It depends on the user how many fields he chooses.If he chooses 2 and it will display 2 fields in the view. If select 3 then it will display 3 fields and so on.I have more than 30 fields I set 3 arrays(for testing purpose I set only 3. It will be total no of fields ) in my form validation page. If I remove the last array than validation is working because I am getting only 2 fields in the view. I am not able to use the

What is the best Authentication and Authorization library for CodeIgniter? [closed]

℡╲_俬逩灬. 提交于 2019-12-23 06:15:41
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I intend building an application using CodeIgniter so I'm currently identifying all the features I want. I would like to know if there are any recommendations for Authentication & Authorization libraries for CodeIgniter. 回答1: I think QuickAuth is the best one. But there is one good list in: http://codeigniter.com

how to change a select list option when other select list changed?

混江龙づ霸主 提交于 2019-12-23 06:13:52
问题 I have two selectlists in my html and both have the values saved in database, I want to know how to change values in selectlist 2 when select 1 is changed by user using jquery? I am trying to do these things in codeigniter, so please help me, I have done these things using jquery before but that was in simple php by passing the values to the load function of jquery, but this is not working in codeigniter, anyone please help me Thanks, Shah RUkh 回答1: Say for example you have this drop down

Codeigniter pagination showing duplicate records with page query string

最后都变了- 提交于 2019-12-23 06:08:38
问题 i have created pagination with codeigniter 3. On every page i am getting same results: my final url seems like: http://localhost/shoping/products/mobile-phones?cid=3&page=2 Controller file: public function category(){ $category_id = $this->input->get('cid', TRUE); $slug = $this->uri->segment(2); $sortby = $this->input->get('sort', TRUE); $sorttype= 'ASC'; $limit = 10; $config = array(); $config['base_url'] = base_url() . 'products/'.$slug.'?cid='.$category_id; $config['total_rows'] = $this-