使用时间时 Phalcon Oracle 日期时间错误

Phalcon Oracle datetime error when time is used

我的模型中有这个保存方法:

public function save($data = null, $whiteList = null){
    $res = false;
    $sql = '';
    $di = \Phalcon\DI::getDefault();
    try {   
        $param = array("[fecha] = to_date('" . $this->fecha . "', 'YYYY-MM-DD HH24:MI:SS') and [parametro_id] = :parametro_id:",
                        "bind" => array("parametro_id" => $this->parametro_id) );
        $primero = Instantaneos::findFirst($param);
        if ($primero){
            $this->instantaneo_id = $primero->instantaneo_id;
        } else {
            $sql = "select AZUL_S_INSTANTANEOS.nextval from dual";
            $result = $di->getShared('db')->query($sql);
            while($row = $result->fetchArray()){
                $this->instantaneo_id = $row['NEXTVAL'];
            }
        }
        $this->fecha = date('d/M/y', strtotime($this->fecha));
        $res = parent::save($data, $whiteList);
        $res = true;
    } catch (Exception $ex) {
        $res = false;
        $this->appendMessage(new Message($ex->getMessage()));
    }
    return $res;
}

它有效,但是,当我修改这一行时:

$this->fecha = date('d/M/y', strtotime($this->fecha));

有了这个:

$this->fecha = date('d/M/y H:i:s', strtotime($this->fecha));

我收到这个错误:

SQLSTATE[HY000]: General error: 1830 OCIStmtExecute: ORA-01830: date format picture ends before converting entire input string

(ext\pdo_oci\oci_statement.c:148) 而且我需要保存时间信息,我尝试自己做保存方法,没有parent::save,插入或更新时写我自己的sql:

    $sql_i = "insert into AZUL_INSTANTANEOS values(%d,%d,to_date('%s', 'YYYY-MM-DD HH24:MI:SS'),%f,'%s')";
    $sql_u = "update AZUL_INSTANTANEOS set val = %f, valf = '%s' where instantaneo_id = %d";

并使用:

$db->execute($sql);

但是我得到另一个错误:

Maximum execution time of 30 seconds exceeded in <b>\app\config\services.php</b> on line <b>172</b><br />

我正在使用:

  1. XAMPP 1.8.2(PHP 版本 5.4.31,Apache/2.4.10 (Win32))
  2. Oracle 数据库 11g 企业版 11.2.0.1.0 版 - 生产
  3. Phalcon 2.1.0b

¿有什么建议吗?谢谢。

Phalcon 不完全支持 Oracle。位于 here 的孵化器中有一个驱动程序可供您使用。

Oracle 还具有 Phalcon 的 PHQL 可能无法识别的不同语法。

我建议您首先向您的应用程序添加 SQL 语句日志记录,这样您就可以看到发送到数据库的内容,然后找出如何更正它。

查看 this 页面并向下滚动到显示 Logging SQL Statements

的位置

添加它并查看您的查询发生了什么。