尝试将变量声明为参数时出错。当我尝试在函数内声明它时没问题
我有这个函数:
public static function getOrdini($sort_order = 4)
{
$con = Propel::getConnection();
$sql = "select * from shop_orders LEFT JOIN shop_orders_total
ON
shop_orders.orders_id = shop_orders_total.orders_id
AND
shop_orders_total.sort_order = :sort_order";
$stmt = $con->prepare($sql);
$result = $stmt->execute(array(':sort_order' => $sort_order));
$ordini = self::populateObjects($stmt);
return $ordini;
}
当我调用它时,我收到此错误:
( ! ) 可捕获的致命错误:对象 类标准无法转换 串入 /home/javier/Aptana_Studio_Workspace/dev_repo/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel/util/DebugPDOStatement.php 第99行
,但如果用下面的方式编写函数,我不会收到任何错误:
public static function getOrdini()
{
$sort_order = 4;
$con = Propel::getConnection();
...
有什么想法吗?
问候
哈维
I have this function:
public static function getOrdini($sort_order = 4)
{
$con = Propel::getConnection();
$sql = "select * from shop_orders LEFT JOIN shop_orders_total
ON
shop_orders.orders_id = shop_orders_total.orders_id
AND
shop_orders_total.sort_order = :sort_order";
$stmt = $con->prepare($sql);
$result = $stmt->execute(array(':sort_order' => $sort_order));
$ordini = self::populateObjects($stmt);
return $ordini;
}
When I call it I get this error:
( ! ) Catchable fatal error: Object of
class Criteria could not be converted
to string in
/home/javier/Aptana_Studio_Workspace/dev_repo/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel/util/DebugPDOStatement.php
on line 99
but if write the function in this way below I don't get any error:
public static function getOrdini()
{
$sort_order = 4;
$con = Propel::getConnection();
...
Any idea?
Regards
Javi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面的代码没有任何bug就可以了。我尝试在静态方法中传递值,很好,错误是从代码的其他部分生成的,在类
Criteria
中进行检查会帮助您,这里发布的内容中没有任何内容。要求
propel, symfony
。这里有人面临同样的问题http://symfonyexperts.com/question/show/id/51
No bug in the above code it is okay. I tried passing value in the static method and it is fine the error is being generated from the other part of your code checking in the class
Criteria
would help you here is nothing in the posted.Ask to
propel, symfony
. here someone is facing the same problemhttp://symfonyexperts.com/question/show/id/51