class AbstractWriter (View source)

Class DatabaseWriter

Methods

insertOne(string $table, array|object $data, string $key = null)

Inserts a row into a table based on an object's properties.

boolean
updateOne(string $table, array|object $data, array $key, boolean $updateNulls = false)

Updates a row in a table based on an object's properties.

saveOne(string $table, array $data, string $key, boolean $updateNulls = false)

save

mixed
insertMultiple(string $table, array $dataSet, array $key = null)

insertMultiple

mixed
updateMultiple(string $table, array $dataSet, array $key, boolean $updateNulls = false)

updateMultiple

mixed
saveMultiple(string $table, array $dataSet, array $key, boolean $updateNulls = false)

saveMultiple

boolean
updateBatch(string $table, array $data, mixed $conditions = array())

Batch update some data.

boolean
delete(string $table, array $conditions = array())

delete

integer
countAffected()

Get the number of affected rows for the previous executed SQL statement.

string
insertId()

Method to get the auto-incremented value from the last INSERT statement.

execute(string|Query $query)

execute

getDriver()

Method to get property Db

setDriver(AbstractDatabaseDriver $db)

Method to set property db

resource
getCursor()

Method to get property Cursor

setCursor(resource $cursor)

Method to set property cursor

Details

at line line 41
__construct(AbstractDatabaseDriver $db)

Constructor.

Parameters

AbstractDatabaseDriver $db

at line line 58
AbstractWriter insertOne(string $table, array|object $data, string $key = null)

Inserts a row into a table based on an object's properties.

Parameters

string $table The name of the database table to insert into.
array|object $data &$data A reference to an object whose public properties match the table fields.
string $key The name of the primary key. If provided the object property is updated.

Return Value

AbstractWriter

Exceptions

InvalidArgumentException

at line line 150
boolean updateOne(string $table, array|object $data, array $key, boolean $updateNulls = false)

Updates a row in a table based on an object's properties.

Parameters

string $table The name of the database table to update.
array|object $data A reference to an object whose public properties match the table fields.
array $key The name of the primary key.
boolean $updateNulls True to update null fields or false to ignore them.

Return Value

boolean True on success.

Exceptions

InvalidArgumentException

at line line 242
bool|AbstractWriter saveOne(string $table, array $data, string $key, boolean $updateNulls = false)

save

Parameters

string $table The name of the database table to update.
array $data &$data A reference to an object whose public properties match the table fields.
string $key The name of the primary key.
boolean $updateNulls True to update null fields or false to ignore them.

Return Value

bool|AbstractWriter

Exceptions

InvalidArgumentException

at line line 276
mixed insertMultiple(string $table, array $dataSet, array $key = null)

insertMultiple

Parameters

string $table The name of the database table to update.
array $dataSet &$dataSet A reference to an object whose public properties match the table fields.
array $key The name of the primary key.

Return Value

mixed

Exceptions

InvalidArgumentException

at line line 302
mixed updateMultiple(string $table, array $dataSet, array $key, boolean $updateNulls = false)

updateMultiple

Parameters

string $table The name of the database table to update.
array $dataSet A reference to an object whose public properties match the table fields.
array $key The name of the primary key.
boolean $updateNulls True to update null fields or false to ignore them.

Return Value

mixed

Exceptions

InvalidArgumentException

at line line 328
mixed saveMultiple(string $table, array $dataSet, array $key, boolean $updateNulls = false)

saveMultiple

Parameters

string $table The name of the database table to update.
array $dataSet A reference to an object whose public properties match the table fields.
array $key The name of the primary key.
boolean $updateNulls True to update null fields or false to ignore them.

Return Value

mixed

Exceptions

InvalidArgumentException

at line line 356
boolean updateBatch(string $table, array $data, mixed $conditions = array())

Batch update some data.

Parameters

string $table Table name.
array $data Data you want to update.
mixed $conditions Where conditions, you can use array or Compare object. Example: - array('id' => 5) => id = 5 - new GteCompare('id', 20) => 'id >= 20' - new Compare('id', '%Flower%', 'LIKE') => 'id LIKE "%Flower%"'

Return Value

boolean True if update success.

at line line 400
boolean delete(string $table, array $conditions = array())

delete

Parameters

string $table
array $conditions

Return Value

boolean

at line line 422
integer countAffected()

Get the number of affected rows for the previous executed SQL statement.

Only applicable for DELETE, INSERT, or UPDATE statements.

Return Value

integer The number of affected rows.

at line line 435
string insertId()

Method to get the auto-incremented value from the last INSERT statement.

Return Value

string The value of the auto-increment field from the last inserted row.

at line line 447
AbstractWriter execute(string|Query $query)

execute

Parameters

string|Query $query

Return Value

AbstractWriter

at line line 461
AbstractDatabaseDriver getDriver()

Method to get property Db

Return Value

AbstractDatabaseDriver

at line line 473
AbstractWriter setDriver(AbstractDatabaseDriver $db)

Method to set property db

Parameters

AbstractDatabaseDriver $db

Return Value

AbstractWriter Return self to support chaining.

at line line 485
resource getCursor()

Method to get property Cursor

Return Value

resource

at line line 497
AbstractWriter setCursor(resource $cursor)

Method to set property cursor

Parameters

resource $cursor

Return Value

AbstractWriter Return self to support chaining.