dsa45664 2014-04-11 17:47
浏览 45
已采纳

看来RedBeanPHP 4KS删除了R :: setStrictTyping(false)。 使用下划线分配豆类的解决方法是什么?

I am using RedBeanPHP along with an API I am writing to make calls to an existing Database. Everything works great except some of the tables have underscores in their names. According to RedBean "underscores and uppercase chars are not allowed in type and property names."

When searching for solutions people recommended the use of the function.

R::setStrictTyping(false);

This would override the rules and allow you to dispense a bean such as

$post_points = R::dispense( 'user_points' );

However this appears to be missing in RedBeanPHP 4KS because when I put the SetStringTyping line in I recieve the following error:

Plugin 'setStrictTyping' does not exist, add this plugin using: R::ext('setStrictTyping')

There is no plugin for this.

Is there a workaround for this override? Since I am working with an existing DB schema its not as easy to just change all the table names to conform to RedBeanPHP standards at this point. Nor, as others suggested, just switching to a different system all together such as using Doctrine.

  • 写回答

2条回答 默认 最新

  • dtwzwmv87399 2014-04-11 18:40
    关注

    Found out a solution. The check for underscores and uppercase chars only happens in the Facade. By adding this code:

    R::ext('xdispense', function($type){
     return R::getRedBean()->dispense( $type);
    })
    

    You can then do the following without error.

    $post_points = R::xdispense( 'user_points' );
    

    Cool.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上