尝试将变量声明为参数时出错。当我尝试在函数内声明它时没问题

发布于 2024-10-06 13:49:43 字数 977 浏览 0 评论 0原文

我有这个函数:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2024-10-13 13:49:43

上面的代码没有任何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 problem
http://symfonyexperts.com/question/show/id/51

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文