cakephp 错误:意外的'(',期待')',我的语法错误吗?

发布于 2025-01-03 21:50:39 字数 2479 浏览 0 评论 0原文

您在这里看到任何语法错误吗?

'Coupon'=>array(
            'fields'=>array(
                'promo_code','desc'
            ),
            'conditions'=>array(
                        'OR'=>array(
                            'expires' =>0,
                            'Coupon.end_date >'=>date('Y-m-d')
                        )
            )
        ),

这是我的控制器代码中“包含”数组的一部分。当我从代码中删除此代码片段时,蛋糕效果很好(只有我需要这部分!)。我将完整声明发布在下面。帮助?

public $paginate = array(
    'Location'=>array(
        'joins' => array(
             array( 
                'table' => 'locations_tags', 
                'alias' => 'LocationsTag', 
                'type' => 'inner',
                'conditions'=> array( 
                'LocationsTag.location_id = Location.id'
                )
            )
        ),
        'limit'=>9,
        'contain'=>array(
        'Course'=>array(
            'fields'=>array(
                'specials', 'contact','desc'
                ),
            'conditions'=>array('Course.active'=>1)
            ),
        'Charter'=>array(
            'fields'=>array(
                'book','specials', 'contact','desc'
                ),
            'conditions'=>array('Charter.active'=>1)
            ),
        'Restaurant'=>array(
            'fields'=>array(
                'menu','wine_list','specials', 'contact','desc'
                ),
            'conditions'=>array('Restaurant.active'=>1)
            ),
        'Nightclub'=>array(
            'fields'=>array(
                'menu','schedule','specials', 'contact','desc'
                ),
            'conditions'=>array('Nightclub.active'=>1)
            ),
        'Store'=>array(
            'fields'=>array(
                'catalog','specials', 'contact','desc'
                ),
            'conditions'=>array('Store.active'=>1)
            ),
        'Coupon'=>array(
            'fields'=>array(
                'promo_code','desc'
            ),
            'conditions'=>array(
                        'OR'=>array(
                            'expires' =>0,
                            'Coupon.end_date >'=>date('Y-m-d')
                        )
            )
        ),
        'Image',
        'Tag'=>array(
            'fields'=>array(
                'seo_tag'
            )
            )
        )
    )
);

Do you see any syntax errors here?

'Coupon'=>array(
            'fields'=>array(
                'promo_code','desc'
            ),
            'conditions'=>array(
                        'OR'=>array(
                            'expires' =>0,
                            'Coupon.end_date >'=>date('Y-m-d')
                        )
            )
        ),

This is part of my 'contain' array in my controller code. When I remove this snippet from my code, cake works great (only I need this part!). Am posting the entire statement below. Help?

public $paginate = array(
    'Location'=>array(
        'joins' => array(
             array( 
                'table' => 'locations_tags', 
                'alias' => 'LocationsTag', 
                'type' => 'inner',
                'conditions'=> array( 
                'LocationsTag.location_id = Location.id'
                )
            )
        ),
        'limit'=>9,
        'contain'=>array(
        'Course'=>array(
            'fields'=>array(
                'specials', 'contact','desc'
                ),
            'conditions'=>array('Course.active'=>1)
            ),
        'Charter'=>array(
            'fields'=>array(
                'book','specials', 'contact','desc'
                ),
            'conditions'=>array('Charter.active'=>1)
            ),
        'Restaurant'=>array(
            'fields'=>array(
                'menu','wine_list','specials', 'contact','desc'
                ),
            'conditions'=>array('Restaurant.active'=>1)
            ),
        'Nightclub'=>array(
            'fields'=>array(
                'menu','schedule','specials', 'contact','desc'
                ),
            'conditions'=>array('Nightclub.active'=>1)
            ),
        'Store'=>array(
            'fields'=>array(
                'catalog','specials', 'contact','desc'
                ),
            'conditions'=>array('Store.active'=>1)
            ),
        'Coupon'=>array(
            'fields'=>array(
                'promo_code','desc'
            ),
            'conditions'=>array(
                        'OR'=>array(
                            'expires' =>0,
                            'Coupon.end_date >'=>date('Y-m-d')
                        )
            )
        ),
        'Image',
        'Tag'=>array(
            'fields'=>array(
                'seo_tag'
            )
            )
        )
    )
);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

绅士风度i 2025-01-10 21:50:39
        'Coupon.end_date >'=>date('Y-m-d')

您不能在类属性声明中分配计算值(例如,调用函数)。它们必须是恒定值。

对于计算值,您必须在构造函数或其他东西中分配它。

来自文档

此声明可以包含初始化,但此初始化必须是常量值 - 也就是说,它必须能够在编译时进行评估,并且不能依赖于运行时信息才能进行评估。

        'Coupon.end_date >'=>date('Y-m-d')

You can't assign calculated values (e.g., calling functions) in class property declarations. They have to be constant values.

For a calculated value, you'd have to assign that in the constructor or something.

From the docs:

This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.

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