codeigniter

SELECT from subquery in Codeigniter Active Record

怎甘沉沦 提交于 2021-01-27 13:41:38
问题 How would I do the following query in Codeigniter ActiveRecord : - SELECT *, (SELECT image_path FROM image WHERE image_table = 'model' AND image_table_id = model_id GROUP BY image_table_id LIMIT 1) AS ModelImg FROM (SELECT * FROM vw_newcars where offer_table = 'derivative' order by offer_order ) x WHERE make_name = 'Fiat' group by offer_table_id limit 12 The part I'm having problems with is how to do a select from subquery in Active Record. I don't see a from_select function or anything

How to get avg rating per product using codeigniter query?

戏子无情 提交于 2021-01-27 12:53:31
问题 I have rating table which have rating for every product given by user, I am retrieving all rating records, but at the same time I want to get avg rating based on per product but I am unable to get ouptput Query : $this->db->select('ratings.*'); $this->db->select('select AVG(ratings) as avg_rating from ratings group by product_id'); $this->db->from('ratings'); $this->db->join('users','users.id=ratings.user_id'); $this->db->get()->result(); Rating table id user_id product_id rating 1 4 1 4 2 5

Submit Canvas Data in an HTML Form

笑着哭i 提交于 2021-01-27 12:16:26
问题 How can I submit Canvas content inside a PHP CodeIgniter form? One of the inputs on my form is a Canvas for a drawing or webcam photo. I created a tag <input name="picture" type="hidden"> and set its value to the base64 content: myPictureInput.value = canvas.toDataURL(); However, when the user submits the form, the POST value read from the <input> is truncated to 64kb. Is there an optimal way to post or submit images together with form data? 回答1: As mentioned in this answer, you should send

Codeigniter - Get current route

喜夏-厌秋 提交于 2021-01-27 12:07:51
问题 I'm looking for help to know which route my Codeigniter application goes through. In my application folder in config/routes.php i got some database generated routes, could look like this: $route["user/:any"] = "user/profile/$1"; $route["administration/:any"] = "admin/module/$1"; If i for example to go domain.net/user/MYUSERNAME, then i want to know that i get through the route "user/:any". Is it possible to know which route it follows? 回答1: One way to know the route could be using this: $this

You don't have permission to browse the server?

只愿长相守 提交于 2021-01-27 04:25:34
问题 I am using kcfinder with ckeditor. While changing disabled to false in config file of kcfinder there is no problem but on overriding it with $_SESSION['KCFINDER'] = array( 'disabled' => false ); i am unable to browse & upload files there.Message pop up's showing you don't have permission to browse the server. (framework used CI 3.x.) 回答1: Try this. Make following changes to main index.php file //$system_path = 'system'; $system_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'system'; //

You don't have permission to browse the server?

半腔热情 提交于 2021-01-27 04:25:11
问题 I am using kcfinder with ckeditor. While changing disabled to false in config file of kcfinder there is no problem but on overriding it with $_SESSION['KCFINDER'] = array( 'disabled' => false ); i am unable to browse & upload files there.Message pop up's showing you don't have permission to browse the server. (framework used CI 3.x.) 回答1: Try this. Make following changes to main index.php file //$system_path = 'system'; $system_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'system'; //

The requested URL was not found on this server

时间秒杀一切 提交于 2021-01-21 05:51:31
问题 While hosting a codeigniter website on my server, the first page is coming through fine and the other links are showing an error as shown below. Not Found The requested URL /site/ourservices was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. How to sort this out? I am a beginner. 回答1: Add these lines to .htaccess : (based on codeigniter urls docs) RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f

What is CI_Controller built_in class? whether it is abstract or not?

匆匆过客 提交于 2021-01-20 09:37:53
问题 I have searched alot that what is CI_Controller class? Actually, it is a base class and all controllers extend from CI_Controller class in codeigniter? Whether, it is abstract class or not? 回答1: in your directory structure open system->core->controller.php you will see the class name is CI_Controller 来源: https://stackoverflow.com/questions/43602164/what-is-ci-controller-built-in-class-whether-it-is-abstract-or-not

What is CI_Controller built_in class? whether it is abstract or not?

和自甴很熟 提交于 2021-01-20 09:36:49
问题 I have searched alot that what is CI_Controller class? Actually, it is a base class and all controllers extend from CI_Controller class in codeigniter? Whether, it is abstract class or not? 回答1: in your directory structure open system->core->controller.php you will see the class name is CI_Controller 来源: https://stackoverflow.com/questions/43602164/what-is-ci-controller-built-in-class-whether-it-is-abstract-or-not

How to count the number of rows with a date from a certain year in CodeIgniter?

白昼怎懂夜的黑 提交于 2021-01-20 08:59:24
问题 I have the following query. $query = $this->db->query('SELECT COUNT(*) FROM iplog.persons WHERE begin_date LIKE '2014%''); I need to count the number of columns with a begin_date in the year 2014. When I run this script I'm getting an error: Parse error: syntax error, unexpected '2014' (T_LNUMBER) in C:\xampp\htdocs\iPlog2\application\controllers\stat.php on line 12 I was trying to change my CI script to $query = $this->db->query('SELECT COUNT(*) FROM iplog.persons WHERE begin_date LIKE "2014