Php 不使用serialize将数据数组发送到函数

Php 不使用serialize将数据数组发送到函数,php,arrays,cakephp,arraylist,Php,Arrays,Cakephp,Arraylist,我有一个从excel加载数据的数组,现在我需要将此数据发送到另一个视图以查看测试,但找不到,因为它是函数中的数组,我尝试使用序列化和取消序列化,但这会在url中发送字符限制错误 public function excel() { $this->loadModel('SoyaProductorCompra'); $excel=array(); $k=0; if ($this->request->is('post')) { $dato

我有一个从excel加载数据的数组,现在我需要将此数据发送到另一个视图以查看测试,但找不到,因为它是函数中的数组,我尝试使用序列化和取消序列化,但这会在url中发送字符限制错误

public function excel() {
    $this->loadModel('SoyaProductorCompra');
    $excel=array();
    $k=0;
    if ($this->request->is('post')) {
        $datos = new Spreadsheet_Excel_Reader();
        $datos->read($this->request->data['SoyaProductorCompra']['excel']['tmp_name']);
        for ($i = 2; $i <= $datos->sheets[0]['numRows']; $i++) {
            $excel[$k]['producto']=$datos->sheets[0]['cells'][$i][1];
            $excel[$k]['toneladas']=$datos->sheets[0]['cells'][$i][2];
            $excel[$k]['precio']=$datos->sheets[0]['cells'][$i][3];
            $excel[$k]['total']=$datos->sheets[0]['cells'][$i][4];
            $excel[$k]['fecha']=$datos->sheets[0]['cells'][$i][5];
            $excel[$k]['id']=$datos->sheets[0]['cells'][$i][6];
            $k++;

        }
        $this->set('excels',$excel);

        //return $this->redirect(array('action' => 'revision', serialize($excel))); not found
    }
}

不管怎样,我都不会通过查询字符串发送整个电子表格的数据,即使它足够小,可以这样做。我的意思是,如果有人开始手动编辑URL,例如,会发生什么?要么将数据写入文件,要么将其保存在会话中。

您似乎在同一控制器内调用函数,对吗

如果是,那么为什么不使用:

public function excel()
{
    //read excel into $excel variable
    $this->revicionexcel($excel);
}
所以,这里不需要重定向

尽管建议您在
模型层
中读取excel,因为该层适用于所有类型的数据管理

编辑: 然后,根据您的评论,您可以将所有读数移动到模型,并从控制器调用它:

SoyaProductorCompra型号: SoyaProductorCompras控制器:
我们在这里要做的是从action
revision()
调用模型中的excel打开,并将它们发送到视图中。您不需要在此处重定向。

您说得对,但我需要excel中的数据,我不需要该文件。正是出于这个原因,我需要将存储在数组中的数据保存起来,然后发送以供查看和编辑。我看到了执行此操作的选项。是的,但是我如何使用arrayBut重定向到RevisionExcel?是否有任何理由使用重定向而不是普通的方法调用?是的,因为在保存之前需要处理这些数据,因为这样做需要显示数据并编辑或删除一些数据。
public function excel()
{
    //read excel into $excel variable
    $this->revicionexcel($excel);
}
public function excel($data) {
    //your excel reading function as you have it on the controller.
    //change all "$this->request->data" references for the parameter "$data"
    //be sure to return the excel properly.
    ...
    return $excel;
}
public function revision()
{
    $excel = $this->SoyaProductorCompra->excel($this->request->data);
    $this->set('excels', $excel);
}