original_string: private function checkTable($modelObj)
      {
          if (!method_exists($modelObj, 'table')) {
              return false;
          }
  
          // get table name
          $tableName = $modelObj->table();
  
          // check table, add if not exist
          $existTable = PdoDriver::getInstance()->tableExists($tableName);
  
          if (!$existTable) {
              $this->createTable($tableName, $modelObj->getFields());
              CliManager::getMessage('Created table ' . $tableName);
          }
  
          // get database table data and check
          PdoDriver::getInstance()->query('SHOW COLUMNS FROM ' . $tableName);
          $dbFields = PdoDriver::getInstance()->selectAll();
  
          $modelFieldNames = [];
  
          foreach ($modelObj->getFields() as $modelField) {
              $modelFieldNames[] = $modelField->identifier();
          }
  
          // check db fields on model fields
          $dbFieldNames = [];
  
          foreach ($dbFields as $dbField) {
              if (!in_array($dbField->Field, $modelFieldNames)) {
                  echo " --- Old field " . CliManager::setTextColor($dbField->Field, 'yellow') . " in table " . CliManager::setTextColor($modelObj->table(), 'green') . " --- \n\r";
              }
  
              $dbFieldNames[] = $dbField->Field;
          }
  
          // check model fields on db fields
          foreach ($modelObj->getFields() as $key => $modelField) {
              if (!in_array($modelField->identifier(), $dbFieldNames)) {
                  // Add new fields to db table
                  $previousField = false;
  
                  if (isset($modelObj->getFields()[$key-1])) {
                      $previousField = $modelObj->getFields()[$key-1];
                  }
  
                  $this->createField($tableName, $modelField, $previousField);
                  echo CliManager::setTextColor(" --- Add New field " . $modelField->identifier() . " in table " . $modelObj->table(), 'green') . " --- \n\r";
              }
          }
      }
code: private function checkTable($modelObj)
      {
          if (!method_exists($modelObj, 'table')) {
              return false;
          }
  
          // get table name
          $tableName = $modelObj->table();
  
          // check table, add if not exist
          $existTable = PdoDriver::getInstance()->tableExists($tableName);
  
          if (!$existTable) {
              $this->createTable($tableName, $modelObj->getFields());
              CliManager::getMessage('Created table ' . $tableName);
          }
  
          // get database table data and check
          PdoDriver::getInstance()->query('SHOW COLUMNS FROM ' . $tableName);
          $dbFields = PdoDriver::getInstance()->selectAll();
  
          $modelFieldNames = [];
  
          foreach ($modelObj->getFields() as $modelField) {
              $modelFieldNames[] = $modelField->identifier();
          }
  
          // check db fields on model fields
          $dbFieldNames = [];
  
          foreach ($dbFields as $dbField) {
              if (!in_array($dbField->Field, $modelFieldNames)) {
                  echo " --- Old field " . CliManager::setTextColor($dbField->Field, 'yellow') . " in table " . CliManager::setTextColor($modelObj->table(), 'green') . " --- \n\r";
              }
  
              $dbFieldNames[] = $dbField->Field;
          }
  
          // check model fields on db fields
          foreach ($modelObj->getFields() as $key => $modelField) {
              if (!in_array($modelField->identifier(), $dbFieldNames)) {
                  // Add new fields to db table
                  $previousField = false;
  
                  if (isset($modelObj->getFields()[$key-1])) {
                      $previousField = $modelObj->getFields()[$key-1];
                  }
  
                  $this->createField($tableName, $modelField, $previousField);
                  echo CliManager::setTextColor(" --- Add New field " . $modelField->identifier() . " in table " . $modelObj->table(), 'green') . " --- \n\r";
              }
          }
      }
code_tokens: private function checkTable ( $ modelObj ) { if ( ! method_exists ( $ modelObj , 'table' ) ) { return false ; } // get table name $ tableName = $ modelObj -> table ( ) ; // check table, add if not exist $ existTable = PdoDriver :: getInstance ( ) -> tableExists ( $ tableName ) ; if ( ! $ existTable ) { $ this -> createTable ( $ tableName , $ modelObj -> getFields ( ) ) ; CliManager :: getMessage ( 'Created table ' . $ tableName ) ; } // get database table data and check PdoDriver :: getInstance ( ) -> query ( 'SHOW COLUMNS FROM ' . $ tableName ) ; $ dbFields = PdoDriver :: getInstance ( ) -> selectAll ( ) ; $ modelFieldNames = [ ] ; foreach ( $ modelObj -> getFields ( ) as $ modelField ) { $ modelFieldNames [ ] = $ modelField -> identifier ( ) ; } // check db fields on model fields $ dbFieldNames = [ ] ; foreach ( $ dbFields as $ dbField ) { if ( ! in_array ( $ dbField -> Field , $ modelFieldNames ) ) { echo " --- Old field " . CliManager :: setTextColor ( $ dbField -> Field , 'yellow' ) . " in table " . CliManager :: setTextColor ( $ modelObj -> table ( ) , 'green' ) . " --- \n\r" ; } $ dbFieldNames [ ] = $ dbField -> Field ; } // check model fields on db fields foreach ( $ modelObj -> getFields ( ) as $ key => $ modelField ) { if ( ! in_array ( $ modelField -> identifier ( ) , $ dbFieldNames ) ) { // Add new fields to db table $ previousField = false ; if ( isset ( $ modelObj -> getFields ( ) [ $ key - 1 ] ) ) { $ previousField = $ modelObj -> getFields ( ) [ $ key - 1 ] ; } $ this -> createField ( $ tableName , $ modelField , $ previousField ) ; echo CliManager :: setTextColor ( " --- Add New field " . $ modelField -> identifier ( ) . " in table " . $ modelObj -> table ( ) , 'green' ) . " --- \n\r" ; } } }
docstring: Check Table fields
  
  @param $modelObj
  @return bool
docstring_tokens: Check Table fields