codeigniter

CodeIgniter: Load controller within controller

為{幸葍}努か 提交于 2019-12-27 17:30:49
问题 I have a home controller with an index action that displays a set of featured products. However, the products are managed through a product controller including a proprietary model and views. How do I access product information from within the index action in the home controller? Instancing product won't work as the class isn't loaded at runtime and CodeIgniter doesn't provide a way to dynamically load controllers. Putting the product class into a library file doesn't really work, either. To

UNION query with codeigniter's active record pattern

元气小坏坏 提交于 2019-12-27 11:06:38
问题 How to do UNION query with PHP CodeIgniter framework's active record query format? 回答1: CodeIgniter's ActiveRecord doesn't support UNION, so you would just write your query and use the ActiveRecord's query method. $this->db->query('SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2'); 回答2: This is a quick and dirty method I once used // Query #1 $this->db->select('title, content, date'); $this->db->from('mytable1'); $query1 = $this->db->get()->result(); //

UNION query with codeigniter's active record pattern

六眼飞鱼酱① 提交于 2019-12-27 11:06:23
问题 How to do UNION query with PHP CodeIgniter framework's active record query format? 回答1: CodeIgniter's ActiveRecord doesn't support UNION, so you would just write your query and use the ActiveRecord's query method. $this->db->query('SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2'); 回答2: This is a quick and dirty method I once used // Query #1 $this->db->select('title, content, date'); $this->db->from('mytable1'); $query1 = $this->db->get()->result(); //

subquery in codeigniter active record

我的梦境 提交于 2019-12-27 10:22:48
问题 SELECT * FROM certs WHERE id NOT IN (SELECT id_cer FROM revokace); How do I write the above select statement in CodeIgniter active record? 回答1: ->where() support passing any string to it and it will use it in the query. You can try using this: $this->db->select('*')->from('certs'); $this->db->where('`id` NOT IN (SELECT `id_cer` FROM `revokace`)', NULL, FALSE); The ,NULL,FALSE in the where() tells CodeIgniter not to escape the query, which may mess it up. UPDATE : You can also check out the

subquery in codeigniter active record

放肆的年华 提交于 2019-12-27 10:20:10
问题 SELECT * FROM certs WHERE id NOT IN (SELECT id_cer FROM revokace); How do I write the above select statement in CodeIgniter active record? 回答1: ->where() support passing any string to it and it will use it in the query. You can try using this: $this->db->select('*')->from('certs'); $this->db->where('`id` NOT IN (SELECT `id_cer` FROM `revokace`)', NULL, FALSE); The ,NULL,FALSE in the where() tells CodeIgniter not to escape the query, which may mess it up. UPDATE : You can also check out the

PHP: CodeIgniter3中函数名不能与控制器名相同的问题

不问归期 提交于 2019-12-26 19:59:40
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> PHP: 有关CodeIgniter3中函数名不能与控制器名相同的问题 在CodeIgniter3开发中遇到一个问题: 控制器名与方法名同名时,报"404 Page Not Found"错误。 比如有个控制器“Controllers/Login.php”: class Login extends CI_Controller{ function login(){ echo 'login'; } } 预期结果是: 可以使用“index.php/login/login”访问此login()函数,输出"login"字符串 实际结果是: 页面报出"404 Page Not Found"错误 查看CodeIgniter3框架代码,在CodeIgniter.php中有这样一段代码: require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php'); if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method)){ $e404 = TRUE; } elseif (method_exists($class, '_remap')

how to remove comma and display records

纵然是瞬间 提交于 2019-12-26 15:21:15
问题 I have a database table package_details which include fields package_id features description in features field I have stored data like feature1,fea2,fea3 and so on. I have separated features by comma. I have to display records. Now my question is how to remove comma and display records one by one like feature1 fea2 fea3 can anyone help me? Thanks. 回答1: $array = explode(',' $data); will explode your string based on comma 回答2: A simple solution : //The initial string where ... represents more

how to remove comma and display records

て烟熏妆下的殇ゞ 提交于 2019-12-26 15:21:02
问题 I have a database table package_details which include fields package_id features description in features field I have stored data like feature1,fea2,fea3 and so on. I have separated features by comma. I have to display records. Now my question is how to remove comma and display records one by one like feature1 fea2 fea3 can anyone help me? Thanks. 回答1: $array = explode(',' $data); will explode your string based on comma 回答2: A simple solution : //The initial string where ... represents more

how to remove comma and display records

强颜欢笑 提交于 2019-12-26 15:19:21
问题 I have a database table package_details which include fields package_id features description in features field I have stored data like feature1,fea2,fea3 and so on. I have separated features by comma. I have to display records. Now my question is how to remove comma and display records one by one like feature1 fea2 fea3 can anyone help me? Thanks. 回答1: $array = explode(',' $data); will explode your string based on comma 回答2: A simple solution : //The initial string where ... represents more

Fatal error: Call to undefined method CI_DB_pdo_driver::where() in

烂漫一生 提交于 2019-12-26 08:52:15
问题 I’m using PDO driver to access MySQL database. Everything is working OK on that part. My database.php looks like this: $active_group = 'default'; $active_record = FALSE; $db['default']['hostname'] = 'mysql:host=127.0.0.1:3386'; $db['default']['username'] = 'root'; $db['default']['password'] = ''; $db['default']['database'] = 'mydatabase'; $db['default']['dbdriver'] = 'pdo'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default'][