在课堂上找不到字段

时间:2015-05-24 00:28:44

标签: php function class model

我试图将用户可用性与功能内的组匹配。

问题是我无法弄清楚如何将模型(getAllAvailability)调用到数组中,以便我可以针对组表进行检查。我可能只是错了。

这是我能得到的尽可能接近,但在线:

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

找不到可用性:(

这是我的完整代码:

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');
            }

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 个答案:

答案 0 :(得分:0)

@SaidKholov - 哇,我明白了。我不知道我在这方面工作了多久,直到我要求一些帮助才能解决这个问题。我正在考虑你的var_dump,我意识到我试图将结果作为一个数组,当它们已经是一个数组时。
因此摆脱了make数组行,我有:

/**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');
            }