class PostgresqlWriter extends PdoWriter (View source)

Class PostgresqlWriter

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

__construct(AbstractDatabaseDriver $db)

Constructor.

Parameters

AbstractDatabaseDriver $db

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

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

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

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

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

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

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.

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

delete

Parameters

string $table
array $conditions

Return Value

boolean

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.

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.

AbstractWriter execute(string|Query $query)

execute

Parameters

string|Query $query

Return Value

AbstractWriter

AbstractDatabaseDriver getDriver()

Method to get property Db

Return Value

AbstractDatabaseDriver

AbstractWriter setDriver(AbstractDatabaseDriver $db)

Method to set property db

Parameters

AbstractDatabaseDriver $db

Return Value

AbstractWriter Return self to support chaining.

resource getCursor()

Method to get property Cursor

Return Value

resource

AbstractWriter setCursor(resource $cursor)

Method to set property cursor

Parameters

resource $cursor

Return Value

AbstractWriter Return self to support chaining.