src/MVQN/Data/Models/Model.php
private static function getPrimaryKey(string $table): array
    {
        if (self::$primaryKeyCache !== null && array_key_exists($table, self::$primaryKeyCache))
            return self::$primaryKeyCache[$table];

        // Ensure the database is connected!
        $pdo = Database::connect();

        /** @noinspection SqlResolve */
        $query = "
            SELECT
                tc.constraint_name, tc.table_name, kcu.column_name, 
                ccu.table_name AS foreign_table_name,
                ccu.column_name AS foreign_column_name 
            FROM 
                information_schema.table_constraints AS tc 
                JOIN information_schema.key_column_usage AS kcu
                  ON tc.constraint_name = kcu.constraint_name
                JOIN information_schema.constraint_column_usage AS ccu
                  ON ccu.constraint_name = tc.constraint_name
            WHERE constraint_type = 'PRIMARY KEY' AND tc.table_name = '$table'
        ";

        $results = $pdo->query($query);
        self::$primaryKeyCache[$table] = $results->fetch(); // ONLY ONE PRIMARY KEY!

        return self::$primaryKeyCache[$table];
    }
private static function getPrimaryKey(string $table): array
    {
        if (self::$primaryKeyCache !== null && array_key_exists($table, self::$primaryKeyCache))
            return self::$primaryKeyCache[$table];

        // Ensure the database is connected!
        $pdo = Database::connect();

        /** @noinspection SqlResolve */
        $query = "
            SELECT
                tc.constraint_name, tc.table_name, kcu.column_name, 
                ccu.table_name AS foreign_table_name,
                ccu.column_name AS foreign_column_name 
            FROM 
                information_schema.table_constraints AS tc 
                JOIN information_schema.key_column_usage AS kcu
                  ON tc.constraint_name = kcu.constraint_name
                JOIN information_schema.constraint_column_usage AS ccu
                  ON ccu.constraint_name = tc.constraint_name
            WHERE constraint_type = 'PRIMARY KEY' AND tc.table_name = '$table'
        ";

        $results = $pdo->query($query);
        self::$primaryKeyCache[$table] = $results->fetch(); // ONLY ONE PRIMARY KEY!

        return self::$primaryKeyCache[$table];
    }
Gets the PRIMARY KEY for the specified table.

@param string $table The table name to inspect.
@return array Returns an array of information pertaining to the PRIMARY KEY of the specified table.
@throws DatabaseConnectionException