original_string: public function count_field_values($table, string $field = null,  array $where = [], array $order = []){
      if ( \is_array($table) && \is_array($table['fields']) && count($table['fields']) ){
        $args = $table;
        $field = array_values($table['fields'])[0];
      }
      else{
        $args = [
          'tables' => [$table],
          'where' => $where,
          'order' => $order
        ];
      }
      $args = array_merge($args, [
        'kind' => 'SELECT',
        'fields' => [
          'val' => $field,
          'num' => 'COUNT(*)'
        ],
        'group_by' => [$field]
      ]);
      return $this->rselect_all($args);
    }
code: public function count_field_values($table, string $field = null,  array $where = [], array $order = []){
      if ( \is_array($table) && \is_array($table['fields']) && count($table['fields']) ){
        $args = $table;
        $field = array_values($table['fields'])[0];
      }
      else{
        $args = [
          'tables' => [$table],
          'where' => $where,
          'order' => $order
        ];
      }
      $args = array_merge($args, [
        'kind' => 'SELECT',
        'fields' => [
          'val' => $field,
          'num' => 'COUNT(*)'
        ],
        'group_by' => [$field]
      ]);
      return $this->rselect_all($args);
    }
code_tokens: public function count_field_values ( $ table , string $ field = null , array $ where = [ ] , array $ order = [ ] ) { if ( \ is_array ( $ table ) && \ is_array ( $ table [ 'fields' ] ) && count ( $ table [ 'fields' ] ) ) { $ args = $ table ; $ field = array_values ( $ table [ 'fields' ] ) [ 0 ] ; } else { $ args = [ 'tables' => [ $ table ] , 'where' => $ where , 'order' => $ order ] ; } $ args = array_merge ( $ args , [ 'kind' => 'SELECT' , 'fields' => [ 'val' => $ field , 'num' => 'COUNT(*)' ] , 'group_by' => [ $ field ] ] ) ; return $ this -> rselect_all ( $ args ) ; }
docstring: Return a count of identical values in a field as array, reporting a structure type 'num' - 'val'.
  
  ```php
  \bbn\x::dump($db->count_field_values('table_users','surname',[['name','=','John']]));
  // (array) ["num" => 2, "val" => "John"]
  ```
  
  @param string|array $table The table's name or a configuration array
  @param null|string $field The field's name
  @param array $where The "where" condition
  @param array $order The "order" condition
  @return array | false
docstring_tokens: Return a count of identical values in a field as array reporting a structure type num - val .