Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function count($column = self::DEFAULT_COUNTING_FIELD)
 {
     if ($column == self::DEFAULT_COUNTING_FIELD && !empty($this->loader->getPrimaryKey())) {
         $column = 'DISTINCT(' . $this->loader->getPrimaryKey() . ')';
     }
     return parent::count($column);
 }
 /**
  * Fetch one record from database using it's primary key. You can use INLOAD and JOIN_ONLY
  * loaders with HAS_MANY or MANY_TO_MANY relations with this method as no limit were used.
  *
  * @see findOne()
  * @param mixed $id Primary key value.
  * @return RecordEntity|null
  * @throws SelectorException
  */
 public function findByPK($id)
 {
     $primaryKey = $this->loader->getPrimaryKey();
     if (empty($primaryKey)) {
         throw new SelectorException("Unable to fetch data by primary key, no primary key found.");
     }
     //No limit here
     return $this->findOne([$primaryKey => $id], false);
 }