title: Derived Classes in Php Phalcon
body: <p>I am fairly new to php phalcon and the language itself. I am making a website that involves an abstract class and derived classes. </p>
  
  <p>The Abstract Class:</p>
  
  <pre><code>&lt;?php
  
  abstract class UsersAbstract extends \Phalcon\Mvc\Model {
  
      private $Full_Name; //
      private $Mobile_Number; //
      private $Email_ID; //
      private $City; //
      private $Country;  //
      private $DoB; //
      private $Gender; //
      private $Age; //
      private $Availability_Flag;   /*value of flag is 1 for active and 0 for inactive*/
  
  
      /********setters and getters for all data members which I have not written here*******/
  
  
      public function getSource()
      {
          return 'users_abstract';
      }
  } 
  </code></pre>
  
  <p>The derived class</p>
  
  <pre><code>&lt;?php
  class UserPatients extends UsersAbstract
  {
      private $Patient_ID;
      private $Guardian_Name;
      private $Doctors = array();
  
      public function getSource()
      {
          return 'user_patients';
      }
  
      /***************setter and getter for patient id*******************/
      public function getPatientID()
      {
          return $this-&gt;Patient_ID;
      }
      public function setPatientID($value)
      {
          $this-&gt;Patient_ID = $value;
      }
  
      /****************setter and getter for guardian name******************/
      public function getGuardianName()
      {
          return $this-&gt;Guardian_Name;
      }
  public function setGuardianName($value)
  {
      $this-&gt;Guardian_Name = $value;
  }
  
  /****************getter and setter for doctor array*********************/
  public function getDoctors()
  {
      return $this-&gt;Doctors;
  }
  
  public function setDoctors($value)
  {
      $this-&gt;Doctors = $value;
  }} 
  </code></pre>
  
  <p>In my controller, I am reading data from a form in a view. An object of the class UserPatients is declared and its data members are set. Here is the action method that I am calling in the controller PatientSignInController:</p>
  
  <pre><code>public function SaveAction()
      {
         if (!empty($_POST)){
              $patient_data = new UserPatients();
              $patient_data-&gt;setFull_Name($_POST['Full_Name']);
              $patient_data-&gt;setGuardianName($_POST['Guardian_Name']);
              $patient_data-&gt;setDoB($_POST['DoB']);
              $patient_data-&gt;setAge($_POST['Age']);
              $patient_data-&gt;setGender($_POST['gender']);
              $patient_data-&gt;setMobile_Number($_POST['Contact_No']);
              $patient_data-&gt;setEmail_Address($_POST['Email_ID']);
              $patient_data-&gt;setCity($_POST['City']);
              $patient_data-&gt;setCountry($_POST['Country']);
              $patient_data-&gt;setPatientID($_POST['Patients_ID']);
              $patient_data-&gt;setFlag(1);
  
              $doctorsArray = array("ACD","ABC"); //some hard coded values for the time being
              $patient_data-&gt;setDoctors($doctorsArray);
  
              $patient_medical_info = new PatientInfo();
  
              $patient_medical_info-&gt;setBP($_POST['BP']);
              $patient_medical_info-&gt;setTemperature($_POST['Temperature']);
              $patient_medical_info-&gt;setInformation($_POST['Info']);
              $patient_medical_info-&gt;setPatientID($_POST['Patients_ID']);
              $patient_medical_info-&gt;setDateOfMeeting(date("d/m/y"));
  
             $patient_data-&gt;save();
             $patient_medical_info-&gt;save();
  
  
            $this-&gt;response-&gt;redirect("../../../../WebMCare/PatientSignIn/Index");
  
         }
      }
  </code></pre>
  
  <p>The structure of my database is the same as these classes - I have a table <code>Users_Abstract</code> with all the attributes of the abstract class and I have a table <code>User_Patients</code> with all the attributes of the child class. </p>
  
  <p>When I hit the save button on the form in the view and check the database tables, I discover that the new entries are added in the <code>patient_info</code> table. Which means that the <code>$patient_medical_info-&gt;save()</code> is working. </p>
  
  <p>However, the table <code>users_abstract</code> does not contain any new data for the corresponding object, while the table <code>user_patients</code> does get the associated data. I checked messages for errors in save method, but it returned nothing.
  I can't seem to find anything online.
  Please help me.</p>
  
  <p>I have tried storing data in a single table by associating one table, with all 12 attributes, to the classes <code>UsersAbstract</code> and <code>User_Patients</code>. Even that does not work.</p>