/** * Release a lock that was previously obtained with @lock. * @param lock $lock - a lock obtained from this factory. * @return boolean - true if the lock is no longer held (including if it was never held). */ public function release_lock(lock $lock) { $params = array('locktype' => $this->dblockid, 'token' => $lock->get_key()); $result = $this->db->get_record_sql('SELECT pg_advisory_unlock(:locktype, :token) AS unlocked', $params); $result = $result->unlocked === 't'; if ($result) { unset($this->openlocks[$lock->get_key()]); } return $result; }
/** * Get a single database record as an object using a SQL statement. * * The SQL statement should normally only return one record. * It is recommended to use get_records_sql() if more matches possible! * * @param string $sql The SQL string you wish to be executed, should normally only return one record. * @param array $params array of sql parameters * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; * IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); * MUST_EXIST means throw exception if no record or multiple records found * @return mixed a fieldset object containing the first matching record, false or exception if error not found depending on mode * @throws dml_exception A DML specific exception is thrown for any errors. */ public function get_record_sql($sql, array $params = null, $strictness = IGNORE_MISSING) { $strictness = (int) $strictness; if ($strictness == IGNORE_MULTIPLE) { // do not limit here - ORA does not like that $rs = $this->get_recordset_sql($sql, $params); $result = false; foreach ($rs as $rec) { $result = $rec; break; } $rs->close(); return $result; } return parent::get_record_sql($sql, $params, $strictness); }