src/Towel/Model/BaseModel.php
public function hydrate(PDOStatement $results) {

    if (method_exists($this, 'preHydrate')) {
      $results = $this->preHydrate($results);
    }

    $return = array();

    if ($results) {
      $arrayResults = $results->fetchAll();
      foreach ($arrayResults as $arrayResult) {
        $className = get_class($this);
        $object = new $className();
        $return[$arrayResult[$this->id_name]] = $object->setRecord($arrayResult);
      }
    }

    if (method_exists($this, 'postHydrate')) {
      $return = $this->preHydrate($return);
    }

    return $return;
  }
public function hydrate(PDOStatement $results) {

    if (method_exists($this, 'preHydrate')) {
      $results = $this->preHydrate($results);
    }

    $return = array();

    if ($results) {
      $arrayResults = $results->fetchAll();
      foreach ($arrayResults as $arrayResult) {
        $className = get_class($this);
        $object = new $className();
        $return[$arrayResult[$this->id_name]] = $object->setRecord($arrayResult);
      }
    }

    if (method_exists($this, 'postHydrate')) {
      $return = $this->preHydrate($return);
    }

    return $return;
  }
public function hydrate ( PDOStatement $ results ) { if ( method_exists ( $ this , 'preHydrate' ) ) { $ results = $ this -> preHydrate ( $ results ) ; } $ return = array ( ) ; if ( $ results ) { $ arrayResults = $ results -> fetchAll ( ) ; foreach ( $ arrayResults as $ arrayResult ) { $ className = get_class ( $ this ) ; $ object = new $ className ( ) ; $ return [ $ arrayResult [ $ this -> id_name ] ] = $ object -> setRecord ( $ arrayResult ) ; } } if ( method_exists ( $ this , 'postHydrate' ) ) { $ return = $ this -> preHydrate ( $ return ) ; } return $ return ; }
Default Hydrate.

Use preHydrate and postHydrate methods to change the default behavior.
You can override this method too if you need.

@param PDOStatement $results

@return Array of Model Objects
Default Hydrate .