zf2更改Callback验证程序返回的错误代码(zf2 change error code returned by Callback validator)
我成功使用了ZF2
Callback
验证器,但是它返回的代码有问题。 这里使用的配置:'validators'=>array( array( 'name' => 'Callback', 'options' => array( 'messages'=>array( Callback::INVALID_VALUE => 'Error', ), 'callback' => function ($value,$context=array()) { if(empty($value) && empty($context['company'])){ $isValid = false; }else{ $isValid = true; } return $isValid; }, ) ) ),
问题出在错误代码中,它不返回任何消息
它返回
callbackValue
,它是Callback
验证类的常量INVALID_VALUE
的值有没有办法通过选项更改此值?
我想避免为每个必须验证的项目编写自定义类。
I successfully use the ZF2
Callback
validator but I have a problem with the code that it returns. Here the config that use:'validators'=>array( array( 'name' => 'Callback', 'options' => array( 'messages'=>array( Callback::INVALID_VALUE => 'Error', ), 'callback' => function ($value,$context=array()) { if(empty($value) && empty($context['company'])){ $isValid = false; }else{ $isValid = true; } return $isValid; }, ) ) ),
The problem is in the error code which returns no message
It returns
callbackValue
which is the value of the constantINVALID_VALUE
of theCallback
validation classIs there a way to change this value through the options?
I would like to avoid writing a custom class for each item that I have to validate.
原文:https://stackoverflow.com/questions/29416928
最满意答案
搜索后,我没有找到适合这个问题的解决方案。 很多建议,比如在执行命令之前添加
SET NOCOUNT ON
。 下面是一些相关链接:
- http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx
- http://www.sqlservercentral.com/articles/Data+Flow+Task+(SSIS)/117370/
- http://www.ssistalk.com/2007/10/10/ssis-stored-procedures-and-the-ole-db-source/
你可以做一个解决方法
声明一个SSIS变量(假设
@[User::Query]
)设置
@[User::Query]
属性EvaluateAsExpression
= True并使用以下表达式"EXEC [dbo].[GetDales_Person_data] " + @[User::Sales]
如果
@[User::Sales]
是一个字符串,请使用以下命令"EXEC [dbo].[GetDales_Person_data] '" + @[User::Sales] + "'"
然后在
OLEDB Source
使用SQL Command from variable
选择@[User::Query]
After searching i didn't find a solution for this issue that worked for me. Ther are many suggestions like adding
SET NOCOUNT ON
before the execute command. Below some related links:
- http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx
- http://www.sqlservercentral.com/articles/Data+Flow+Task+(SSIS)/117370/
- http://www.ssistalk.com/2007/10/10/ssis-stored-procedures-and-the-ole-db-source/
You can do a workaround
Declare a SSIS variable (assuming
@[User::Query]
)Set
@[User::Query]
propertyEvaluateAsExpression
= True and use the following expression"EXEC [dbo].[GetDales_Person_data] " + @[User::Sales]
if
@[User::Sales]
is a string use the following"EXEC [dbo].[GetDales_Person_data] '" + @[User::Sales] + "'"
Then In
OLEDB Source
useSQL Command from variable
and select@[User::Query]
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
SSIS使用变量值记录OnVariableValueChanged(SSIS Logging of OnVariableValueChanged with variable value)[2023-07-19]
您可以使用Event Handler来执行此操作。 转到“ Variables页面,转到“ Variable Grid Options ,选中“ Raise event when variable value changes ,并且应该为这些变量显示另外一个选项,即“ Raise Change Event ,默认为“ False ,对于那些变量,请更改为“ True ”需要跟踪更改(日志)。 并将日志记录任务放入Event handler UPDATE新行可能是已重置的参数值,并且该值很可能等于blank或 ... -
使用参数。 在SSIS中有问号? 被用作参数,其顺序决定了参数名称。 只需使用此SQL(在Source任务中): SELECT ID, [Product Type], [Product Title] FROM [View] where ID = ? ..然后单击Parameters按钮: 请注意, Preview按钮(如果您将尝试它)将无法工作(它将引发错误),但您可以忽略它,只需尝试按此处所述运行您的包。 ..然后将参数名称更改为0 (零)并将其设置为您的变量: 应该运作良好。 Use the p ...
-
你的参数映射应该没问题。 您需要将结果集设置为“无”并删除结果集映射。 您正试图在变量中捕获输出参数并将其设置为结果集。 这个问题是你的存储过程中的sql不会返回结果。 Your parameter mapping should be fine. You need to set the resultset to "None" and remove the resultset mapping. You are trying to both capture the output parameter in a v ...
-
搜索后,我没有找到适合这个问题的解决方案。 很多建议,比如在执行命令之前添加SET NOCOUNT ON 。 下面是一些相关链接: http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx http://www.sqlservercentral.com/articles/Data+Flow+Task+(SSIS)/117370/ ...
-
在存储过程中,可以包含SELECT语句以返回行计数。 CREATE proc test_proc as begin .... select rowcnt= 230 end 根据Execute SQL Task设置,我在下面捕获并附加了2个图像。 In your stored procedure, you can include a SELECT statement to return the row count. CREATE proc test_proc as begin ... ...
-
没有办法做到这一点。 您可以从SSIS配置中读取(在被调用的proc中,请参阅: http://blogs.lessthandot.com/index.php/datamgmt/dbprogramming/execute-ssis-from-sql/) 或者将值存储到调用的proc读取的表中,然后使用proc中的读取变量。 There is no way to do it. You can either read from SSIS Configurations (in the called proc ...
-
我不太明白你的要求,但你可以这样做: 删除执行SQL任务 确保YourStagingTable存在且列与存储过程输出匹配 下面是一些示例代码,可以放入执行SQL任务中,执行您想要的操作: -- Clear Staging Table TRUNCATE YourStagingTable -- Save results of stored proc into staging table INSERT INTO YourStagingTable EXEC YourProc -- Update any exis ...
-
SSIS - 从工作表中读取数据并将每一行传递给存储过程(SSIS - read data from sheet and pass each row to a stored procedure)[2023-11-20]
为包含存储过程的SQL数据库添加连接管理器。 将结果集从Excel OleDB Data Source到OleDB Command ,并在OleDB Command的编辑器中: “连接管理器”选项卡 - 选择新的SQL连接管理器 组件属性选项卡 - 将“SQLCommand”设置为EXEC your_stored_proc ?, ?, ? 带有要传递给存储过程的每个参数的问号。 Column Mappings选项卡 - 将输入字段映射到? 占位符。 Add a connection manager for ...