UNPKG

lupdo

Version:

Database Abstraction Layer for Node js

94 lines (93 loc) 4.65 kB
import { PdoAffectingData } from '../types/pdo-affecting-data'; import { PdoColumnData } from '../types/pdo-column-data'; import { PdoColumnValue } from '../types/pdo-column-value'; import { Params } from '../types/pdo-prepared-statement'; import { PdoRawConnectionI } from '../types/pdo-raw-connection'; import { PdoRowData } from '../types/pdo-raw-data'; import { Both, Dictionary, Fetched, Named, Newable, Pair, PdoStatementI } from '../types/pdo-statement'; export declare class PdoStatement implements PdoStatementI { protected readonly connection: PdoRawConnectionI; protected readonly rawSql: string; protected affectingResults: PdoAffectingData; protected sql: string; protected rawParams: Params | null; protected params: Params | null; protected cursor: number | null; protected rowset: number; protected isRowset: boolean; protected currentSelectResults: PdoRowData[]; protected currentColumns: PdoColumnData[]; protected selectResults: PdoRowData[] | PdoRowData[][]; protected columns: PdoColumnData[] | PdoColumnData[][]; constructor(connection: PdoRawConnectionI, rawSql: string, affectingResults: PdoAffectingData, selectResults: PdoRowData[] | PdoRowData[][], columns: PdoColumnData[] | PdoColumnData[][]); columnCount(): number; debug(): string; debugSent(): string; getColumnMeta(column: number): PdoColumnData | null; rowCount(): number; lastInsertId(name?: string): Promise<string | number | null>; getAttribute(attribute: string): string | number; setAttribute(attribute: string, value: number | string): boolean; /** * Specifies that the fetch method shall return each row as a key-value object keyed * by column name as returned in the corresponding result set. * If the result set contains multiple columns with the same name, * it returns only a single value per column name. */ fetchDictionary<T = Dictionary>(): Fetched<T>; /** * Specifies that the fetch method shall return each row as an array indexed by * column number as returned in the corresponding result set, starting at column 0. */ fetchArray(): Fetched<PdoColumnValue[]>; /** * Specifies that the fetch method shall return each row as a key-value object keyed by * both column name and number as returned in the corresponding result set, starting at column 0. */ fetchBoth(): Fetched<Both>; /** * Specifies that the fetch method shall return only a single requested column * from the next row in the result set. */ fetchColumn<T extends PdoColumnValue>(column: number): Fetched<T>; /** * Specifies that the fetch method shall return a new instance of the requested class, * mapping the columns to named properties in the class. * Note: The setter method is called if defined in the requested class */ fetchObject<T>(abstract: Newable<T>, constructorArgs?: any[]): Fetched<T>; /** * Allows completely customize the way data is treated on the fly. */ fetchClosure<T>(fn: (...args: any[]) => T): Fetched<T>; /** * Specifies that the fetch method shall return each row as a key-value object keyed * by column name as returned in the corresponding result set. * If the result set contains multiple columns with the same name, * it returns an array of values per column name. */ fecthNamed(): Fetched<Named>; /** * Fetch a two-column results into a key-value object where the first column is a key * and the second column is the value. */ fetchPair<T extends PdoColumnValue, U extends PdoColumnValue>(): Pair<T, U>; resetCursor(): void; protected fetched<T>(callable: (row: PdoRowData, columns: string[], duplicatedColumns: string[]) => T, withDuplicated?: boolean): Fetched<T>; protected getRowNulled(row: PdoRowData): PdoRowData; protected getCasedColumnsName(): string[]; protected getDuplicatedColumns(): string[]; protected assignPropsToObj(obj: any, row: PdoRowData, columns: string[]): void; protected fetch(): PdoRowData | null; protected fetchAll(): PdoRowData[]; protected setCursor(cursor: number | null): void; protected setCursorToEnd(): void; protected setCursorToStart(): void; protected getTempCursorForFetch(cursorOrientation: number): number; protected isValidCursor(cursor: number, cursorOrientation: number): boolean; protected resetRowset(): void; protected setCurrentColumns(): void; protected setCurrentSelectResults(): void; nextRowset(): boolean; } export default PdoStatement;