Zend_Db - 在获取或执行和获取之前定义未完成

时间:2013-02-20 10:32:45

标签: oracle zend-framework zend-db bind-variables

我在Oracle中有一个处理所有电子邮件的send_mail()程序。

我可以从Zend查询中调用该过程,但没有错误$db->query("blah blah"); 当我使用$stmt = $db->prepare("blah blah");时,我收到错误(虽然电子邮件仍然发送):

24374 ORA-24374: define not done before fetch or execute and fetch *begin send_mail(:mailto,:mailhost,:mailport,:mailfrom,:subject,:message); end;","file":"C:\\wamp\\www\\sam\\library\\Zend\\Db\\Statement\\Oracle.php

我的所有变量都已定义?所以不确定是什么导致了这个错误?

我的代码:

$db = Zend_Registry::get('db');

            $emailTo = trim($_POST['emailto']);
            $subject = trim($_POST['subject']);
            $message = trim($_POST['msg']);

        $eSettings = $db->query("Select MAIL_HOST, MAIL_PORT, MAIL_FROM from     PI_SETTINGS_TABLE")->FetchAll();

            $stmt = $db->prepare("begin send_mail(:mailto,:mailhost,:mailport,:mailfrom,:subject,:message); end;");
            $stmt->bindParam('mailto', $emailTo);
            $stmt->bindParam('mailhost', $eSettings[0]['MAIL_HOST']);
            $stmt->bindParam('mailport', $eSettings[0]['MAIL_PORT']);
            $stmt->bindParam('mailfrom', $eSettings[0]['MAIL_FROM']);
            $stmt->bindParam('subject', $subject);
            $stmt->bindParam('message', $message);
            $stmt->execute();
            $checkQuery = $stmt->FetchAll();

也许有人可以解释为什么我可以将其作为查询传递而不是作为绑定语句?

我的SEND_MAIL程序:

create or replace
PROCEDURE "SEND_MAIL" (
msg_to varchar2,
mail_host varchar2,
mail_port varchar2,
msg_from varchar2,
msg_subject varchar2,
msg_text varchar2 )
IS
c utl_smtp.connection;
rc integer;

BEGIN
c := utl_smtp.open_connection(mail_host, mail_port); -- SMTP on port 25
utl_smtp.helo(c, mail_host);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);

utl_smtp.data(c,'From: ' || msg_from || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || utl_tcp.crlf || msg_text);
utl_smtp.quit(c);

EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt
using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;

注意:当我使用bind vars从SQL Developer运行查询时出现此错误,并且电子邮件未发送:

ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "PI_USER_ADMIN.SEND_MAIL", line 15

但它会用zend发送吗?

最基本的问候

0 个答案:

没有答案