Search code examples
zend-frameworkzend-dbzend-db-table

Parse error: syntax error, unexpected $end, expecting T_FUNCTION in ClmsRegistrationModel.php


    <?php
/**
 * clmsRegistration
 * 
 * @author MGUCS-07
 * @version 
 */
require_once 'Zend/Db/Table/Abstract.php';
class ClmsRegistrationModel extends Zend_Db_Table_Abstract
{
    /**
     * The default table name 
     */
    protected $_name = "clms_registration";
    protected $_primary = "user_name";


    public static function changePassword($username, $newpassword)
    { //changes the password
        try {
            $chps= new ClmsRegistrationModel();
            $row = $chps->find($username);
            $row1 = $row->current();
            $row1->password=$newpassword;
            $row1->save();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }       
    }

    public static function checkUsed($username)
    {  //check whether used or not
        try {
        $table = new ClmsRegistrationModel();
        $row=$table->find($username);
        if($row)
        {
            return 1;
        }}
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }   

    }

    public static function deleteUser($user_name)
    { //deletes a user
        try { 
            $deluser=new ClmsRegistrationModel();
            $row = $deluser->find($user_name);
            $row1=$row->current();
            $result = $row1->delete();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }   
    }

    public static function updateUser($user_name,$district,$email_id,$phone_number)
    {
        //updates the details of the user
        try {
            $upUser = new ClmsRegistrationModel();
            $row = $upUser->find($user_name); 
            $row1=$row->current();
            $row1->district= $district;
            $row1->email_id= $email_id;
            $row1->phone_number= $phone_number;
            $row1->save();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }

    }

    public static function getRole($user_name)
    { //gets the role of the user
        try {
            $roq= new ClmsRegistrationModel();
            $u= $roq->fetchRow($roq->select()->where('user_name=?',$user_name));
            return $u->toArray();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }   

    }

    public function isActive($user_name)
    { //select active user
        try {
            $roq = new ClmsRegistrationModel();
            $u= $roq->fetchRow($roq->select()->where('user_name=?',$user_name));
            return $u->toArray();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }   
    }
    public function setActive($user_nam)
    { //sets user active 
        try {
            $roq = new ClmsRegistrationModel();
            $row= $roq->find($user_nam);
            $row1=$row->current();
            $row1->user_name= $user_nam;
            $row1->status1 = 1;
            $row1->save();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }   
    }
    public static function setRole($user_name,$role)
    { //sets the role of the user
        try {
            $reg=new ClmsRegistrationModel();       
            $row = $reg->find($user_name);
            $row1= $row->current();
            $row1->role_organization=$role;
            $row1->save();
        }
        catch (Zend_Db_Exception $e)
        {
            $e->getMessage();
        }   
    }

    public function  register($uname,$pass,$role,$en,$status,$email,$ph,$date,$dis)
    {// function  for registration purposes

         try{

            $reg = new  ClmsRegistrationModel();
            $row =$reg->fetchNew();
            //$row= $row->current();
            $row->user_name = '$uname';
            $row->password = '$pass';
            $row->role = $role;
            $row->employee_name=$en;
            $row->status1=$status;
            $row->email_id =$email;
            $row->phone_number =$ph;
            $row->date =$date;
            $row->District=$dis;
            $row->employe_id =$row->employe_id +1;
            $row->save();
            //$reg->save();
         }
         catch (Zend_Db_Exception $e){
            $e->getMessage();
         }


}
}

This is my model class and getting that error. Please tell why this error and how to debug it.


Solution

  • try this

     $reg = new  ClmsRegistrationModel();
                $row1 =$reg->createRow();
                $row1->user_name = $uname;
                $row1->password= $pass;
                $row1->role = $role;
                $row1->employee_name=$en;
                $row1->status1=$status;
                $row1->email_id =$email;
                $row1->phone_number =$ph;
                $row1->date =$date;
                $row1->District=$dis;
    
    
            $row1->save();