douzhushen_9776 2009-08-06 12:30
浏览 10
已采纳

如何在Zend Framework中将当前日期分配给行?

I have the following private method in my form :

    function _verifywebsite ($id) {
    $row = $this->websites->fetchRow("id=$id");
    $row->verified_date = $this->_get_date(); // this is the line in question
    $row->save();
}

I assume that $row requires me to enter date as string value in correct date format.

But what if I want to include some SQL function, like NOW(), can I assign it to $row->verified_date somehow or it's against best practices?

  • 写回答

1条回答 默认 最新

  • dongxiangshen7916 2009-08-06 12:45
    关注

    This code is enabling SQL expression for Active Record field:

    $row->verified_date = new Zend_Db_Expr('now()');

    As ZF Manual says:

    You might need values in the data array to be treated as SQL expressions, in which case they should not be quoted. By default, all data values passed as strings are treated as string literals. To specify that the value is an SQL expression and therefore should not be quoted, pass the value in the data array as an object of type Zend_Db_Expr instead of a plain string.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100