/** * Inserts $message to the currently open database. Calls open(), * if necessary. Also passes the message along to any Log_observer * instances that are observing this Log. * * @param mixed $message String or object containing the message to log. * @param string $priority The priority of the message. Valid * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = null) { /* If a priority hasn't been specified, use the default value. */ if ($priority === null) { $priority = $this->_priority; } /* Abort early if the priority is above the maximum logging level. */ if (!$this->_isMasked($priority)) { return false; } /* If the connection isn't open and can't be opened, return failure. */ if (!$this->_opened && !$this->open()) { return false; } /* If we don't already have a statement object, create one. */ if (!is_object($this->_statement) && !$this->_prepareStatement()) { return false; } /* Extract the string representation of the message. */ $message = $this->_extractMessage($message); /* Build our set of values for this log entry. */ $values = array('id' => $this->_db->nextId($this->_sequence), 'logtime' => MDB2_Date::mdbNow(), 'ident' => $this->_ident, 'priority' => $priority, 'message' => $message); /* Execute the SQL query for this log entry insertion. */ $this->_db->expectError(MDB2_ERROR_NOSUCHTABLE); $result =& $this->_statement->execute($values); $this->_db->popExpect(); /* Attempt to handle any errors. */ if (PEAR::isError($result)) { /* We can only handle MDB2_ERROR_NOSUCHTABLE errors. */ if ($result->getCode() != MDB2_ERROR_NOSUCHTABLE) { return false; } /* Attempt to create the target table. */ if (!$this->_createTable()) { return false; } /* Recreate our prepared statement resource. */ $this->_statement->free(); if (!$this->_prepareStatement()) { return false; } /* Attempt to re-execute the insertion query. */ $result = $this->_statement->execute($values); if (PEAR::isError($result)) { return false; } } $this->_announce(array('priority' => $priority, 'message' => $message)); return true; }
/** * Free the memory used by the result resource * * @return void */ public function free() { switch ($this->mode) { case "mysql": $this->result->free(); break; case "postgres": case "redshift": pg_free_result($this->result); break; case "odbc": odbc_free_result($this->result); break; case "sqlite": $this->result->finalize(); break; case "mssql": mssql_free_result($this->result); break; } }
/** * Limpiamos la consulta * @author Ignacio Daniel Rostagno <*****@*****.**> * @return boolean */ private function free() { return is_resource($this->data) ? $this->data->free() : true; }
public function __destruct() { if (is_object($this->handle)) { $this->handle->free(); } }
/** * 释放结果集所占资源 * @return void */ protected function free() { @$this->rs->free(); }