codeigniter-2

CodeIgniter rename email attachment file

◇◆丶佛笑我妖孽 提交于 2019-12-12 12:05:45
问题 I have CodeIgniter script for sending email with attachments. $this->ci->email->attach("/path/to/file/myjhxvbXhjdSycv1y.pdf"); It works great, but I have no idea, how rename attached file to some more user-friendly string? 回答1: CodeIgniter v3.x This feature has been added since CI v3: /** * Assign file attachments * * @param string $file Can be local path, URL or buffered content * @param string $disposition = 'attachment' * @param string $newname = NULL * @param string $mime = '' * @return

Heroku PHP app crash bash: vendor/bin/heroku-php-apache2: No such file or directory

我的未来我决定 提交于 2019-12-12 08:45:39
问题 I'm not very good with Heroku setup I'm trying to put online an app in PHP (with Code Igniter) but it doesn't work well. Here is the error : Heroku PHP app crash bash: vendor/bin/heroku-php-apache2: No such file or directory index.php is in root folder. Vendor directory also in root folder composer made his job In procfile : web: vendor/bin/heroku-php-apache2 And in my index.php: require('vendor/autoload.php'); In the past I used the boot.sh way, so I'm not comfortable with the new way. I

How to display image from database in CodeIgniter?

不问归期 提交于 2019-12-12 08:45:28
问题 I am using CodeIgniter 2.1.0 and MySQL database. I have uploaded an image through a form and successfully stored it in a uploads directory and I have also successfully stored the full path of the image in my database. but i am having problem with showing the image by calling the full path from my database. Here is my code for the upload: $image_path = realpath(APPPATH . '../uploads'); $config = array( 'allowed_types' => 'jpeg|png|gif|jpg', 'upload_path' => $image_path, 'max_size' => 2097152,

passing data from hook to view in codeigniter

这一生的挚爱 提交于 2019-12-12 08:12:41
问题 can i passing data from hook to view, If is it possible please explain. for example $hook['post_controller_constructor'][] = array( 'class' => 'Varify_user', 'function' => 'user_project', 'filename' => 'varify_project.php', 'filepath' => 'hooks', 'params' => array('') ); i want send some array data varify_project.php(hook file) to view. 回答1: I do so application/core/MY_Loader.php class MY_Loader extends CI_Loader { static $add_data = array(); public function view($view, $vars = array(),

Codeigniter: does $this->db->last_query(); execute a query?

☆樱花仙子☆ 提交于 2019-12-12 07:38:58
问题 Does query execution happen at the get_where() clause of the following codeigniter active record statement? $this->db->select('*'); $q = $this->db->get_where('Contacts', array('id' => $contact_id)); $sql = $this->db->last_query(); Or does it happens once you call the result_array() ? And is $this->db->last_query(); a reliable way in getting the query string. 回答1: The query execution happens on all get methods like $this->db->get('table_name'); $this->db->get_where('table_name',$array); While

CodeIgniter custom validation errors for each rule per each field

走远了吗. 提交于 2019-12-12 06:55:39
问题 I'm using CodeIngiter 2.1 and I wanna define custom validation errors for each rule per each field. The fields are as follows. array( 'field' => 'firstname', 'rules' => 'required', 'error' => 'This field cannot be empty.' ), array( 'field' => 'email', 'rules' => 'required', 'error' => 'The email cannot be empty.' ) But In CodeIgniter only one error message is defined for one rule. So how to override that one and Please suggest some solutions for getting different errors for perticular field.

Form Actions in Codeigniter gets added to the existing URL

泄露秘密 提交于 2019-12-12 04:48:16
问题 I am new to codeigniter and i am facing a small issue. I have a controller named "test" and would like to call the "edit_details" action within that controller. This is a test application i am developing. I would like to update a user's information and i am sending the user id via(URL segments) the URL: "http://localhost/codeigniter/index.php/test/edit/12" as an example. The edit action loads the view with a form where the user's details could be entered. This is done using an anchor from the

How to simulate a transaction failure? [closed]

落花浮王杯 提交于 2019-12-12 04:18:39
问题 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 3 years ago . I am utilising transactions for some MySQL queries where I am doing multiple inserts across a few tables. After the transaction has been committed, I am checking the status, throwing an error/exception if it failed. However, I am struggling to test the case where it fails. I tried garbling up a column name, but

Class not found

流过昼夜 提交于 2019-12-12 03:11:38
问题 I'm new to MVC and Codeigniter and am trying to get a class working. I'm running CodeIgniter 2.1.0 and Doctrine 2.2.1 When my code calls the submit() function, I get Class 'Myclass_model' not found , and references to the line that includes: $u = new Myclass_model(); (See edit note at the bottom, now getting Class 'Doctrine_Record' not found in the model where it is extended) In my controller is the following code: public function submit() { if ($this->_submit_validate() === FALSE) { $this-

How to inter link three mysql tables using Codeigniter

梦想的初衷 提交于 2019-12-12 03:11:27
问题 I have the following three tables. I am trying to inter link (join) among these three tables like this- link 1 table1.code=table2.account-code table1.code=table3.t-code table2.voucher_no=table3.voucher_no I tried to query in Codeignitier's way but I get an error message that says table1 is not unique or something like that. here's what I tried(and got the error) $this->db->select('*'); $this->db->from('table2'); $this->db->join('table3', 'table2.voucher_no = table3.voucher_no'); $this->db-