/**
  * @param string $name
  * @param array $args
  * @return bool|HaploActiveRecord
  */
 protected static function findOneBy($name, $args)
 {
     /** @var object $result */
     $name = str_replace(self::camelCaseToUnderscore($name), 'find_one_by_', '');
     $sql = self::$sqlBuilder->where($name, '=', $args[0])->get(static::tableName());
     $result = self::$db->getRow($sql);
     if (!empty($result)) {
         return static::hydrate($result);
     }
     return false;
 }
 /**
  * @param string $table
  * @return int
  */
 public function count($table = '')
 {
     $sql = sprintf('SELECT COUNT(*) FROM %s', $table !== '' ? $this->db->quoteIdentifier($table) : $this->from);
     if ($this->where !== '') {
         $sql .= ' WHERE ' . $this->where;
     }
     if ($this->groupBy !== '') {
         $sql .= ' GROUP BY ' . $this->groupBy;
     }
     if ($this->having !== '') {
         $sql .= ' HAVING ' . $this->having;
     }
     if ($this->orderBy !== '') {
         $sql .= ' ORDER BY ' . $this->orderBy;
     }
     $sql .= ';';
     $this->reset();
     return $sql;
 }