SQLSrvQueryBuilder
class SQLSrvQueryBuilder implements IQueryBuilder (View source)
The SQLSrvQueryBuilder class implements the IQueryBuilder interfaces to provide a flexible query building mechanism using various database engines.
Utilizes the Singleton pattern to ensure a single instance. The class allows setting and retrieving query strategies based on the database engine, and provides methods for constructing SQL queries with various clauses such as SELECT, JOIN, WHERE, and ORDER. It also supports fetching results and metadata. It uses the Singleton pattern to ensure a single instance and provides a flexible query building mechanism using various database engines.
Methods:
__construct(IConnection $context = null): Initializes the query builder with a database connection context.with(IConnection $context): Static initializer that sets the database connection context and returns the query builder instance.setContext(IQueryBuilder $context): Sets the query context instance.getContext(): Returns the query context instance.
Query Building Methods:
select(array|string ...$data): Adds a SELECT clause to the query.distinct(array|string ...$data): Adds a DISTINCT clause to the query.from(array|string ...$data): Adds a FROM clause to the query.join(array|string ...$data): Adds a JOIN clause to the query.selfJoin(array|string ...$data): Adds a SELF JOIN clause to the query.leftJoin(array|string ...$data): Adds a LEFT JOIN clause to the query.rightJoin(array|string ...$data): Adds a RIGHT JOIN clause to the query.innerJoin(array|string ...$data): Adds an INNER JOIN clause to the query.outerJoin(array|string ...$data): Adds an OUTER JOIN clause to the query.crossJoin(array|string ...$data): Adds a CROSS JOIN clause to the query.on(array|string ...$data): Adds an ON clause to the query.andOn(array|string ...$data): Adds an AND ON clause to the query.orOn(array|string ...$data): Adds an OR ON clause to the query.where(array|string ...$data): Adds a WHERE clause to the query.andWhere(array|string ...$data): Adds an AND WHERE clause to the query.orWhere(array|string ...$data): Adds an OR WHERE clause to the query.having(array|string ...$data): Adds a HAVING clause to the query.andHaving(array|string ...$data): Adds an AND HAVING clause to the query.orHaving(array|string ...$data): Adds an OR HAVING clause to the query.group(array|string ...$data): Adds a GROUP BY clause to the query.order(array|string ...$data): Adds an ORDER BY clause to the query.orderAsc(array|string ...$data): Adds an ORDER BY ASC clause to the query.orderDesc(array|string ...$data): Adds an ORDER BY DESC clause to the query.limit(array|string ...$data): Adds a LIMIT clause to the query.
Query Execution Methods:
build(): Builds the query string.buildRaw(): Builds the raw query string.getValues(): Returns the query values.getAllMetadata(): Returns the query metadata.fetch(int $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null): Fetches a single row from the query result.fetchAll(int $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null): Fetches all rows from the query result.
Properties:
$context: The database connection context.$self: The singleton instance of the QueryBuilder.$lastQuery: The last query executed.$cursorExhausted: The current query cursor exhausted status.
Traits
This trait is part of the Generic QueryBuilder module and is used to encapsulate reusable query-building logic for database operations.
This trait provides methods to manage a single instance of a class or multiple instances identified by a unique hash. It includes methods to get, create, set, and clear instances.
Properties
| QueryObject | $query | from Query | |
| static protected IConnection | $context | Property to store settings |
from Context |
Methods
Initializes the query object, this method is used to lazily set the query object if it has not been set.
Create or obtain an instance If no hash is provided, works as classic singleton If hash is provided, creates/returns instance for that hash
Create a new instance of the class and set it as the instance
Clear all instances including the classic singleton instance
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Details
in
Query at line 23
void
initQuery()
Initializes the query object, this method is used to lazily set the query object if it has not been set.
static protected void
setContext(IConnection $context)
Set default context for all instances
protected IConnection
getContext()
Get context for current instance
static Singleton
getInstance(string|null $hash = null)
Create or obtain an instance If no hash is provided, works as classic singleton If hash is provided, creates/returns instance for that hash
static Singleton
newInstance(string|null $hash = null)
Create a new instance of the class and set it as the instance
static void
setInstance(Singleton $instance, string|null $hash = null)
Set a specific instance
static void
clearInstance(string|null $hash = null)
Clear instance(s)
static void
clearAllInstances()
Clear all instances including the classic singleton instance
__construct(IConnection|null $context = null)
No description
static SQLSrvQueryBuilder
with(IConnection $context)
Static initializer with context
static IQueryBuilder
select(array|string ...$data)
No description
static IQueryBuilder
distinct(array|string ...$data)
No description
static IQueryBuilder
from(array|string ...$data)
No description
static IQueryBuilder
join(array|string ...$data)
No description
static IQueryBuilder
selfJoin(array|string ...$data)
No description
static IQueryBuilder
leftJoin(array|string ...$data)
No description
static IQueryBuilder
rightJoin(array|string ...$data)
No description
static IQueryBuilder
innerJoin(array|string ...$data)
No description
static IQueryBuilder
outerJoin(array|string ...$data)
No description
static IQueryBuilder
crossJoin(array|string ...$data)
No description
static IQueryBuilder
on(array|string ...$data)
No description
static IQueryBuilder
andOn(array|string ...$data)
No description
static IQueryBuilder
orOn(array|string ...$data)
No description
static IQueryBuilder
where(array|string ...$data)
No description
static IQueryBuilder
andWhere(array|string ...$data)
No description
static IQueryBuilder
orWhere(array|string ...$data)
No description
static IQueryBuilder
having(array|string ...$data)
No description
static IQueryBuilder
andHaving(array|string ...$data)
No description
static IQueryBuilder
orHaving(array|string ...$data)
No description
static IQueryBuilder
group(array|string ...$data)
No description
static IQueryBuilder
order(array|string ...$data)
No description
static IQueryBuilder
orderAsc(array|string ...$data)
No description
static IQueryBuilder
orderDesc(array|string ...$data)
No description
static IQueryBuilder
limit(array|string ...$data)
No description
void
reset()
No description
string
build()
No description
string
buildRaw()
No description
array
getValues()
No description
object
getAllMetadata()
No description
mixed
fetch(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)
No description
array|bool
fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)
No description