[CDBI] how to use variable as column name in set _sql
"pangaoyong" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
the code like this,
__PACKAGE__->set_sql(distinctByProduct => qq{
SELECT DISTINCT %s
FROM __TABLE__
WHERE product = ? order by %s
});
sub distinctCol
{
my ($class, $col, $productName) = @_;
return $class->sql_distinctByProduct($col)->select_col($productName);
}
when method distinctCol is called it throw the error like this,
DBD::mysql::st execute failed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 [for Statement "<br><br> SELECT DISTINCT price<br> FROM product<br> WHERE name = ? order by<br><br>you could see that the second %s is not passed in, the first %s is ok, could someone give me a clue?<br><br>
_______________________________________________
ClassDBI mailing list
ClassDBI-Ra3b/[email protected]
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi