code: public static function countRows(array $conditions, bool $critical = false)
      {
          $entity = new static();
          $selectQuery = new Select($entity->getDatabaseName(), $critical);
          $selectQuery->select([ 'count' => 'COUNT(*)' ]);
          $selectQuery->from($entity->getTableName());
          if (count($conditions) > 0) {
              $where = array();
              foreach ($conditions as $key => $value) {
                  $realName = constant(get_called_class() . '::FIELD_' . strtoupper(Helper::codifyName($key)));
                  $where[$realName] = ':where' . ucfirst($key);
                  $selectQuery->bind('where' . ucfirst($key), $value);
              }
              $selectQuery->where($where);
          }
          if ($selectQuery->execute() === false) {
              return false;
          }
          $data = $selectQuery->fetch();
          if ($data === false) {
              return false;
          }
  
          return $data['count'];
      }
docs: Count rows satisfying the specified conditions.
  
  @param  array $conditions where conditions
  @param  bool  $critical   if true, will be executed on write server
  @return int|false   number of rows or false on error