Return the number of rows in the given $table (on ID column).

@param string $table

@return int
489920
protected function getTotalBackupCount($table)
    {
        $platform = $this->connection->getDatabasePlatform();

        $queryBuilder = $this->connection->createQueryBuilder();
        $queryBuilder
            ->select($platform->getCountExpression('id'))
            ->from($table);

        return (int)$queryBuilder->execute()->fetchColumn();
    }
330127
public function FetchColumns($Table) {
      $Sql = $this->FetchColumnSql($Table);
      $Data = $this->Query($Sql);
      $Return = array();
      foreach($Data->ResultArray() as $Row) {
         if (isset($Row['COLUMN_NAME']))
            $Return[] = $Row['COLUMN_NAME'];
         else
            $Return[] = current($Row);
      }

      return $Return;
   }
231773
public static function sumOfSqrt($table)
    {
        $cnt = count($table);
        $sum = 0;
        for ($x =0;$x < $cnt; $x++ ){
            $sum = $sum + sqrt($table[$x]);
        }
        return ($sum);
    }
17278
public function countRecordsInTableMatching($table, $criteria = []): int
    {
        $where = '';
        foreach ($criteria as $field => $vale) {
            if ($where) {
                $where .= ' AND ';
            }
            if ($vale === null) {
                $where .= sprintf('%s IS NULL', $field);
            } else {
                $where .= sprintf('%s = :%s', $field, $field);
            }
        }
        $query = sprintf('SELECT count(*) AS records FROM %s WHERE %s', $table, $where);

        /** @var EntityManager $manager */
        $manager = $this->client->getContainer()->get('doctrine')->getManager();
        $rsm = new ResultSetMapping();
        $rsm->addScalarResult('records', 'records', 'integer');
        $query = $manager->createNativeQuery($query, $rsm);
        $query->setParameters($criteria);

        return (int) $query->getSingleScalarResult();
    }
1162153
public function rowsFrom(string $table, string ...$tables)
    {
        $instance = $this->deleteQueryInstance();

        $instance->deleteQuery()->rowsFrom($table, ...$tables);

        return $instance;
    }
960129
public function hasTable($table)
    {
        $table = $this->connection->getTablePrefix().$table;

        return count($this->connection->selectFromWriteConnection(
            $this->grammar->compileTableExists(), [$table]
        )) > 0;
    }
520281
public function table_id($table, $db=false){
    if ( substr_count($table, ".") === 1 ){
      return $table;
    }
    else {
      return ( $db ?: $this->client_db ).'.'.$table;
    }
  }
939107
protected function _fetchTableInfo($table)
    {
        $return = null;
        $query  = $this->getObject('lib:database.query.show')
            ->show('TABLE STATUS')
            ->like(':like')
            ->bind(array('like' => $table));

        if($info = $this->select($query, KDatabase::FETCH_OBJECT)) {
            $return = $this->_parseTableInfo($info);
        }

        return $return;
    }
346326
public function FetchColumnSql($Table) {
      if ($Table[0] != '`' && !StringBeginsWith($Table, $this->Database->DatabasePrefix))
         $Table = $this->Database->DatabasePrefix.$Table;
      
      return "show columns from ".$this->FormatTableName($Table);
   }
386312
public function getTableIndexes( $table )
    {
        $query = "SELECT * FROM information_schema.statistics WHERE table_schema =
                 ? AND table_name = ?";

        $params = [ $this->name, $table ];

        $statement = $this->database->prepare( $query );
        $statement->execute( $params );

        $results = $statement->fetchAll();

        $indexes = [ ];

        if ( !empty( $results ) )
        {
            $name = NULL;

            $i = 0;

            foreach ( $results as $result )
            {
                if ( !in_array( $result[ 'INDEX_NAME' ], $indexes ) )
                {
                    $indexes[ ] = $result[ 'INDEX_NAME' ];
                }
            }
        }

        return $indexes;
    }
1136475
public function getResetSequenceSQL($table) {

        if (is_string($table)) {
            $tablename = $table;
            $xmldb_table = new xmldb_table($tablename);
        } else {
            $tablename = $table->getName();
            $xmldb_table = $table;
        }
        // From http://www.acs.ilstu.edu/docs/oracle/server.101/b10759/statements_2011.htm
        $value = (int)$this->mdb->get_field_sql('SELECT MAX(id) FROM {'.$tablename.'}');
        $value++;

        $seqname = $this->getSequenceFromDB($xmldb_table);

        if (!$seqname) {
            // Fallback, seqname not found, something is wrong. Inform and use the alternative getNameForObject() method
            $seqname = $this->getNameForObject($table, 'id', 'seq');
        }

        return array ("DROP SEQUENCE $seqname",
                      "CREATE SEQUENCE $seqname START WITH $value INCREMENT BY 1 NOMAXVALUE CACHE $this->sequence_cache_size");
    }
504266
public function insert_id($table = null)
    {
        if (!$this->db_connected || $this->db_mode == 'r' || empty($table)) {
            return false;
        }

        $sequence = $this->quote_identifier($this->sequence_name($table));
        $result   = $this->query("SELECT $sequence.currval FROM dual");
        $result   = $this->fetch_array($result);

        return $result[0] ?: false;
    }
165690
public function has_id_increment($table): bool
  {
    return ($model = $this->modelize($table)) &&
      isset($model['keys']['PRIMARY']) &&
      (\count($model['keys']['PRIMARY']['columns']) === 1) &&
      ($model['fields'][$model['keys']['PRIMARY']['columns'][0]]['extra'] === 'auto_increment');
  }
322053
public function countAll($column = '*')
    {
        $results = $this->db->get($this->table, NULL, $column);

        return (int) count($results);
    }
712934
public function get_table_definition($table) {
		$statement = $this->get_statement('DESC ' . $this->quote_identifier($table), []);
		$statement->execute();
		$result = $statement->fetch_assoc();
		return $result;
	}
296521
protected function fetchIndexesDb($table = '') {
        $stm = $this->get(
            new Identifier('information_schema', 'STATISTICS'),
            [
                'TABLE_SCHEMA' => $this->getDbName(),
                'TABLE_NAME' => $this->prefixTable($table, false)
            ],
            [
                'columns' => [
                    'INDEX_NAME',
                    'COLUMN_NAME',
                    'NON_UNIQUE'
                ],
                'order' => ['INDEX_NAME', 'SEQ_IN_INDEX']
            ]
        );
        $indexRows = $stm->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP);

        $indexes = [];
        foreach ($indexRows as $indexName => $columns) {
            $index = [
                'type' => null,
                'columns' => array_column($columns, 'COLUMN_NAME'),
                'name' => $indexName
            ];

            if ($indexName === 'PRIMARY') {
                $index['type'] = Db::INDEX_PK;
            } else {
                $index['type'] = $columns[0]['NON_UNIQUE'] ? Db::INDEX_IX : Db::INDEX_UNIQUE;
            }
            $indexes[] = $index;
        }

        return $indexes;
    }
240343
public function getNumOfParent($id)
    {
        if ($parents = $this->qb
            ->table($this->table)
            ->select('id')
            ->where('id', $id)
            ->get()) {
            return $parents->count();
        }

        return 0;
    }