0
    <?php
include_once 'connectClass.php';

class manageSchool extends connect
{

    public function registerSchool($Name,$Address,$City,$State,$PinCode,$Email,$PassWord,$Website,$Phone1,$Phone2,$Fax,$Type,$ClassesUpto,$PrincipalName,$ClassTeacher){
        try{
        $statement=$this->db->prepare("INSERT INTO `tbl_school`(`Name`, `Address`, `City`, `State`, `PinCode`, `Email`,`PassWord`,
         `Website`, `Phone1`, `Phone2`, `Fax`, `Type`, `ClassesUpto`, `PrincipalName`, `ClassTeacher`)
          VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        $statement->execute(array($Name,$Address,$City,$State,$PinCode,$Email,$PassWord,$Website,$Phone1,$Phone2,$Fax,$Type,$ClassesUpto,$PrincipalName,$ClassTeacher));

    }catch (Exception $e) {
            echo 'Query failed'.$e->getMessage();

        }
    }
}

This is sample of code which I used to access PDO object from the connection class. I have to use extends every time for a new class that is created. Is there any other proper method to achieve this?. I have seen some of the answers for the same in stackoverflow but couldn't understood it well.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.