tursodatabase / turso-client-php

Turso + PHP - libSQL Extension for PHP
https://turso.tech/php
MIT License
45 stars 4 forks source link

[Feature Request]: Support SQLite3Result Class in libSQL #1

Closed darkterminal closed 3 months ago

darkterminal commented 3 months ago

Description

Need implementation of SQLite3Result Class in libSQL. Proposal name is LibSQLResult.

Describe the solution you'd like

class SQLite3Result {
   /* Methods */
   private __construct()
   public columnName(int $column): string|false
   public columnType(int $column): int|false
   public fetchArray(int $mode = SQLITE3_BOTH): array|false
   public finalize(): bool
   public numColumns(): int
   public reset(): bool
}

here is:

/**
 * Represents the result of a LibSQL query.
 */
class LibSQLResult
{
    /**
     * Creates a new LibSQLResult instance.
     *
     * @param string $config The configuration string for the database connection.
     * @param string $sql The SQL query that produced this result.
     * @param array $parameters The parameters for the SQL query (optional).
     */
    public function __construct(string $config, string $sql, array $parameters = [])
    {
    }

    /**
     * Fetches the result set as an array.
     *
     * @param int $mode The fetching mode (optional, default is 3).
     *
     * @return array The fetched result set.
     */
    public function fetchArray(int $mode = 3)
    {
    }

    /**
     * Finalizes the result set and frees the associated resources.
     *
     * @return void
     */
    public function finalize()
    {
    }

    /**
     * Resets the result set for re-execution.
     *
     * @return void
     */
    public function reset()
    {
    }

    /**
     * Retrieves the name of a column by its index.
     *
     * @param int $column The index of the column.
     *
     * @return string The name of the column.
     */
    public function columnName(int $column)
    {
    }

    /**
     * Retrieves the type of a column by its index.
     *
     * @param int $column The index of the column.
     *
     * @return string The type of the column.
     */
    public function columnType(int $column)
    {
    }

    /**
     * Retrieves the number of columns in the result set.
     *
     * @return int The number of columns.
     */
    public function numColumns()
    {
    }
}

The finalize method is handle by libSQL by default.

Describe alternatives you've considered

No response