- Rudra\Model\Driver\MySQL
- Rudra\Model\Driver\PgSQL
- Rudra\Model\Driver\SQLite
- Rudra\Model\Entity
- Rudra\Model\Model
- Rudra\Model\QB
- Rudra\Model\QBFacade
- Rudra\Model\Repository
- Rudra\Model\Schema
| Visibility | Function |
|---|---|
| public | concat(string $fieldName, string $alias, ?string $orderBy): string |
| public | close(): string |
| public | integer(string $field, string $default, bool $autoincrement, string $null): string |
| public | string(string $field, string $default, string $null): string |
| public | text(string $field, string $null): string |
| public | created_at(): string |
| public | updated_at(): string |
| public | pk(string $field): string |
| Visibility | Function |
|---|---|
| public | concat(string $fieldName, string $alias, ?string $orderBy): string |
| public | close(): string |
| public | integer(string $field, string $default, bool $pk, string $null): string |
| public | string(string $field, string $default, string $null): string |
| public | text(string $field, string $null): string |
| public | created_at(): string |
| public | updated_at(): string |
| public | pk(string $field): string |
| Visibility | Function |
|---|---|
| public | concat(string $fieldName, string $alias, ?string $orderBy): string |
| public | close(): string |
| public | integer(string $field, string $default, bool $pk, string $null): string |
| public | string(string $field, string $default, string $null): string |
| public | text(string $field, string $null): string |
| public | created_at(): string |
| public | updated_at(): string |
| public | pk(string $field): string |
| Visibility | Function |
|---|---|
| public static | __callStatic(string $method, array $parameters): mixed |
| public | __call(string $method, array $parameters): mixed |
| protected static | callMethod(string $method, array $parameters): mixedDynamically calls a method on the corresponding Model, Repository, or parent Repository class. The method first attempts to call the method on the Model class associated with the Entity. If the Model does not exist, it falls back to the Repository class. If the Repository does not exist, it defaults to the parent Repository class. |
| Visibility | Function |
|---|---|
| public | __construct(?string $table) |
| public | __call(string $method, array $parameters): mixedHandles calls to undefined methods by delegating them to the corresponding Repository class. The method dynamically resolves the Repository class associated with the Model. If the Repository does not exist, it falls back to the parent Repository class. If the method exists in the resolved Repository, it is invoked with the provided parameters. Otherwise, an exception is thrown. |
| Visibility | Function |
|---|---|
| public | __construct(?PDO $connection)Initializes the database driver based on the provided connection or a default connection from the container. If no connection is provided and none is available in the container, a LogicException is thrown. The driver is selected based on the database type specified in the connection's driver attribute. |
| public | select(string $fields): self |
| public | concat(string $fieldName, string $alias, ?string $orderBy): self |
| public | from(string $table): self |
| public | where(string $param): self |
| public | and(string $param): self |
| public | or(string $param): self |
| public | limit(string|int $param): self |
| public | offset(string|int $param): self |
| public | orderBy(string $param): self |
| public | groupBy(string $param): self |
| public | join(string $param, string $type): self |
| public | on(string $param): self |
| public | get(): string |
| public | create(string $table): self |
| public | close(): self |
| public | integer(string $field, string $default, bool $autoincrement, string $null): self |
| public | string(string $field, string $default, string $null): self |
| public | text(string $field, string $null): self |
| public | created_at(): self |
| public | updated_at(): self |
| public | pk(?string $field): self |
| Visibility | Function |
|---|---|
| public static | __callStatic(string $method, array $parameters): mixedHandles static method calls for the Facade class It dynamically resolves the underlying class name by removing "Facade" from the class name If the resolved class does not exist, it attempts to clean up the class name by removing spaces If the resolved class is not already registered in the container, it registers it Finally, it delegates the static method call to the resolved class instance |
| Visibility | Function |
|---|---|
| public | __construct(?string $table, ?PDO $connection)Initializes the class with a table name, connection, and sets up dependencies. The connection is either provided directly or retrieved from the Rudra container. If the connection is not an instance of PDO, a LogicException is thrown. |
| public | __call(string $method, array $parameters): neverHandles calls to undefined methods by throwing a LogicException. This method is invoked when an attempt is made to call a non-existent method on the object. |
| public | qb(): Rudra\Model\QBReturns an instance of the Query Builder (QB). If the QB instance is not yet initialized, it creates a new instance using the connection. This method implements lazy initialization to ensure the QB instance is created only when needed. |
| public | connection(): PDOReturns the current PDO instance used by the repository. |
| public | onConnection(PDO $connection): selfSets the connection for the database connection and resets the Query Builder instance. This method allows changing the connection dynamically and ensures that the Query Builder is re-initialized. |
| public | withConnection(PDO $connection): selfCreates and returns a new instance of the class with the specified connection. This method allows changing the connection while preserving the current table name. It is useful for creating new instances with different database connections without modifying the original object. |
| public | qBuilder(string $queryString, array $queryParams): arrayExecutes a custom SQL query and returns the result as an associative array. The method prepares the query, executes it with optional parameters, and fetches all results. |
| public | getAllPerPage(Rudra\Pagination $pagination, ?string $fields): array |
| public | find(string|int $id): array|false |
| public | getAll(string $sort, ?string $fields): array |
| public | numRows(): int |
| public | findBy(string $field, mixed $value): array|falseFinds a single record by a specified field and value. The field name is validated against the actual table columns to prevent SQL injection. |
| public | lastInsertId(): string |
| public | update(array $fields): void |
| public | create(array $fields): void |
| public | delete(string|int $id): void |
| protected static | updateStmtString(array $fields): stringGenerates a string of fields and placeholders for an SQL UPDATE statement. The method takes an array of fields and constructs a comma-separated list of "key=:key" pairs. This string can be directly used in the SET clause of an SQL UPDATE query. |
| protected static | createStmtString(array $fields): arrayGenerates two strings for an SQL INSERT statement: one for column names and one for placeholders. The method takes an array of fields and constructs two comma-separated lists: - A list of column names. - A list of placeholders (prefixed with colons) for parameter binding. These strings can be directly used in the SQL INSERT query. |
| public | getColumns(): arrayRetrieves the column information for the current table based on the database driver. The method executes a query specific to the database type (MySQL, PostgreSQL, or SQLite) to fetch the column details of the table. |
| public | getFields(?string $fields): arrayRetrieves the list of fields (columns) for the current table. If no specific fields are provided, the method fetches all column names based on the database driver. Otherwise, it splits the provided comma-separated string of fields into an array. |
| public | search(string $search, string $column, ?string $fields): arraySearches for records in the database based on a search term and column. The column name is validated against the actual table columns to prevent SQL injection. Results are ordered by ID in descending order and limited to 10 records. |
| public | cache(array $params, ?string $cacheTime): mixedCaches the result of a method call to a JSON file for a specified duration. If the cached file exists and is still valid (based on cache time), the cached data is returned. Otherwise, the method executes the specified method, caches its result, and returns the data. |
| public | clearCache(string $type, ?string $key): voidClears cached files of a specified type or all types. If a cache key is provided, only that specific cache file is deleted. |
| Visibility | Function |
|---|---|
| public static | create(string $table, callable $callback): selfCreates a new Schema instance and defines the table structure using a callback function. The callback function is used to configure the table schema via the Query Builder. |
| public | execute(): boolExecutes the schema creation by preparing and running the SQL query. The SQL query is generated using the Query Builder and executed on the database connection. |