Takes table name, select query and list of bind values.
Deletes from the table, but only records with IDs returned by the select query, eg:
DELETE FROM $table WHERE id IN ($query)
SimpleQueryQUERY_STRING,[BIND_VALUE,...]
Execute the SQL string specified in QUERY_STRING
FetchResultQUERY,[BIND_VALUE,...]
Takes a SELECT query as a string, along with an array of BIND_VALUEs If the select succeeds, returns the
first row as an array. Otherwise, returns a Class::ResturnValue object with the failure loaded up.
BinarySafeBLOBs
Returns 1 if the current database supports BLOBs with embedded nulls. Returns undef if the current
database doesn't support BLOBs with embedded nulls
KnowsBLOBs
Returns 1 if the current database supports inserts of BLOBs automatically. Returns undef if the current
database must be informed of BLOBs for inserts.
BLOBParamsFIELD_NAMEFIELD_TYPE
Returns a hash ref for the bind_param call to identify BLOB types used by the current database for a
particular column type.
DatabaseVersion[Short=>1]
Returns the database's version.
If argument "Short" is true returns short variant, in other case returns whatever database handle/driver
returns. By default returns short version, e.g. '4.1.23' or '8.0-rc4'.
Returns empty string on error or if database couldn't return version.
The base implementation uses a "SELECT VERSION()"
CaseSensitive
Returns 1 if the current database's searches are case sensitive by default Returns undef otherwise
QuoteTableNames
Returns 1 if table names will be quoted in queries, otherwise 0
_MakeClauseCaseInsensitiveFIELDOPERATORVALUE
Takes a field, operator and value. performs the magic necessary to make your database treat this clause
as case insensitive.
Returns a FIELD OPERATOR VALUE triple.
Transactions
DBIx::SearchBuilder::Handle emulates nested transactions, by keeping a transaction stack depth.
NOTE: In nested transactions you shouldn't mix rollbacks and commits, because only last action really do
commit/rollback. For example next code would produce desired results:
$handle->BeginTransaction;
$handle->BeginTransaction;
...
$handle->Rollback;
$handle->BeginTransaction;
...
$handle->Commit;
$handle->Commit;
Only last action(Commit in example) finilize transaction in DB.
BeginTransaction
Tells DBIx::SearchBuilder to begin a new SQL transaction. This will temporarily suspend Autocommit mode.
EndTransaction[Action=>'commit'][Force=>0]
Tells to end the current transaction. Takes "Action" argument that could be "commit" or "rollback", the
default value is "commit".
If "Force" argument is true then all nested transactions would be committed or rolled back.
If there is no transaction in progress then method throw warning unless action is forced.
Method returns true on success or false if an error occurred.
Commit[FORCE]
Tells to commit the current SQL transaction.
Method uses "EndTransaction" method, read its description.
Rollback[FORCE]
Tells to abort the current SQL transaction.
Method uses "EndTransaction" method, read its description.
ForceRollback
Force the handle to rollback. Whether or not we're deep in nested transactions.
TransactionDepth
Returns the current depth of the nested transaction stack. Returns "undef" if there is no connection to
database.
ApplyLimitsSTATEMENTREFROWS_PER_PAGEFIRST_ROW
takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW;
Join{Paramhash}
Takes a paramhash of everything Searchbuildler::Record does plus a parameter called 'SearchBuilder' that
contains a ref to a SearchBuilder object'.
This performs the join.
MayBeNull
Takes a "SearchBuilder" and "ALIAS" in a hash and resturns true if restrictions of the query allow NULLs
in a table joined with the ALIAS, otherwise returns false value which means that you can use normal join
instead of left for the aliased table.
Works only for queries have been built with "Join" in DBIx::SearchBuilder and "Limit" in
DBIx::SearchBuilder methods, for other cases return true value to avoid fault optimizations.
DistinctQuerySTATEMENTREF
takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
DistinctQueryAndCountSTATEMENTREF
takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set and the total
count of potential records.
DistinctCountSTATEMENTREF
takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
LogMESSAGE
Takes a single argument, a message to log.
Currently prints that message to STDERR
SimpleDateTimeFunctions
See "DateTimeFunction" for details on supported functions. This method is for implementers of custom DB
connectors.
Returns hash reference with (function name, sql template) pairs.
DateTimeFunction
Takes named arguments:
• Field - SQL expression date/time function should be applied to. Note that this argument is used as is
without any kind of quoting.
• Type - name of the function, see supported values below.
• Timezone - optional hash reference with From and To values, see "ConvertTimezoneFunction" for
details.
Returns SQL statement. Returns NULL if function is not supported.
Supportedfunctions
Type value in "DateTimeFunction" is case insesitive. Spaces, underscores and dashes are ignored. So 'date
time', 'DateTime' and 'date_time' are all synonyms. The following functions are supported:
• date time - as is, no conversion, except applying timezone conversion if it's provided.
• time - time only
• hourly - datetime prefix up to the hours, e.g. '2010-03-25 16'
• hour - hour, 0 - 23
• date - date only
• daily - synonym for date
• day of week - 0 - 6, 0 - Sunday
• day - day of month, 1 - 31
• day of month - synonym for day
• day of year - 1 - 366, support is database dependent
• month - 1 - 12
• monthly - year and month prefix, e.g. '2010-11'
• year - e.g. '2023'
• annually - synonym for year
• week of year - 0-53, presence of zero week, 1st week meaning and whether week starts on Monday or
Sunday heavily depends on database.
ConvertTimezoneFunction
Generates a function applied to Field argument that converts timezone. By default converts from UTC.
Examples:
# UTC => Moscow
$handle->ConvertTimezoneFunction( Field => '?', To => 'Europe/Moscow');
If there is problem with arguments or timezones are equal then Field returned without any function
applied. Field argument is not escaped in any way, it's your job.
Implementation is very database specific. To be portable convert from UTC or to UTC. Some databases have
internal storage for information about timezones that should be kept up to date. Read documentation for
your DB.
DateTimeIntervalFunction
Generates a function to calculate interval in seconds between two dates. Takes From and To arguments
which can be either scalar or a hash. Hash is processed with "CombineFunctionWithField" in
DBIx::SearchBuilder.
Arguments are not quoted or escaped in any way. It's caller's job.
NullsOrder
Sets order of NULLs when sorting columns when called with mode, but only if DB supports it. Modes:
• small
NULLs are smaller then anything else, so come first when order is ASC and last otherwise.
• large
NULLs are larger then anything else.
• first
NULLs are always first.
• last
NULLs are always last.
• default
Return back to DB's default behaviour.
When called without argument returns metadata required to generate SQL.
HasSupportForNullsOrder
Returns true value if DB supports adjusting NULLs order while sorting a column, for example "ORDER BY
Value ASC NULLS FIRST".
HasSupportForCombineSearchAndCount
Returns true value if DB supports to combine search and count in single query.
HasSupportForEmptyString
Returns true value if DB supports empty string.
QuoteName
Quote table or column name to avoid reserved word errors.
Returns same value passed unless over-ridden in database-specific subclass.
DequoteName
Undo the effects of QuoteName by removing quoting.
DESTROY
When we get rid of the Searchbuilder::Handle, we need to disconnect from the database
CastAsDecimalFIELD
Cast the given field as decimal.
E.g. on Pg, it's "CAST(Content AS DECIMAL)".
perl v5.38.2 2024-05-15 DBIx::SearchBuilder::Handle(3pm)