UDF消失
|
我正在努力将一堆数据从旧数据库迁移到新数据库。在迁移为我的脚本创建的UDF的过程中,它将为我提供大量我需要的数据。当我运行多次调用UDF的循环时,我发现第一个迭代运行良好,但是随后的迭代中UDF消失了。
我的代码是:
<cffunction name=\"getCats\" access=\"public\">
<cfargument name=\"assignments\" type=\"any\" />
<cfquery name=\"getCats\" datasource=\"pgdold\">
SELECT c1.id AS id1, c1.category AS name1, c2.id AS id2, c2.category AS name2, c3.id AS id3, c3.category AS name3, c4.id AS id4, c4.category AS name4, c5.id AS id5, c5.category AS name5
FROM category c1
LEFT JOIN category AS c2 ON c2.parentid = c1.id
LEFT JOIN category AS c3 ON c3.parentid = c2.id
LEFT JOIN category AS c4 ON c4.parentid = c3.id
LEFT JOIN category AS c5 ON c5.parentid = c4.id
</cfquery>
<cfquery name=\"get\" dbtype=\"query\">
SELECT (name1 + \'/\' + name2 + \'/\' + name3 + \'/\' + name4 + \'/\' + name5) AS category
FROM getCats
WHERE
<cfloop query=\"Arguments.assignments\">
(id1 = #Arguments.assignments.categoryid# OR id2 = #Arguments.assignments.categoryid# OR id3 = #Arguments.assignments.categoryid# OR id4 = #Arguments.assignments.categoryid# OR id5 = #Arguments.assignments.categoryid#)
<cfif Arguments.assignments.currentrow IS NOT Arguments.assignments.recordCount> OR </cfif>
</cfloop>
</cfquery>
<cfreturn get />
</cffunction>
<cfscript>
olddb = {datasource=\'pgdold\'};
a = new Query(argumentCollection=olddb);
a.setSQL(\'SELECT * FROM products LIMIT 10\');
p = a.execute();
pr = p.getResult();
</cfscript>
<cfscript>
products = arrayNew();
for(i=1;i<=pr.recordCount;i++){
product = {};
if(!reFind(\'([0-9]+\\-)(G|g)(I|i)(F|f)(T|t)\',pr[\'sku\'][i])){
b = new Query(argumentCollection=olddb);
b.setSql(\'SELECT * FROM productpics WHERE sku = :sku ORDER BY picorder\');
b.addParam(name=\'sku\',value=pr[\'sku\'][i]);
pics = b.execute().getResult();
picList = \'\';
for(j=1;j<=pics.recordCount;j++){
picList = picList & \';\' & pics[\'imagename\'][j];
}
d = new Query(argumentCollection=olddb);
d.setSql(\'SELECT * FROM skucategories WHERE sku = :sku\');
d.addParam(name=\'sku\', value=pr[\'sku\'][i]);
assignments = d.execute().getResult();
categories = getCats(assignments);
writeDump(categories);
product = {
store = \'admin\',
websites = \'base\',
attribute_set = \'Default\',
categories = \'\',
type = \'simple\',
sku = pr[\'sku\'][i],
name = reReplace(reReplace(pr[\'title\'][i],\'\\\"\',\'&##34;\',\'all\'),\'\\,\',\'&##44;\',\'all\'),
price = pr[\'price\'][i],
description = reReplace(reReplace(pr[\'detail\'][i],\'\\\"\',\'&##34;\',\'all\'),\'\\,\',\'&##44;\',\'all\'),
short_description = \'\',
image = pics[\'imagename\'][1],
small_image = pics[\'imagename\'][1],
thumbnail = pics[\'imagename\'][1],
weight = pr[\'weight\'][i],
has_options = 1,
is_in_stock = 1,
qty = 1000,
disabled = \'No\',
status = \'Enabled\',
options_container = \'Black after info Column\',
tax_class_id = \'Taxable Goods\',
visibility = \'Catalog,Search\',
gallery = right(picList,len(picList)-1) // Seperate images by semicolon (;)
};
arrayAppend(products,product);
}
}
</cfscript>
就是getCats函数消失了。
*是,代码丑陋且效率低下。它无非是要完成一项工作,而在完成工作后,它会被丢弃,所以不要告诉我丑陋或效率低下的情况。
没有找到相关结果
已邀请:
2 个回复
导力疵谜
在CF2或以下的CF2中:
缉康怪