Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reset on cache #319

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 38 additions & 33 deletions idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static function configure($key, $value = null, $connection_name = self::D
}
} else {
if (is_null($value)) {
// Shortcut: If only one string argument is passed,
// Shortcut: If only one string argument is passed,
// assume it's a connection string
$value = $key;
$key = 'connection_string';
Expand Down Expand Up @@ -296,7 +296,7 @@ public static function get_config($key = null, $connection_name = self::DEFAULT_
public static function reset_config() {
self::$_config = array();
}

/**
* Despite its slightly odd name, this is actually the factory
* method used to acquire instances of the class. It is named
Expand Down Expand Up @@ -383,7 +383,7 @@ protected static function _setup_identifier_quote_character($connection_name) {

/**
* Detect and initialise the limit clause style ("SELECT TOP 5" /
* "... LIMIT 5"). If this has been specified manually using
* "... LIMIT 5"). If this has been specified manually using
* ORM::configure('limit_clause_style', 'top'), this will do nothing.
* @param string $connection_name Which connection to use
*/
Expand Down Expand Up @@ -561,13 +561,13 @@ protected static function _log_query($query, $parameters, $connection_name, $que

self::$_last_query = $bound_query;
self::$_query_log[$connection_name][] = $bound_query;


if(is_callable(self::$_config[$connection_name]['logger'])){
$logger = self::$_config[$connection_name]['logger'];
$logger($bound_query, $query_time);
}

return true;
}

Expand Down Expand Up @@ -734,7 +734,7 @@ public function find_result_set() {
* @return array
*/
public function find_array() {
return $this->_run();
return $this->_run();
}

/**
Expand Down Expand Up @@ -906,14 +906,14 @@ public function select_expr($expr, $alias=null) {
* Add columns to the list of columns returned by the SELECT
* query. This defaults to '*'. Many columns can be supplied
* as either an array or as a list of parameters to the method.
*
*
* Note that the alias must not be numeric - if you want a
* numeric alias then prepend it with some alpha chars. eg. a1
*
*
* @example select_many(array('alias' => 'column', 'column2', 'alias2' => 'column3'), 'column4', 'column5');
* @example select_many('column', 'column2', 'column3');
* @example select_many(array('column', 'column2', 'column3'), 'column4', 'column5');
*
*
* @return \ORM
*/
public function select_many() {
Expand All @@ -932,16 +932,16 @@ public function select_many() {

/**
* Add an unquoted expression to the list of columns returned
* by the SELECT query. Many columns can be supplied as either
* by the SELECT query. Many columns can be supplied as either
* an array or as a list of parameters to the method.
*
*
* Note that the alias must not be numeric - if you want a
* numeric alias then prepend it with some alpha chars. eg. a1
*
*
* @example select_many_expr(array('alias' => 'column', 'column2', 'alias2' => 'column3'), 'column4', 'column5')
* @example select_many_expr('column', 'column2', 'column3')
* @example select_many_expr(array('column', 'column2', 'column3'), 'column4', 'column5')
*
*
* @return \ORM
*/
public function select_many_expr() {
Expand All @@ -961,11 +961,11 @@ public function select_many_expr() {
/**
* Take a column specification for the select many methods and convert it
* into a normalised array of columns and aliases.
*
*
* It is designed to turn the following styles into a normalised array:
*
*
* array(array('alias' => 'column', 'column2', 'alias2' => 'column3'), 'column4', 'column5'))
*
*
* @param array $columns
* @return array
*/
Expand Down Expand Up @@ -1127,7 +1127,7 @@ public function _add_having_placeholder($column_name, $separator, $values) {
foreach ($data as $key => $val) {
$column = $result->_quote_identifier($key);
$placeholders = $result->_create_placeholders($val);
$result = $result->_add_having("{$column} {$separator} ({$placeholders})", $val);
$result = $result->_add_having("{$column} {$separator} ({$placeholders})", $val);
}
return $result;
}
Expand Down Expand Up @@ -1172,7 +1172,7 @@ public function _add_where_placeholder($column_name, $separator, $values) {
foreach ($data as $key => $val) {
$column = $result->_quote_identifier($key);
$placeholders = $result->_create_placeholders($val);
$result = $result->_add_where("{$column} {$separator} ({$placeholders})", $val);
$result = $result->_add_where("{$column} {$separator} ({$placeholders})", $val);
}
return $result;
}
Expand Down Expand Up @@ -1231,7 +1231,7 @@ protected function _add_simple_condition($type, $column_name, $separator, $value
$result = $result->_add_condition($type, "{$key} {$separator} ?", $val);
}
return $result;
}
}

/**
* Return a string containing the given number of question marks,
Expand All @@ -1251,7 +1251,7 @@ protected function _create_placeholders($fields) {
return implode(', ', $db_fields);
}
}

/**
* Helper method that filters a column/value array returning only those
* columns that belong to a compound primary key.
Expand Down Expand Up @@ -1328,7 +1328,7 @@ public function where_id_is($id) {
* it can be overriden for any or every column using the second parameter.
*
* Each condition will be ORed together when added to the final query.
*/
*/
public function where_any_is($values, $operator='=') {
$data = array();
$query = array("((");
Expand Down Expand Up @@ -1504,7 +1504,7 @@ public function group_by($column_name) {
}

/**
* Add an unquoted expression to the list of columns to GROUP BY
* Add an unquoted expression to the list of columns to GROUP BY
*/
public function group_by_expr($expr) {
$this->_group_by[] = $expr;
Expand Down Expand Up @@ -1899,6 +1899,11 @@ protected function _run() {
$cached_result = self::_check_query_cache($cache_key, $this->_table_name, $this->_connection_name);

if ($cached_result !== false) {
// reset Idiorm after executing the query
$this->_values = array();
$this->_result_columns = array('*');
$this->_using_default_result_columns = true;

return $cached_result;
}
}
Expand Down Expand Up @@ -2007,7 +2012,7 @@ public function set($key, $value = null) {
* To set multiple properties at once, pass an associative array
* as the first parameter and leave out the second parameter.
* Flags the properties as 'dirty' so they will be saved to the
* database when save() is called.
* database when save() is called.
* @param string|array $key
* @param string|null $value
*/
Expand Down Expand Up @@ -2243,12 +2248,12 @@ public function __isset($key) {

/**
* Magic method to capture calls to undefined class methods.
* In this case we are attempting to convert camel case formatted
* In this case we are attempting to convert camel case formatted
* methods into underscore formatted methods.
*
* This allows us to call ORM methods using camel case and remain
* This allows us to call ORM methods using camel case and remain
* backwards compatible.
*
*
* @param string $name
* @param array $arguments
* @return ORM
Expand All @@ -2265,13 +2270,13 @@ public function __call($name, $arguments)
}

/**
* Magic method to capture calls to undefined static class methods.
* In this case we are attempting to convert camel case formatted
* Magic method to capture calls to undefined static class methods.
* In this case we are attempting to convert camel case formatted
* methods into underscore formatted methods.
*
* This allows us to call ORM methods using camel case and remain
* This allows us to call ORM methods using camel case and remain
* backwards compatible.
*
*
* @param string $name
* @param array $arguments
* @return ORM
Expand Down Expand Up @@ -2432,7 +2437,7 @@ public function get_results() {
public function as_array() {
return $this->get_results();
}

/**
* Get the number of records in the result set
* @return int
Expand Down Expand Up @@ -2467,7 +2472,7 @@ public function offsetExists($offset) {
public function offsetGet($offset) {
return $this->_results[$offset];
}

/**
* ArrayAccess
* @param int|string $offset
Expand Down