Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.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/6/codeigniter/3.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
codeigniter php事件管理系统。。我想在创建事件时发出通知_Php_Codeigniter_Notifications - Fatal编程技术网

codeigniter php事件管理系统。。我想在创建事件时发出通知

codeigniter php事件管理系统。。我想在创建事件时发出通知,php,codeigniter,notifications,Php,Codeigniter,Notifications,你好,先生。有人能帮我吗?我正试图编写通知代码。事件管理系统。管理员将为学者创建事件。在创建活动的过程中,管理员将选择活动的目的。当管理员完成创建事件时,此奖学金获得者将自动收到他们的通知。我的问题是无法将事件id插入数据库中的通知表中。我不知道为什么我的$this->db->insert_id()在$data7中。$data5和$data6正在工作 public function create_event_scholar() { $now

你好,先生。有人能帮我吗?我正试图编写通知代码。事件管理系统。管理员将为学者创建事件。在创建活动的过程中,管理员将选择活动的目的。当管理员完成创建事件时,此奖学金获得者将自动收到他们的通知。我的问题是无法将事件id插入数据库中的通知表中。我不知道为什么我的$this->db->insert_id()在$data7中。$data5和$data6正在工作

       public function create_event_scholar()
         {
            $now = date('Y-m-d');
            $start=$_POST['start_date'];
            $end=$_POST['end_date'];
            if(($start==$now)||$end==$now){
              $event_status= "Ongoing";
               
                 
                  }
                  else if(($start < $now)&&($end>$now)){
                    $event_status= "Ongoing";
                  }
                  else if(($start<$now)&&($end<$now)){
                    $event_status= "Done";
                    

                  }
                  else {
                    $event_status= "Upcoming";
                  }


            $data = array
             (
              'event_id'     =>      '',
             'event_title'   =>      $this->input->post('event_title',true),
             'event_desc'    =>      $this->input->post('event_desc',true),
             'start_date'    =>      $this->input->post("start_date",true),
             'end_date'      =>      $this->input->post("end_date",true),
             /*'event_status'   =>      $event_status,*/
            'event_sponsor' =>      $this->input->post('event_sponsor',true),
            'Semester'      =>      $this->input->post("Semester",true),
           'school_year'   =>      $this->input->post('school_year',true),
           'event_for'     =>      'Scholar',
           'start_time' =>      $this->input->post('start_time',true),
           'venue'          =>      $this->input->post('venue',true),
           'end_time'       =>      $this->input->post('end_time',true),
          'user_id'     =>      $this->input->post('user_id',true),
          'color '      =>      $this->input->post('color',true)
          );

          $sql1=    $this->db->insert('event',$data);


             $earlier = new DateTime($_POST['start_date']);
              $later = new DateTime($_POST['end_date']);

              $diff = $later->diff($earlier)->format("%a");

                $data = array(
                'security_id'     => "",  
                'event_id'        =>$this->db->insert_id(),
                'scholarship'     =>$this->input->post('scholarship',true),
                'max_attendees'   =>$this->input->post('Participants',true),
                'pre_reg'         =>$this->input->post('pre',true),
                'total_attendance'=>$diff,
                'event_duration'  =>$this->input->post('event_duration',true),
                
                );

        $sql2=$this->db->insert('event_security',$data,'event_id'); 
        
            $data3=array(
        'assign_id'  => '',
        'user_id'   =>$this->input->post('user_id',true),
        'event_id'  =>$this->db->insert_id()
        );
        $sql3=  $this->db->insert('tbl_staff_events',$data3);



         $data5 = array(
        'notification_id'   =>'',
        'subject'           =>$this->input->post('event_title',true),
        'body'              =>"There is an event", 
        'event_id'          =>$this->db->insert_id()


      );

       $this->db->insert('notification',$data5);

        $subject=$this->input->post('scholarship',true);
        $this->db->select('*');
        $this->db->from('tbl_scholar');
        $this->db->where('scholarship_id',$subject);
        $get= $this->db->get()->result_array();
        foreach ($get as $value) {
        $data6=array(
        'participants_id'   => '',
        'event_id'          =>$this->db->insert_id(),
         'user_id'          =>$value['user_id']
        );
        $this->db->insert('participants',$data6);
        }

        $data7= array(
       'sent_id'                =>'',
       'read'                   =>'0',
       'recieve'                =>'0',
       'notification_id'        =>$this->db->insert_id(),
       'participants_id'        =>$this->db->insert_id()
        );

        $this->db->insert('sent_notification',$data7);

        if($sql1===true && $sql2===true && $sql3 === true) 
        {
         return true;
         }
        else
        {
        return false;
        }   

        }
public function create\u event\u scholar()
{
$now=日期('Y-m-d');
$start=$\u POST['start\u date'];
$end=$\u POST['end\u date'];
如果(($start==$now)| |$end==$now){
$event\u status=“进行中”;
}
else if(($start<$now)&($end>$now)){
$event\u status=“进行中”;
}
否则如果($start$this->input->post('event_title',true),
'event_desc'=>this->input->post('event_desc',true),
“开始日期”=>this->input->post(“开始日期”,true),
“结束日期”=>this->input->post(“结束日期”,true),
/*“事件状态”=>$event\u status*/
“活动赞助商”=>$this->input->post(“活动赞助商”,true),
“学期”=>$this->input->post(“学期”,true),
“学年”=>$this->input->post('school\u year',true),
'event_for'=>'Scholar',
“开始时间”=>this->input->post('start\u time',true),
“地点”=>$this->input->post('venture',true),
“结束时间”=>this->input->post('end\u time',true),
'user\u id'=>this->input->post('user\u id',true),
'color'=>this->input->post('color',true)
);
$sql1=$this->db->insert('event',$data);
$previous=新的日期时间($\u POST['start\u date']);
$later=新的日期时间($\u POST['end\u date']);
$diff=$later->diff($previous)->格式(“%a”);
$data=数组(
“安全id=>”,
'event_id'=>this->db->insert_id(),
“奖学金”=>$this->input->post('scholarship',true),
“最大与会者数”=>$this->input->post('Participants',true),
'pre_reg'=>$this->input->post('pre',true),
“总出席人数”=>$diff,
“事件持续时间”=>$this->input->post('event\u duration',true),
);
$sql2=$this->db->insert('event\u security',$data,'event\u id');
$data3=数组(
'分配\u id'=>'',
'user\u id'=>this->input->post('user\u id',true),
'event_id'=>this->db->insert_id()
);
$sql3=$this->db->insert('tbl\u staff\u events',$data3);
$data5=数组(
'通知id'=>'',
'subject'=>this->input->post('event_title',true),
“正文”=>“有一个事件”,
'event_id'=>this->db->insert_id()
);
$this->db->insert('notification',$data5);
$subject=$this->input->post('scholarship',true);
$this->db->select('*');
$this->db->from('tbl_scholar');
$this->db->where('scholarship\u id',$subject);
$get=$this->db->get()->result_array();
foreach($get as$value){
$data6=数组(
“参与者id=>”,
'event_id'=>this->db->insert_id(),
'user\u id'=>$value['user\u id']
);
$this->db->insert('participants',$data6);
}
$data7=数组(
'已发送\u id'=>'',
'读取'=>'0',
“Receive'=>0',
'notification_id'=>this->db->insert_id(),
“参与者id”=>this->db->insert\u id()
);
$this->db->insert('sent_notification',$data7);
如果($sql1==true&&$sql2==true&&$sql3==true)
{
返回true;
}
其他的
{
返回false;
}   
}

此代码可能会帮助您

$sql1=    $this->db->insert('event',$data);

$event_id = $this->db->insert_id();

$this->db->insert('notification',$data5);

$notification_id = $this->db->insert_id();

$this->db->insert('participants',$data6);

$participants_id = $this->db->insert_id();
$this->db->insert_id();
返回上次执行的查询id