dshmkgq558192365 2009-02-12 06:45
浏览 22

修复cakePHP中的'return'以从视图控制器函数返回Value

I have a function inside of a view function inside of a model class in the model.php file that looks like this

function sqlToUnix($date){
    $YMDThenHMS = explode(" ", $date);
    $YMD = explode("-", $YMDThenHMS[0]);
    $HMS = explode(":", $YMDThenHMS[1]);
    $UnixTime = mktime($HMS[0], $HMS[1], $HMS[2], $YMD[1], $YMD[2], $YMD[0]);

    return $UnixTime;
}

The problem is, when it returns $UnixTime, The return value is usable inside the model controller specific view function but it won't render my view (stops script propogation)

Is there a place where I can build functions like this up for use ANYWHERE in ANY Controller?

Such as the function time() built into PHP itself, I want to be able to use sqlToUnix anywhere

  • 写回答

5条回答 默认 最新

  • duanduan1993 2009-02-12 06:47
    关注

    I was able to fix the problem by storing the function in the appController.php and called the function when need be using

    $this->sqlToUnix($SQLDate);
    

    Sorry about asking the question but I just remembered the appController when I posted this ><

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大