Managing Connections
- protected function getConnectionNamespace() — Return a namespace for this object's connections in the connection cache. Generally, the database name is appropriate. Two connections are considered equivalent if they have the same connection namespace and mode.
- protected function getEstablishedConnection($mode) — Get an existing, cached connection for this object.
- protected function setEstablishedConnection($mode, $connection, $force_unique) — Store a connection in the connection cache.
- public function setForcedConnection($connection) — Force an object to use a specific connection.
Configuring Storage
- protected function establishLiveConnection($mode)
- protected function getConfiguration()
- public function getConfigOption($option_name) — Determine the setting of a configuration option for this class of objects.
- public function getTableName()
- public static function pushStorageNamespace($namespace)
- public static function popStorageNamespace()
- public static function getDefaultStorageNamespace()
- public static function getStorageNamespace()
- public function getApplicationName()
Loading Objects
- public function load($id) — Load an object by ID. You need to invoke this as an instance method, not a class method, because PHP doesn't have late static binding (until PHP 5.3.0). For example:
- public function loadAll() — Loads all of the objects, unconditionally.
- public function loadAllWhere($pattern, ...) — Load all objects which match a WHERE clause. You provide everything after the 'WHERE'; Lisk handles everything up to it. For example:
- public function loadOneWhere($pattern, ...) — Load a single object identified by a 'WHERE' clause. You provide everything after the 'WHERE', and Lisk builds the first half of the query. See loadAllWhere(). This method is similar, but returns a single result instead of a list.
- public function reload() — Reload an object from the database, discarding any changes to persistent properties. This is primarily useful after entering a transaction but before applying changes to an object.
- public function loadFromArray($row) — Initialize this object's properties from a dictionary. Generally, you load single objects with loadOneWhere(), but sometimes it may be more convenient to pull data from elsewhere directly (e.g., a complicated join via @{method:queryData}) and then load from an array representation.
- public function loadAllFromArray($rows) — Initialize a list of objects from a list of dictionaries. Usually you load lists of objects with @{method:loadAllWhere}, but sometimes that isn't flexible enough. One case is if you need to do joins to select the right objects:
Examining Objects
- public function getID() — Retrieve the unique ID identifying this object. This value will be null if the object hasn't been persisted and you didn't set it manually.
- public function hasProperty($property) — Test if a property exists.
- protected function getAllLiskProperties() — Retrieve a list of all object properties. This list only includes properties that are declared as protected, and it is expected that all properties returned by this function should be persisted to the database. Properties that should not be persisted must be declared as private.
- protected function checkProperty($property) — Check if a property exists on this object.
- public function establishConnection($mode, $force_new) — Get or build the database connection for this object.
- protected function getAllLiskPropertyValues() — Convert this object into a property dictionary. This dictionary can be restored into an object by using @{method:loadFromArray} (unless you're using legacy features with CONFIG_CONVERT_CAMELCASE, but in that case you should just go ahead and die in a fire).
Writing Objects
- public function setID($id) — Set unique ID identifying this object. You normally don't need to call this method unless with `IDS_MANUAL`.
- public function save() — Persist this object to the database. In most cases, this is the only method you need to call to do writes. If the object has not yet been inserted this will do an insert; if it has, it will do an update.
- public function replace() — Save this object, forcing the query to use REPLACE regardless of object state.
- public function insert() — Save this object, forcing the query to use INSERT regardless of object state.
- public function update() — Save this object, forcing the query to use UPDATE regardless of object state.
- public function delete() — Delete this object, permanently.
- protected function insertRecordIntoDatabase($mode) — Internal implementation of INSERT and REPLACE.
Hooks and Callbacks
- public function getIDKey() — Retrieve the primary key column, "id" by default. If you can not reasonably name your ID column "id", override this method.
- public function generatePHID()
- protected function willWriteData(&$data)
- protected function didWriteData() — Hook to perform actions after data has been written to the database.
- protected function willSaveObject() — Hook to make internal object state changes prior to INSERT, REPLACE or UPDATE.
- protected function willReadData(&$data)
- protected function didReadData() — Hook to perform an action on data after it is read from the database.
- protected function willDelete() — Hook to perform an action before the deletion of an object.
- protected function didDelete() — Hook to perform an action after the deletion of an object.
- protected function readField($field) — Reads the value from a field. Override this method for custom behavior of @{method:getField} instead of overriding getField directly.
- protected function writeField($field, $value) — Writes a value to a field. Override this method for custom behavior of setField($value) instead of overriding setField directly.
Utilities
- protected function applyLiskDataSerialization(&$data, $deserialize) — Applies configured serialization to a dictionary of values.
- public function __call($method, $args) — Black magic. Builds implied get*() and set*() for all properties.
- public function __set($name, $value) — Warns against writing to undeclared property.
- public static function loadNextCounterValue($conn_w, $counter_name) — Increments a named counter and returns the next value.
- public static function loadCurrentCounterValue($conn_r, $counter_name) — Returns the current value of a named counter.
- public static function overwriteCounterValue($conn_w, $counter_name, $counter_value) — Overwrite a named counter, forcing it to a specific value.
Managing Transactions
- public function beginReadLocking() — Begins read-locking selected rows with SELECT ... FOR UPDATE, so that other connections can not read them (this is an enormous oversimplification of FOR UPDATE semantics; consult the MySQL documentation for details). To end read locking, call @{method:endReadLocking}. For example:
- public function endReadLocking() — Ends read-locking that began at an earlier @{method:beginReadLocking} call.
- public function beginWriteLocking() — Begins write-locking selected rows with SELECT ... LOCK IN SHARE MODE, so that other connections can not update or delete them (this is an oversimplification of LOCK IN SHARE MODE semantics; consult the MySQL documentation for details). To end write locking, call @{method:endWriteLocking}.
- public function endWriteLocking() — Ends write-locking that began at an earlier @{method:beginWriteLocking} call.
Isolation for Unit Testing
- public static function beginIsolateAllLiskEffectsToCurrentProcess()
- public static function endIsolateAllLiskEffectsToCurrentProcess()
- public static function shouldIsolateAllLiskEffectsToCurrentProcess()
- private function establishIsolatedConnection($mode)
- public static function beginIsolateAllLiskEffectsToTransactions()
- public static function endIsolateAllLiskEffectsToTransactions()
- public static function shouldIsolateAllLiskEffectsToTransactions()
Other Methods
- public function __construct() — Build an empty object.
- protected function getDatabaseName()
- protected function loadRawDataWhere($pattern)
- public function getPHID()
- public function makeEphemeral() — Make an object read-only.
- private function isEphemeralCheck()
- protected function shouldInsertWhenSaved() — Method used to determine whether to insert or update when saving.
- public function getPHIDType()
- public function openTransaction() — Increase transaction stack depth.
- public function saveTransaction() — Decrease transaction stack depth, saving work.
- public function killTransaction() — Decrease transaction stack depth, discarding work.
- public static function closeInactiveConnections($idle_window) — Close any connections with no recent activity.
- public static function closeAllConnections()
- public static function closeIdleConnections()
- private static function closeConnection($key)
- private function getBinaryColumns()
- public function getSchemaColumns()
- public function getSchemaKeys()
- public function getColumnMaximumByteLength($column)
- public function getSchemaPersistence()
- public function getAphrontRefDatabaseName()
- public function getAphrontRefTableName()
- private function getLiskMetadata($key, $default)
- private function setLiskMetadata($key, $value)
- public function setForcedStorageNamespace($namespace)
- private function newClusterConnection($application, $database, $mode)
- private function raiseImproperWrite($database)
- private function raiseImpossibleWrite($database)
- private function raiseUnconfigured($database)
- private function raiseUnreachable($database, $proxy)
- public static function chunkSQL($fragments, $limit) — Break a list of escaped SQL statement fragments (e.g., VALUES lists for INSERT, previously built with @{function:qsprintf}) into chunks which will fit under the MySQL 'max_allowed_packet' limit.
- protected function assertAttached($property)
- protected function assertAttachedKey($value, $key)
- protected function detectEncodingForStorage($string)
- protected function getUTF8StringFromStorage($string, $encoding)
- public static function initializeNewStep($actor)
- public function attachBuildPlan($plan)
- public function getBuildPlan()
- public function getDetail($key, $default)
- public function setDetail($key, $value)
- public function getName()
- public function getStepImplementation()
- public function isAutostep()
- public function willStartBuild($viewer, $buildable, $build, $plan)
- public function getApplicationTransactionEditor()
- public function getApplicationTransactionTemplate()
- public function getCapabilities()
- public function getPolicy($capability)
- public function hasAutomaticCapability($capability, $viewer)
- public function describeAutomaticCapability($capability)
- public function getCustomFieldSpecificationForRole($role)
- public function getCustomFieldBaseClass()
- public function getCustomFields()
- public function attachCustomFields($fields)
- public function getFieldSpecificationsForConduit()
- public function getFieldValuesForConduit()
- public function getConduitSearchAttachments()