dplm47571 2015-05-24 00:28
浏览 46
已采纳

在课堂上找不到字段

I'm trying to match a users availability to a Group inside a function.

The problem is I can't figure out how to call the Model (getAllAvailability) into an array so I can check it against the group table. I could just be going about it all wrong.

This is as close as I can get, but on the line:

foreach($this->availability as $key => $value) 

availability is not found :(

Here is my full code:

public function find()
    {


        /**Find groups that are not closed and send to group_find page */
        array('availability' => AvailabilityModel::getAllAvailability());
        foreach($this->availability as $key => $value) {
            GroupModel::getMatchingGroup($value->hour);

            if ($value->hour == 1600){

                /**Redirect::to('group_add user to group and check for max group size'); */
                Redirect::to('group/group_find');
            }

After var_dump()

array(3) { [0]=> object(stdClass)#8 (4) { ["user_id"]=> string(1) "2"
["availability_id"]=> string(1) "8" ["day"]=> string(1) "1" ["hour"]=> 
string(4) "1200" } [1]=> object(stdClass)#9 (4) { ["user_id"]=> 
string(1) "2" ["availability_id"]=> string(1) "9" ["day"]=> string(1) 
"3" ["hour"]=> string(4) "1800" } [2]=> object(stdClass)#10 (4) { 
["user_id"]=> string(1) "2" ["availability_id"]=> string(2) "10" 
["day"]=> string(1) "3" ["hour"]=> string(4) "1600" } }
  • 写回答

1条回答 默认 最新

  • ds211107 2015-05-24 01:59
    关注

    @SaidKholov - wow, I got it. I don't know how long I've been working on this and it wasn't until I asked for a bit of help that I was able to figure it out. I was thinking about your var_dump and I realized that I was trying to make the results an array, when they are already an array.
    So getting rid of the make array line, I have:

    /**Find groups that are not closed and send to group_find page */
            foreach(NewguyModel::getAllAvailability() as $key => $value) {
                GroupModel::getMatchingGroup($value->hour);
            }if ($value->hour == 1600){
    
                    /**Redirect::to('group_add user to group and check for max group size'); */
                    Redirect::to('note');
                }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况