Andrew's Web Libraries (AWL)
Loading...
Searching...
No Matches
AwlQuery Class Reference

Public Member Functions

 __construct ()
 
 SetConnection ( $new_connection, $options=null)
 
 GetConnection ()
 
 _log_query ( $locn, $tag, $string, $line=0, $file="")
 
 Bind ()
 
 Prepare ()
 
 Execute ()
 
 QueryString ()
 
 Parameters ()
 
 rows ()
 
 rownum ()
 
 TransactionState ()
 
 Begin ()
 
 Commit ()
 
 Rollback ()
 
 SetSql ( $sql)
 
 QDo ()
 
 Exec ( $location=null, $line=null, $file=null)
 
 Fetch ($as_array=false)
 
 getErrorInfo ()
 
 SetSlowQueryThreshold ( $new_threshold)
 

Static Public Member Functions

static quote ($str=null)
 

Public Attributes

 $location
 
 $location_line
 
 $location_file
 
 $query_time_warning = 5
 

Protected Attributes

 $connection
 
 $querystring
 
 $bound_querystring
 
 $bound_parameters
 
 $sth
 
 $result
 
 $rownum = null
 
 $rows
 
 $error_info
 
 $execution_time
 

Detailed Description

Definition at line 117 of file AwlQuery.php.

Constructor & Destructor Documentation

◆ __construct()

AwlQuery::__construct ( )

#- Constructor

Parameters
stringThe query string in PDO syntax with replacable '?' characters or bindable parameters.
mixedThe values to replace into the SQL string.
Returns
The AwlQuery object

Definition at line 215 of file AwlQuery.php.

Member Function Documentation

◆ _log_query()

AwlQuery::_log_query (   $locn,
  $tag,
  $string,
  $line = 0,
  $file = "" 
)

Log query, optionally with file and line location of the caller.

This function should not really be used outside of AwlQuery. For a more useful generic logging interface consider calling dbg_error_log(...);

Parameters
string$locnA string identifying the calling location.
string$tagA tag string, e.g. identifying the type of event.
string$stringThe information to be logged.
int$lineThe line number where the logged event occurred.
string$fileThe file name where the logged event occurred.

Definition at line 296 of file AwlQuery.php.

◆ Begin()

AwlQuery::Begin ( )

Wrap the parent DB class Begin() so we can $qry->Begin() sometime before we $qry->Exec()

Definition at line 474 of file AwlQuery.php.

◆ Bind()

AwlQuery::Bind ( )

Bind some parameters. This can be called in three ways: 1) As Bind(':key','value), when using named parameters 2) As Bind('value'), when using ? placeholders 3) As Bind(array()), to overwrite the existing bound parameters. The array may be ':name' => 'value' pairs or ordinal values, depending on whether the SQL is using ':name' or '?' style placeholders.

Parameters
mixed$argsSee details above.

Definition at line 337 of file AwlQuery.php.

◆ Commit()

AwlQuery::Commit ( )

Wrap the parent DB class Commit() so we can $qry->Commit() sometime after we $qry->Exec()

Definition at line 487 of file AwlQuery.php.

◆ Exec()

AwlQuery::Exec (   $location = null,
  $line = null,
  $file = null 
)

Execute the query, logging any debugging.

Example So that you can nicely enable/disable the queries for a particular class, you could use some of PHPs magic constants in your call. $qry->Exec(CLASS, LINE, FILE);

Parameters
string$locationThe name of the location for enabling debugging or just to help our children find the source of a problem.
int$lineThe line number where Exec was called
string$fileThe file where Exec was called
Returns
boolean Success (true) or Failure (false)

Definition at line 563 of file AwlQuery.php.

◆ Execute()

AwlQuery::Execute ( )

Tell the database to execute the query

Definition at line 380 of file AwlQuery.php.

◆ Fetch()

AwlQuery::Fetch (   $as_array = false)

Fetch the next row from the query results

Parameters
boolean$as_arrayTrue if thing to be returned is array
Returns
mixed query row

Definition at line 629 of file AwlQuery.php.

◆ GetConnection()

AwlQuery::GetConnection ( )

Get the current database connection for this query

Definition at line 279 of file AwlQuery.php.

◆ getErrorInfo()

AwlQuery::getErrorInfo ( )

Get any error information from the last query

Definition at line 645 of file AwlQuery.php.

◆ Parameters()

AwlQuery::Parameters ( )

Return the parameters we are planning to substitute into the query string

Definition at line 435 of file AwlQuery.php.

◆ Prepare()

AwlQuery::Prepare ( )

Tell the database to prepare the query that we will execute

Definition at line 358 of file AwlQuery.php.

◆ QDo()

AwlQuery::QDo ( )

Simple QDo() class which will re-use this query for whatever was passed in, and execute it returning the result of the Exec() call. We can't call it Do() since that's a reserved word...

Parameters
stringThe query string in PDO syntax with replacable '?' characters or bindable parameters.
mixedThe values to replace into the SQL string.
Returns
boolean Success (true) or Failure (false)

Definition at line 530 of file AwlQuery.php.

◆ QueryString()

AwlQuery::QueryString ( )

Return the query string we are planning to execute

Definition at line 427 of file AwlQuery.php.

◆ quote()

static AwlQuery::quote (   $str = null)
static

Quote the given string so it can be safely used within string delimiters in a query. To be avoided, in general.

Parameters
mixed$strData to be converted to a string suitable for including as a value in SQL.
Returns
string NULL, TRUE, FALSE, a plain number, or the original string quoted and with ' and \ characters escaped

Definition at line 318 of file AwlQuery.php.

◆ Rollback()

AwlQuery::Rollback ( )

Wrap the parent DB class Rollback() so we can $qry->Rollback() sometime after we $qry->Exec()

Definition at line 498 of file AwlQuery.php.

◆ rownum()

AwlQuery::rownum ( )

Return the current rownum in the retrieved set

Definition at line 451 of file AwlQuery.php.

◆ rows()

AwlQuery::rows ( )

Return the count of rows retrieved/affected

Definition at line 443 of file AwlQuery.php.

◆ SetConnection()

AwlQuery::SetConnection (   $new_connection,
  $options = null 
)

Use a different database connection for this query

Parameters
resource$new_connectionThe database connection to use.

Definition at line 248 of file AwlQuery.php.

◆ SetSlowQueryThreshold()

AwlQuery::SetSlowQueryThreshold (   $new_threshold)

Set the slow query threshold for this query (and subsequent queries using this object). The overall default is $c->slow_query_threshold, or 5 seconds if that is not set.

Parameters
double$new_thresholdThe new threshold for slow queries to be logged
Returns
double The old threshold.

Definition at line 656 of file AwlQuery.php.

◆ SetSql()

AwlQuery::SetSql (   $sql)

Simple SetSql() class which will reset the object with the querystring from the first argument.

Parameters
stringThe query string in PDO syntax with replacable '?' characters or bindable parameters.

Definition at line 510 of file AwlQuery.php.

◆ TransactionState()

AwlQuery::TransactionState ( )

Returns the current state of a transaction, indicating if we have begun a transaction, whether the transaction has failed, or if we are not in a transaction.

Returns
int 0 = not started, 1 = in progress, -1 = error pending rollback/commit

Definition at line 461 of file AwlQuery.php.

Member Data Documentation

◆ $bound_parameters

AwlQuery::$bound_parameters
protected

Definition at line 144 of file AwlQuery.php.

◆ $bound_querystring

AwlQuery::$bound_querystring
protected

Definition at line 138 of file AwlQuery.php.

◆ $connection

AwlQuery::$connection
protected

Definition at line 126 of file AwlQuery.php.

◆ $error_info

AwlQuery::$error_info
protected

Definition at line 174 of file AwlQuery.php.

◆ $execution_time

AwlQuery::$execution_time
protected

Definition at line 181 of file AwlQuery.php.

◆ $location

AwlQuery::$location

Definition at line 193 of file AwlQuery.php.

◆ $location_file

AwlQuery::$location_file

Definition at line 195 of file AwlQuery.php.

◆ $location_line

AwlQuery::$location_line

Definition at line 194 of file AwlQuery.php.

◆ $query_time_warning

AwlQuery::$query_time_warning = 5

Definition at line 205 of file AwlQuery.php.

◆ $querystring

AwlQuery::$querystring
protected

Definition at line 132 of file AwlQuery.php.

◆ $result

AwlQuery::$result
protected

Definition at line 156 of file AwlQuery.php.

◆ $rownum

AwlQuery::$rownum = null
protected

Definition at line 162 of file AwlQuery.php.

◆ $rows

AwlQuery::$rows
protected

Definition at line 168 of file AwlQuery.php.

◆ $sth

AwlQuery::$sth
protected

Definition at line 150 of file AwlQuery.php.


The documentation for this class was generated from the following file: