我的模型中有这个保存方法:
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
(分机\ PDO_OCI \ oci_statement.c:148) 我需要保存时间信息,我尝试创建自己的save方法,没有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 />
我正在使用:
¿任何建议?,thx。