Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
saveAll()cakePHP的问题_Php_Linux_Apache_Cakephp - Fatal编程技术网

saveAll()cakePHP的问题

saveAll()cakePHP的问题,php,linux,apache,cakephp,Php,Linux,Apache,Cakephp,我在保存数据和关联数据时遇到问题。下面是我的错误 模型 操作系统?那是模型吗?像国家一样?你的某个地方的验证规则被弄乱了。你需要更详细地了解是什么导致了它。试着对验证进行评论,看看你是否能让问题暂时消失;model.php:2614中的堆栈跟踪也很有用。是的,Os和country都是模型 <?php class Project extends AppModel { var $name = 'Project'; var $displayField = 'project_tit

我在保存数据和关联数据时遇到问题。下面是我的错误

模型
操作系统?那是模型吗?像国家一样?你的某个地方的验证规则被弄乱了。你需要更详细地了解是什么导致了它。试着对验证进行评论,看看你是否能让问题暂时消失;model.php:2614中的堆栈跟踪也很有用。是的,Os和country都是模型
<?php
class Project extends AppModel {
    var $name = 'Project';
    var $displayField = 'project_title';


    var $validate = array(
        'user_id' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'project_title' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                'required' => true,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'description' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                'required' => true,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'status' => array(
            'boolean' => array(
                'rule' => array('boolean'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'approval_status' => array(
            'boolean' => array(
                'rule' => array('boolean'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'budget' => array(
            'money' => array(
                'rule' => array('money'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                'required' => true,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'bidding_type_id' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                'required' => true,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'project_type_id' => array(
            'notempty' => array(
                'rule' => array('notempty'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                'required' => true,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'esl' => array(
            'boolean' => array(
                'rule' => array('boolean'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'Country' => array(
                        'required' => true,
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'secrecy' => array(
            'boolean' => array(
                'rule' => array('boolean'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'Os' => array(
            'alphanumeric' => array(
                'rule' => array('alphanumeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                'required' => true,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'performance' => array(
                        'required' => false,
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'cme' => array(
                        'required' => false,
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'delivery' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'delivery_days' => array(
            'alphanumeric' => array(
                'rule' => array('alphanumeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'delivery_due' => array(
            'alphanumeric' => array(
                'rule' => array('alphanumeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'close' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'agree' => array(
            'boolean' => array(
                'rule' => array('boolean'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'created' => array(
            'date' => array(
                'rule' => array('date'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'favorite' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'top_employer' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'view_counter' => array(
            'numeric' => array(
                'rule' => array('numeric'),
                //'message' => 'Your custom message here',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => false, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
    );     

    var $belongsTo = array(
            'User' => array(
                    'className' => 'User',
                    'conditions' => '',
                    'fields' => '',
                    'order' => ''
            ),
            'ProjectType' => array(
                    'className' => 'ProjectType',
                    'foreignKey' => 'project_type_id',
                    'conditions' => '',
                    'fields' => '',
                    'order' => ''
            ),
            'BiddingType' => array(
                    'className' => 'BiddingType',
                    'foreignKey' => 'bidding_type_id',
                    'conditions' => '',
                    'fields' => '',
                    'order' => ''
            )
    );

        var $hasMany = array(
            'Bid' => array(
                'className'=> 'Bid',
                'order'=>'',
                ),
            'Comment' => array(
                'className'=> 'Comment',
                'order'=>'',
                )
            );


        var $hasAndBelongsToMany = array(
            'Os' =>
                    array(
                        'className' => 'OperatingSystem',
                        'joinTable' => 'project_operating_systems',
                        'foreignKey' => 'project_id',
                        'associationForeignKey' => 'os_id',
                        'conditions' => '',
                        'fields' => '',
                        'order' => '',
                        'limit' => '',
                        'offset' => '',
                        'finderQuery' => '',
                        'deleteQuery' => '',
                        'insertQuery' => ''
            ),
            'Country' =>
                    array(
                        'className' => 'Country',
                        'joinTable' => 'project_countries',
                        'foreignKey' => 'project_id',
                        'associationForeignKey' => 'country_id',
                        'conditions' => '',
                        'fields' => '',
                        'order' => '',
                        'limit' => '',
                        'offset' => '',
                        'finderQuery' => '',
                        'deleteQuery' => '',
                        'insertQuery' => ''
            ),
            'Category' => array(
                    'className' => 'Category',
                    'joinTable' => 'project_categories',
                    'foreignKey' => 'project_id',
                    'associationForeignKey' => 'category_id',
                    'conditions' => '',
                    'fields' => '',
                    'order' => '',
                    'limit' => '',
                    'offset' => '',
                    'finderQuery' => '',
                    'deleteQuery' => '',
                    'insertQuery' => ''
            ),
        );

        //Gets the Minimum and Maximum Bid of a particular project
        public function getMinMaxBid($projectId)
        {
            $minMax = array(
                'conditions'=>array(
                    'Bid.project_id'=>$projectId
                ),
                'fields'=>array(
                    'MIN(Bid.bid_amount) as minBid',
                    'MAX(Bid.bid_amount) as maxBid'
                ),
                'group'=>array('Bid.bid_amount')
                );

            $minMaxBids = $this->Bid->find('all',$minMax);
            return $minMaxBids[0][0];
        }

        //Gets Project, Project Owner, The Bidder Logged In, And All his comments
        public function getProjectSummaryData($ProjectId = null, $replyToId = null,$loggedInId = null)
        {
            $this->Behaviors->attach('Containable');
            $user = array('fields'=>array('id','username'));
            $projectOwnerId = $this->field('user_id',array('Project.id'=>$ProjectId));

            $commentConditions = array(
                'AND'=>array(
                        array(
                            'Comment.to_id'=>array(
                                "$replyToId","$projectOwnerId"
                                )
                            ),
                        array(
                            'Comment.from_id'=>array(
                                "$replyToId","$projectOwnerId"
                                )
                            )
                ));

            if($ProjectId)
            {
                $params = array(
                    'conditions'=>array(
                        'Project.id'=>$ProjectId
                        ),
                    'contain'=>array(
                        //Gets the User Who owns the Project
                        'User'=>$user,
                        'Bid'=>array(
                            'conditions'=>array('Bid.user_id'=>$loggedInId),
                             'order' => array('id' => 'desc'),
                            //The User Who owns the Bid
                            'User'=>$user),
                        //Gets All Comments that belong to project. Filters Only Comments Between Owner and Logged In Users
                        'Comment'=>array(
                                'conditions'=>$commentConditions,
                                'To'=>$user,
                                'From'=>$user
                            ),
                        )
                    );
                $project = $this->find('first',$params);

                $userProjectCount = $this->find('count',array('conditions'=>array('Project.user_id'=>$project['Project']['user_id'])));

                if($replyToId != $project['Project']['user_id'])
                    $project['Project']['replyTo'] = $replyToId;
                else
                    $project['Project']['replyTo'] = $project['Project']['user_id'];

                if($loggedInId == $project['Project']['user_id'])
                    $project['Project']['is_owner'] = true;
                else
                    $project['Project']['is_owner'] = false;

                $project['Project']['numMessages'] = count($project['Comment']);
                $project['Project']['totalProjects'] = $userProjectCount;
                //debug($project);
                return $project;
            }
            else
            {
                return false;
            }
        }//END FUNCTION

        public function tick($prodID)
        {
            //xdebug_break();
            $project = $this->findById($prodID);
            $project['Project']['view_counter'] += 1;
            $this->data = $project;
            if(!$this->save($this->data,false))
            {
                echo 'ticker issue';
            }
        }

        public function getProjectDataView($ProjectId, $userID)
        {
            $this->Behaviors->attach('Containable',array('autoFields'=>false));
            $user = array('fields'=>array('id','username'));
            $projectOwnerId = $this->field('user_id',array('Project.id'=>$ProjectId));
            $order = array('Comment.from_id');

            if($ProjectId)
            {
                $params = array(
                    'conditions'=>array(
                        'Project.id'=>$ProjectId
                        ),
                    'contain'=>array(
                        //Gets the User Who owns the Project
                        'User'=>$user,
                        'Bid'=>array(
                            //The User Who owns the Bid
                            'User'=>$user),
                        'ProjectType',
                        'Os',
                        'Comment'=>array(
                                'To'=>$user,
                                'From'=>$user,
                            ),
                        ),
                    );
                   //debug($params);

                $comments = $this->Comment->find('all',array(
                    'conditions'=>array(
                        'AND'=>array(
                            'Comment.to_id'=>$userID,
                            'Comment.project_id'=>$ProjectId)
                        ),
                    'fields'=>array(
                        'To.username',
                        'To.id',
                        'From.username',
                        'From.id',
                        'Comment.comment'
                    ),
                    'group'=>array(
                        'From.id'
                    )
                    )
                        );
                $minMaxBid = $this->getMinMaxBid($ProjectId);
                $project = $this->find('first',$params);
                $project['bid_count'] = $this->Bid->find('count',array('conditions'=>array('Bid.project_id'=>$ProjectId)));

                $project['Comment'] = $comments;
                $project['Project'] = array_merge($project['Project'],$minMaxBid);
                return $project;
            }
            else
            {
                return false;
            }
        }

        //checks to see if the user has already bid on the project
        public function hasBid($project, $userID)
        {
            if(!$project)
                return false;

            foreach($project['Bid'] as $bid)
            {
                if($bid['User']['id'] == $userID)
                    return true;
            }

            return false;
        }

        //returns total projects availible
        public function getTotalProjectCount()
        {
            return $this->find('count',array("order"=> array('Project.created desc')));
        }

        //returns total open project amount
        public function getTotalBidAmount()
        {
            $this->recursive = 0;
            $amounts = $this->find('all',array(
                'conditions'=>array(
                    'approval_status'=>1
                ),
                'fields'=>'budget'
            ));
            $amt = 0;

            foreach ($amounts as $amount)
            {
                $amt += $amount['Project']['budget'];
            }
            return $amt;
        }
}
> 12:47:51 Error: Array (
>     [description] => notempt
>     [Os] => This field cannot bePU
>     [cme] => required
>     [delivery] => numeric )
> 
> 2011-12-19 12:47:51 Error: Array (
>     [Project] => Array
>         (
>             [project_title] => New Project
>             [project_type_id] => 5
>             [budget] => 20000
>             [bidding_type_id] => 2
>             [esl] => 1
>             [secrecy] => 1
>             [user_id] => 9
>             [approval_date] => Array
>                 (
>                     [month] => 12
>                     [day] => 19
>                     [year] => 2011
>                     [hour] => 12
>                     [min] => 47
>                     [meridian] => pm
>                 )
> 
>             [categories] => Array
>                 (
>                     [0] => 2
>                     [1] => 3
>                 )
> 
>             [description] => 
>             [performance] => 1
>             [cme] => 1
>             [project_deadline] => 1
>             [delivery] => 
>             [bidding_deadline] => 
>             [agree] => 0
>         )
> 
>     [Country] => Array
>         (
>             [Country] => Array
>                 (
>                     [0] => 1
>                     [1] => 4
>                 )
> 
>         )
> 
>     [Os] => Array
>         (
>             [Os] => Array
>                 (
>                     [0] => 3
>                     [1] => 5
>                 )
> 
>         )
> 
> )