Viewed   225 times

What is the most simplist way to generate reports in Codeigniter framework? Is there any library available to do this task? Except charting what are the other resources to do this.

 Answers

2

Found a nice solution myself. If you want to generate reports in csv format it is very easy with codeigniter. Your model function

function index(){
return $query = $this->db->get('my_table');
    /*
    Here you should note i am returning 
    the query object instead of 
    $query->result() or $query->result_array()
    */
}    

Now in controller

function get_report(){
    $this->load->model('my_model');
    $this->load->dbutil();
    $this->load->helper('file');
    /* get the object   */
    $report = $this->my_model->index();
    /*  pass it to db utility function  */
    $new_report = $this->dbutil->csv_from_result($report);
    /*  Now use it to write file. write_file helper function will do it */
    write_file('csv_file.csv',$new_report);
    /*  Done    */
}

No externals are required everything is available in codeigntier. Cheers! If you want to write xml file it is easy too.
Just use xml_from_result() method of dbutil and use write_file('xml_file.xml,$new_report) Visit these links they will help.

Database Utility Class

And

File Helper

Wednesday, August 24, 2022
1

You are using Firefox, aren't you?

You could try looking at system/libraries/Upload.php line 199:

$this->_file_mime_type($_FILES[$field]);

Change that line to:

$this->_file_mime_type($_FILES[$field]); var_dump($this->file_type); die();

Then do upload your .wmv file. It would show something like application/octet-stream or whatever. Add that to your mimes.php. Hope this help =)

Similar answer here

Some links:

  • CodeIgniter forum's thread
  • Mimetype corruption in Firefox
  • Getting around IE’s MIME type mangling
Saturday, December 10, 2022
5

SOLUTION: I've try to upload it to server. But it still gives me the same error. Then i found this: Codeigniter : The filetype you are attempting to upload is not allowed. Yesterday it was fine "The most recent time I have had this is when I upgraded my core Codeiginter version from 2.x to 3.x. I updated the contents of the system directory, but not application/config. I didn't spot the fact that the application/config/mimes.php file is slightly different - the newer version returns an array whereas the old one included it as a var. The fix was to copy in the newer version of mimes.php"

Wednesday, September 21, 2022
 
1

Noticed several issues in code. required & array spelling is wrong moreover wrong syntax used in last params in form_dropdown() function

Try this

<div class="col-md-5 ">
  <div class="control-group form-group">
    <label class="control-label">
      Escalation Email Ids
    </label>
    <div class="controls">
      <?php $options=array(); if(count($useridsoptions)){ foreach($useridsoptions as $key=>$val){ $options[$key]=$val; } } echo form_dropdown('esc_users[]', $options, explode(",",$row->esc_users),'id="esc_users" class="form-control function col-md-12 select2" required="required" multiple'); ?>
    </div>
  </div>
</div>
Saturday, November 26, 2022
2

You need to remove index.php from your url.Create .htacces file and place in your root.Copy this code and run

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

for more how to remove index.php form url try this http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/

Friday, December 2, 2022
5

Please try below solution.

You have missed dynamic classes adding in div like apps and joomla

<div class="portfolio-item apps joomla col-xs-12 col-sm-4 col-md-3">

added class in above line with your existing code

<?php
foreach($results as $row) {
//code for getting dynamic class names from db
$class = explode(",.", $row->type);
$gettypes = implode(" ", $class); 
?>
<div class="portfolio-item <?php echo $gettypes;?> col-xs-12 col-sm-4 col-md-3">

Hope this work!

Friday, August 12, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :