Transactd PHP ORM 1.5.0
  • Namespace
  • Class

Namespaces

  • None
  • Transactd
    • boot
      • Laravel

Classes

  • AggregateFunction
  • CachedQueryExecuter
  • Collection
  • CollectionIterator
  • DatabaseManager
  • Model
  • QueryAdapter
  • QueryExecuter
  • Relation
  • TableForwordIterator
  • TableIterator
  • TableReverseIterator

Traits

  • JsonSerializable

Exceptions

  • IOException
  • ModelNotFoundException
  • ModelUserCancelException

Class QueryExecuter

Direct known subclasses

Transactd\CachedQueryExecuter

Namespace: Transactd
Located at QueryExecuter.php

Methods summary

public
# setEvent( string $name, string $class )

Set a event function of CUD and save operations.

Set a event function of CUD and save operations.

Parameters

$name

The event name.
('creating', 'created')
('updating', 'updated')
('saving', 'saved')
('deleting', 'deleted')

$class
A static function class name of event handler.
public Transactd\QueryExecuter
# reset( )

Reset the execute paramators.

Reset the execute paramators.

Returns

Transactd\QueryExecuter
protected BizStation\Transactd\Recordset
# setFetchClass( BizStation\Transactd\Recordset $rs )

Parameters

$rs

Returns

BizStation\Transactd\Recordset
protected int[]
# primaryKeyFields( )

Get the array of primary key field number.

Get the array of primary key field number.

Returns

int[]
public integer
# primarykey( )

Get the primary key number.

Get the primary key number.

Returns

integer
public string[]
# primaryKeyFieldNames( )

Get the array of primary key field name.

Get the array of primary key field name.

Returns

string[]
public string[]
# keyFieldNames( integer $index )

Get the array of key field name of specified index.

Get the array of key field name of specified index.

Parameters

$index
The key number

Returns

string[]
public boolean
# isSeekHasMany( integer $index, integer $segments )

Returns whether multiple records search from the specified parameters.

Returns whether multiple records search from the specified parameters.

Parameters

$index
The key number.
$segments
The number of segments to be used.

Returns

boolean
public BizStation\Transactd\Table
# table( )

Get the writable internal table Object.

Get the writable internal table Object.

Returns

BizStation\Transactd\Table
public BizStation\Transactd\ActiveTable
# activeTable( )

Get the internal ActiveTable Object.

Get the internal ActiveTable Object.

Returns

BizStation\Transactd\ActiveTable
public BizStation\Transactd\Table
# getWritableTable( )

Get the writable internal table Object.

Get the writable internal table Object.

Returns

BizStation\Transactd\Table
public BizStation\Transactd\Table
# getReadbleTable( )

Get the read-only internal table Object.

Get the read-only internal table Object.

Returns

BizStation\Transactd\Table
public
# __construct( string $tableName, BizStation\Transactd\PooledDbManager|BizStation\Transactd\database $dbm, BizStation\Transactd\PooledDbManager|BizStation\Transactd\database $dbs, string $className = 'stdClass' )

Parameters

$tableName
$dbm
Master database.
$dbs
Slave database.
$className
(optional) A class name of result.

Throws

Transactd\IOException
protected
# copyKeyValues( BizStation\Transactd\Table $tb, BizStation\Transactd\Table $src )

Parameters

$tb
$src
protected
# setKeyValues( mixed|mixed[] $id, BizStation\Transactd\Table $tb )

Set key values to current key fields

Set key values to current key fields

Parameters

$id
$tb
public integer
# getIndexByFieldNames( string|string[] $fieldNames, boolean $notUniqueAble = false, boolean $ignoreCount = false )

Parameters

$fieldNames
$notUniqueAble
$ignoreCount

Returns

integer

Throws

UnexpectedValueException
public
# setTimeStampMode( boolean $v )

Set timestamp mode to wriatble internal table.

Set timestamp mode to wriatble internal table.

Parameters

$v
public
# setAliases( array $aliases )

Set field name aliases

Set field name aliases

Parameters

$aliases
[['original' => 'alias'], ...]
public Transactd\QueryExecuter
# index( integer $index )

Set the index number for search.

Set the index number for search.

Parameters

$index

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# indexToPrimaryKey( )

Change the index number to the primary key.

Change the index number to the primary key.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# keyValue( mixed $v1, mixed $v2 = null, mixed $v3 = null, mixed $v4 = null, mixed $v5 = null, mixed $v6 = null, mixed $v7 = null, mixed $v8 = null )

Set key value(s) of current key.

Set key value(s) of current key.

Parameters

$v1
First segment value.
$v2
(optional) Second segment value.
$v3
(optional) Third segment value.
$v4
(optional) Fourth segment value.
$v5
(optional) Fifth segment value.
$v6
(optional) Sixth segment value.
$v7
(optional) Seventh segment value.
$v8
(optional) Eighth segment value.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# updateConflictCheck( boolean $v )

Whether or not to enable updateConflictCheck.

Whether or not to enable updateConflictCheck.

Parameters

$v

Returns

Transactd\QueryExecuter

Throws

RuntimeException
public boolean
# chunk( integer $n, callable $func )

Search results the registration of the chunk.

Search results the registration of the chunk.

Parameters

$n
Count of a chunk.
$func
Handler function name.

Returns

boolean
public Transactd\Collection|BizStation\Transactd\Recordset
# read( boolean $toArray = true )

Execute the contents of the queue in the order. And returns the result.

Execute the contents of the queue in the order. And returns the result.

Parameters

$toArray
(optional) false: Get by recordset.

Returns

Transactd\Collection|BizStation\Transactd\Recordset

Throw

IOException
public Transactd\Collection
# arrayToCollection( array $ar, Transactd\Relation $rel = null, object $parent = null )

Create a collection from a result array.

Create a collection from a result array.

Parameters

$ar
A array of result.
$rel
(optinal) Relation object of result.
$parent
(optinal) A parent object of relation.

Returns

Transactd\Collection
public Transactd\Collection|BizStation\Transactd\Recordset
# get( boolean $toArray = true )

The alias of this::read().

The alias of this::read().

Parameters

$toArray
(optional) false: Get by recordset.

Returns

Transactd\Collection|BizStation\Transactd\Recordset

Throw

IOException
public Transactd\Collection
# outerJoin( Transactd\QueryExecuter|Transactd\Recordset $qOrRs, string|string[]|RecordsetQuery $keyNmaesOrRecordsetQuery )

Add the outer-join in the execution queue.

Add the outer-join in the execution queue.

Table outer-join : Specify QueryExecuter and keyNmaes. Recordset outer-join : Specify Recordset and RecordsetQuery.

Parameters

$qOrRs
QueryExecuter or \Transactd\Recordset
$keyNmaesOrRecordsetQuery
Key names of this table or RecordsetQuery.

Returns

Transactd\Collection
public Transactd\Collection
# join( Transactd\QueryExecuter|Transactd\Recordset $qOrRs, string|string[]|RecordsetQuery $keyNmaesOrRecordsetQuery )

Add the inner-join in the execution queue. Table inner-join : Specify QueryExecuter and keyNmaes. Recordset inner-join : Specify Recordset and RecordsetQuery.

Add the inner-join in the execution queue. Table inner-join : Specify QueryExecuter and keyNmaes. Recordset inner-join : Specify Recordset and RecordsetQuery.

Parameters

$qOrRs
QueryExecuter or \Transactd\Recordset
$keyNmaesOrRecordsetQuery
Key names of this table or RecordsetQuery.

Returns

Transactd\Collection
public Transactd\QueryExecuter
# groupBy( BizStation\Transactd\GroupQuery $gq )

Add the grouping query in the execution queue.

Add the grouping query in the execution queue.

Parameters

$gq

Returns

Transactd\QueryExecuter

Throws

InvalidArgumentException
public Transactd\QueryExecuter
# orderBy( string $name, boolean $asc )

Add the sort-ordering query in the execution queue.

Add the sort-ordering query in the execution queue.

Parameters

$name
A name of sort-target field name
$asc
Specifies whether the ascending order.

Returns

Transactd\QueryExecuter

Throws

InvalidArgumentException
public Transactd\QueryExecuter
# matchBy( BizStation\Transactd\RecordsetQuery $rq )

Add the filter(match-by) query in the execution queue.

Add the filter(match-by) query in the execution queue.

Parameters

$rq

Returns

Transactd\QueryExecuter
public BizStation\Transactd\Recordset
# recordset( )

Execute the contents of the queue in the order. And returns the BizStation\Transactd\Recordset result.

Execute the contents of the queue in the order. And returns the BizStation\Transactd\Recordset result.

Returns

BizStation\Transactd\Recordset
public Transactd\QueryExecuter
# union( BizStation\Transactd\Recordset $rs )

Set the union data.

Set the union data.

Parameters

$rs
A source data of recordset.

Returns

Transactd\QueryExecuter

Throws

InvalidArgumentException
public Transactd\QueryExecuter
# with( string $func )

Parameters

$func

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# removeNullRecord( )

Add the remove null operation in the execution queue.

Add the remove null operation in the execution queue.

Returns

Transactd\QueryExecuter
public Transactd\Collection|BizStation\Transactd\Recordset
# all( boolean $toArray = true )

Reads all records from a table by the primary key.

Reads all records from a table by the primary key.

Parameters

$toArray
(optional) false: Get by recordset.

Returns

Transactd\Collection|BizStation\Transactd\Recordset
public object|null
# find( mixed|mixed[] $id, boolean $throwException = false )

Find a record from the table by the current key.

Find a record from the table by the current key.

Parameters

$id
The primary key values.
$throwException
Whether to return an error when an exception.

Returns

object|null

Throws

Transactd\ModelNotFoundException
public Transactd\Collection
# findMany( array $keyValuesArray )

Find multiple records by the current key values.

Find multiple records by the current key values.

Parameters

$keyValuesArray
A araay of the current key values. Ex:[1, 2] or [[1,1],[1,2]]

Returns

Transactd\Collection

Throws

InvalidArgumentException
public object
# first( boolean $throwException = false )

Find a first record by the current conditions.

Find a first record by the current conditions.

Parameters

$throwException
Whether throw an exception that could not be found.

Returns

object

Throws

Transactd\ModelNotFoundException
public Generator
# cursor( )

Get a genaretor of the current query. Please set Index keyValue and query conditions beforehand.

Get a genaretor of the current query. Please set Index keyValue and query conditions beforehand.

Returns

Generator
public static Transactd\TableIterator
# getIterator( type $tb, type $op = 0, $lockBias = Transactd\Transactd::LOCK_BIAS_DEFAULT, $forword = true )

Read a record with the $op and return a iteraor. Please set key number and key value beforehand.

Read a record with the $op and return a iteraor. Please set key number and key value beforehand.

Parameters

$tb
$op
$op
$lockBias SEEK_EQUAL(0) to SEEK_LESSTHAN(6)
$lockBias
$forword

Returns

Transactd\TableIterator

Throws

InvalidArgumentException
public BizStation\Transactd\TableIterator
# serverCursor( integer $op = self::SEEK_EQUAL, integer $lockBias = Transactd\Transactd::LOCK_BIAS_DEFAULT, boolean $forword = true )

Read a record with the $op and return a writable iteraor. Please set Index and keyValue beforehand. And finally call reset() to restore index and keyValue.

Read a record with the $op and return a writable iteraor. Please set Index and keyValue beforehand. And finally call reset() to restore index and keyValue.

Parameters

$op
Table::SEEK_EQUAL to Table::SEEK_LESSTHAN
$lockBias
$forword
Choicing ForwordIterator or ReverseIterator.

Returns

BizStation\Transactd\TableIterator

Throw

IOException
public object
# create( array $attributes, type $nosave = false )

Create(insert) a new object specified by the property of fetchClass.

Create(insert) a new object specified by the property of fetchClass.

Parameters

$attributes
The initial value of the attribute.
$nosave

Whether at the same time it stored in the database?
- true Do not save. - false Do save.

  • true : Do not save
  • false : Do save

Returns

object

Throws

Transactd\IOException
public object
# firstOrCreate( array $attributes )

Find or create(insert) a object specified by attribute.

Find or create(insert) a object specified by attribute.

Parameters

$attributes
The initial value of the attribute.

Returns

object

Throws

Transactd\IOException
public object
# firstOrNew( array $attributes )

Find or instantiate a object specified by attribute.

Find or instantiate a object specified by attribute.

Parameters

$attributes
The initial value of the attribute.

Returns

object

Throws

Transactd\IOException
protected object[]
# doUpdate( array $attributes )

Parameters

$attributes
The update value of attributes.

Returns

object[]

Throws

Transactd\IOException
protected object[]
# doDelete( )

Returns

object[]

Throws

Transactd\IOException
public integer
# update( array $attributes )

Update records selected by current conditions by the attributes. If no conditions specified updates current key values. If conditions specified the updateConflictCheck dose not works.

Update records selected by current conditions by the attributes. If no conditions specified updates current key values. If conditions specified the updateConflictCheck dose not works.

Parameters

$attributes

The update value of attributes. Do not specify the current key field.

Returns

integer
Count of effects.

Throws

Transactd\IOException
public integer
# delete( )

Delete records selected by current conditions. If no conditions specified deletes current key values. If conditions specified the updateConflictCheck dose not works.

Delete records selected by current conditions. If no conditions specified deletes current key values. If conditions specified the updateConflictCheck dose not works.

Returns

integer
Count of effects.

Throws

Transactd\IOException
protected
# doDestroy( $ids )

No error is thrown if id is not found, IOException is thrown if other errors.

No error is thrown if id is not found, IOException is thrown if other errors.

public integer
# destroy( integer|string|(int|string)[] $ids )

Parameters

$ids

Returns

integer
public boolean
# deleteObject( object $obj )

Parameters

$obj

Returns

boolean

Throws

Transactd\IOException
public boolean
# save( object $obj, boolean $forceInsert = false )

Parameters

$obj
$forceInsert

Returns

boolean

Throws

Transactd\IOException
public object
# insert( array $attributes )

Insert a record.

Insert a record.

Parameters

$attributes
The initial value of the attribute.

Returns

object

Throws

Transactd\IOException
public integer
# deleteMany( array $values, function $func = null )

Delete records by current index's values. NOTE: The current record is changed by this operation.

Delete records by current index's values. NOTE: The current record is changed by this operation.

Parameters

$values
$func
onDeleted event function func($obj)

Returns

integer
Number of deleted object.
public string
# getUniqueKey( object $obj )

Get a key string from primary key field value of the object.

Get a key string from primary key field value of the object.

Parameters

$obj

Returns

string
public
# __call( $name, $arguments )
public Transactd\QueryExecuter
# when( boolean $condition, type $func )

Execute the closure that has been specified by the condition.

Execute the closure that has been specified by the condition.

Parameters

$condition
$func
The closure.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# where( string $name, string|mixed $operator = null, mixed $value = null )

Parameters

$name
A field name.
$operator
Operator or a value.
$value
(optional) a value

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# orWhere( string $name, string $operator = null, mixed $value = null )

Parameters

$name
A field name.
$operator
Operator or a value.
$value
a value

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereNull( string $name )

Parameters

$name
A field name.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# orNull( string $name )

Parameters

$name
A field name.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereNotNull( string $name )

Parameters

$name
A field name.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# orNotNull( string $name )

Parameters

$name
A field name.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereInKey( @param $values, @param $segments = null )

Parameters

$values
$values Key values
$segments
$segments The segment count of values.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereIn( string $name, array $values )

Parameters

$name
A field name.
$values
Key values.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereNotIn( string $name, mixed $values )

Parameters

$name
A field name.
$values
Key values.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereBetween( string $name, mixed[2] $valuePair )

Parameters

$name
A field name.
$valuePair
A pair of first value and end value.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereNotBetween( string $name, mixed[2] $valuePair )

Parameters

$name
A field name.
$valuePair
A pair of first value and end value.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# whereColumn( string $name, string|mixed $operator = null, mixed $value = null )

Parameters

$name
A field name.
$operator
Operator or a value.
$value
(optional) a value

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# orColumn( string $name, string|mixed $operator = null, mixed $value = null )

Parameters

$name
A field name.
$operator
Operator or a value.
$value
(optional) a value

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# select( string|string[] $name1, string $name2 = null, string $name3 = null, string $name4 = null, string $name5 = null, string $name6 = null, string $name7 = null, string $name8 = null )

Parameters

$name1
A field name.
$name2
(optional) A field name.
$name3
(optional) A field name.
$name4
(optional) A field name.
$name5
(optional) A field name.
$name6
(optional) A field name.
$name7
(optional) A field name.
$name8
(optional) A field name.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# addSelect( string $name )

Parameters

$name
A field name.

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# reject( integer $v )

Parameters

$v

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# noBreakReject( )

Alias of reject(0xffff)

Alias of reject(0xffff)

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# skip( integer $n )

Parameters

$n

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# take( integer $n )

Parameters

$n

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# limit( integer $n )

Alias to the take

Alias to the take

Parameters

$n

Returns

Transactd\QueryExecuter
public Transactd\QueryExecuter
# direction( integer $v )

Parameters

$v
Nstable::findForword| Nstable::findBackForword

Returns

Transactd\QueryExecuter
public string
# queryString( )

Get a description of the query.

Get a description of the query.

Returns

string
public string
# queryDescription( BizStation\Transactd\Query $q = null )

Get a description of the key values and query.

Get a description of the key values and query.

Parameters

$q

Returns

string
public integer
# count( )

Get the record count.

Get the record count.

Returns

integer
public float
# sum( string $column )

Calculate the total value of the specified column.

Calculate the total value of the specified column.

Parameters

$column

Returns

float
public float
# min( string $column )

Find the minimum value of the specified column.

Find the minimum value of the specified column.

Parameters

$column

Returns

float
public float
# max( string $column )

Find the maximum value of the specified column.

Find the maximum value of the specified column.

Parameters

$column

Returns

float
public float
# avg( string $column )

Calculate the average value of the specified column.

Calculate the average value of the specified column.

Parameters

$column

Returns

float
public float
# average( string $column )

The alias name of the avg function .

The alias name of the avg function .

Parameters

$column

Returns

float

Constants summary

integer SEEK_FIRST
# 0
integer SEEK_LAST
# 1
integer SEEK_EQUAL
# 2
integer SEEK_GREATER_OREQUAL
# 3
integer SEEK_GREATER
# 4
integer SEEK_LESSTHAN_OREQUAL
# 5
integer SEEK_LESSTHAN
# 6

Properties summary

protected $at
#
protected $tb
# null
protected $tbr
# null
protected $q
#
protected $dbm
# null
protected array $primaryKeyFieldNames
# array()
protected array $keyFieldNameCache
# array()
protected array $keyFieldCache
# array()
protected integer $primaryKey
# 0
protected array $with
# array()
protected $obj
#
protected boolean $spcoll
# false
protected $creating
# null
protected $created
# null
protected $updating
# null
protected $updated
# null
protected $saving
# null
protected $saved
# null
protected $deleting
# null
protected $deleted
# null
Transactd PHP ORM 1.5.0 API documentation generated by ApiGen