I have written a mysql stored procedure in my magento database to perform a complex operation and want to use them in my magento code. I was able to call the procedure from my magento code and fetch the resultset in an array. Now i wanted to use this resultset as maybe a model to do further joins using joinattribute or to be more specific, i want to transfer this output resultset from the stored procedure into a collection so that i can use the getcollection methods. how do i do this ?
我在magento数据库中编写了一个mysql存储过程来执行复杂的操作,并希望在我的magento代码中使用它们。我能够从我的magento代码调用该过程并在数组中获取结果集。现在我想使用这个结果集作为使用joinattribute进行进一步连接的模型,或者更具体一点,我想将此输出结果集从存储过程转移到集合中,以便我可以使用getcollection方法。我该怎么做呢 ?
1 个解决方案
#1
2
From a thread on joining procedure results:
从一个关于加入程序结果的线程:
> Is it possible to join a table on the results from a stored procedure within a single query?
>是否可以在单个查询中连接存储过程的结果表?
No.
So it looks like you'll have to do it the long way and use the array as a parameter.
所以看起来你必须做很长的事情并使用数组作为参数。
// $collection is a collection
// $results is the stored procedure results as an array
$collection->addAttributeToFilter('ATTRIBUTE_NAME', array('in'=>$results));
For similar tricks with collections see "Other Comparison Operators" here.
有关集合的类似技巧,请参阅此处的“其他比较运算符”。
#1
2
From a thread on joining procedure results:
从一个关于加入程序结果的线程:
> Is it possible to join a table on the results from a stored procedure within a single query?
>是否可以在单个查询中连接存储过程的结果表?
No.
So it looks like you'll have to do it the long way and use the array as a parameter.
所以看起来你必须做很长的事情并使用数组作为参数。
// $collection is a collection
// $results is the stored procedure results as an array
$collection->addAttributeToFilter('ATTRIBUTE_NAME', array('in'=>$results));
For similar tricks with collections see "Other Comparison Operators" here.
有关集合的类似技巧,请参阅此处的“其他比较运算符”。