Asked  7 Months ago    Answers:  5   Viewed   30 times

My controller is like this:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Dashboard extends EX_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this->data['news'] = $this->dashboard_model->get_news();
        $this->load->view('dashboard/index_view', $this->data);
    }

My EX_Controller is like this :

<?php
class EX_Controller extends CI_Controller
{
    public $data;
    public function __construct()
    {
        parent::__construct();

        $this->load->model('notification_model');
        $this->get_notification();
    }

    public function get_notification()
    {
        $session = $this->session->userdata('login');
        $this->data['notification'] = $this->notification_model->get($session);
        $this->data['count_notification'] = $this->notification_model->get_count_notification($session['customer_id']);
    }
}
?>

My index view is like this :

<?php
    foreach ($notification as $value) {
?>
        <li>
        <?php
            echo '<a href='.base_url().'notification/notif/'.$value['notification_id'].'>';
        ?>
                <span class="time">
                <?php 
                    echo time_elapsed($value['notification_created_date']); 
                ?>
                </span>
                <span class="details">
                    <span class="label label-sm label-icon label-info">
                        <i class="fa fa-bookmark"></i>
                    </span> <?php echo $value['notification_message']; ?>
                </span>
            </a>
        </li>
<?php
    }
?> 

When executed, there exist error :

Message:  Undefined variable: count_notification
Message:  Undefined variable: notification

It seems it can not call get_notification function in EX Controller

I put in function get_notification(EX Controller) to be read in all controllers

Any solution to solve my problem?

 Answers

95

The solution to this problem is to just use this:

$this->load->model('notification_model'); 
$this->get_notification();
Wednesday, March 31, 2021
 
Guesser
answered 7 Months ago
44

I've used PHPExcel with CodeIgniter successfully before.

All I did was drop the phpexcel folder into application/third-party and created the following wrapper library:

<?php

class Excel {

    private $excel;

    public function __construct() {
        // initialise the reference to the codeigniter instance
        require_once APPPATH.'third_party/phpexcel/PHPExcel.php';
        $this->excel = new PHPExcel();    
    }

    public function load($path) {
        $objReader = PHPExcel_IOFactory::createReader('Excel5');
        $this->excel = $objReader->load($path);
    }

    public function save($path) {
        // Write out as the new file
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
        $objWriter->save($path);
    }

    public function stream($filename) {       
        header('Content-type: application/ms-excel');
        header("Content-Disposition: attachment; filename="".$filename."""); 
        header("Cache-control: private");        
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');
        $objWriter->save('php://output');    
    }

    public function  __call($name, $arguments) {  
        // make sure our child object has this method  
        if(method_exists($this->excel, $name)) {  
            // forward the call to our child object  
            return call_user_func_array(array($this->excel, $name), $arguments);  
        }  
        return null;  
    }  
}

?>

I could then do the following in my controllers:

$this->load->library("excel");
$this->excel->load("/path/to/input.xls");
$this->excel->setActiveSheetIndex(0);
$this->excel->getActiveSheet()->SetCellValue('B2', "whatever");
$this->excel->save("/path/to/output.xls");

Hope this helps you out?

Wednesday, March 31, 2021
 
CBroe
answered 7 Months ago
75

the problem is that the excel file is saved version 5, then I should Register with the 2007 version (. xlsx) and the Arabic values ??appear correctly in file properities:

$obj_writer = PHPExcel_IOFactory::createWriter($this->excel, 'Excel2007');
$obj_writer->save('php://output');
Saturday, May 29, 2021
 
BlueNile
answered 5 Months ago
90

You can use the DataGridViewCell.Value Property to retrieve the value stored in a particular cell.

So to retrieve the value of the 'first' selected Cell and display in a MessageBox, you can:

MessageBox.Show(dataGridView1.SelectedCells[0].Value.ToString());

The above probably isn't exactly what you need to do. If you provide more details we can provide better help.

Friday, July 23, 2021
 
simPod
answered 3 Months ago
98

Some of you might be in my situation: I cannot use the import/export utility of datastore, because my data needs to be transformed before getting into the datastore.

I ended up using apache-beam (google cloud dataflow).

You only need to write a few lines of "beam" code to

  • read your data (for example, hosted on cloud storage) - you get a PCollection of strings,
  • do whatever transform you want (so you get a PCollection of datastore Entities),
  • dump them to datastore sink.

See How to speedup bulk importing into google cloud datastore with multiple workers? for a concrete use case.

I was able to write with a speed of 800 entities per second into my datastore with 5 workers. This enabled me to finish the importing task (with 16 million rows) in about 5 hours. If you want to make it faster, use more workers :D

Thursday, July 29, 2021
 
Isky
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share