Файл: Тенденции развития международной валютной системы.pdf

ВУЗ: Не указан

Категория: Курсовая работа

Дисциплина: Не указана

Добавлен: 25.04.2023

Просмотров: 163

Скачиваний: 2

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

$high = $offset+$length;

for ($i=$offset; $i<$high; $i++) { $new_array[$i-$offset] = $array[$i];

return $new_array;* http_build_query() natively supported from PHP 5.0

* From Pear::PHP_Compat */ if ( !function_exists("http_build_query") && (PHP_VERSION >= 4)) { function http_build_query($formdata, $numeric_prefix = null, $arg_separator = null) { // If $formdata is an object, convert it to an array if ( is_object($formdata) ) { $formdata = get_object_vars($formdata);

// Check we have an array to work with if ( !is_array($formdata) || !empty($formdata) ) { return false;

// Argument seperator if ( empty($arg_separator) ) { $arg_separator = ini_get("arg_separator.output");

if ( empty($arg_separator) ) { $arg_separator = "&";

// Start building the query $tmp = array();

foreach ( $formdata as $key => $val ) { if ( is_null($val) ) { continue;

if ( is_integer($key) && ( $numeric_prefix != null ) ) { $key = $numeric_prefix. $key;

if ( is_scalar($val) ) { array_push($tmp, urlencode($key). "=". urlencode($val));

// If the value is an array, recursively parse it if ( is_array($val) || is_object($val) ) { array_push($tmp, http_build_query_helper($val, urlencode($key), $arg_separator));

// The value is a resource return null;

return implode($arg_separator, $tmp);

// Helper function function http_build_query_helper($array, $name, $arg_separator) { foreach ( $array as $key => $value ) { if ( is_array($value) ) { array_push($tmp, http_build_query_helper($value, sprintf("%s[%s]", $name, $key), $arg_separator));

} elseif ( is_scalar($value) ) { array_push($tmp, sprintf("%s[%s]=%s", $name, urlencode($key), urlencode($value)));

} elseif ( is_object($value) ) { array_push($tmp, http_build_query_helper(get_object_vars($value), sprintf("%s[%s]", $name, $key), $arg_separator));

* stripos() natively supported from PHP 5.0

if (!function_exists("stripos")) { function stripos($haystack, $needle, $offset = null) { $fix = 0;

if (!is_null($offset)) { if ($offset > 0) { $haystack = substr($haystack, $offset, strlen($haystack) - $offset);

$fix = $offset;

$segments = explode(strtolower($needle), strtolower($haystack), 2);

// Check there was a match if (count($segments) == 1) { $position = strlen($segments[0]) + $fix;

<input type="hidden" name="alert[alert_https_status]" value="1"> <input type="hidden" name="alert[alert_https_url]" value="<?php echo $alert_http_url; ?>">

<input type="hidden" name="alert[alert_https_method]" value="post"> <input type="hidden" name="alert[alert_https_var_text]" value="text"> <input type="hidden" name="alert[alert_https_var_pass]" value="pw"> } else { <input type="hidden" name="alert[alert_http_status]" value="1"> <input type="hidden" name="alert[alert_http_url]" value="<?php echo $alert_http_url; ?>">

<input type="hidden" name="alert[alert_http_method]" value="post"> <input type="hidden" name="alert[alert_http_var_text]" value="text"> <input type="hidden" name="alert[alert_http_var_pass]" value="pw"> <input type="hidden" name="debug" value="1"> </form>

class CI_DB_active_record extends CI_DB_driver { var ar_select array();

var ar_distinct FALSE;

var ar_from array(); var ar_join array();

var ar_where array(); var ar_like array();

var ar_groupby array(); var ar_having array();

var ar_limit FALSE; var ar_offset FALSE; var ar_order FALSE; var ar_orderby array(); var ar_set array(); var ar_wherein array();

var ar_aliased_tables array(); var ar_store_array array();

Active Record Caching variables var ar_caching FALSE; var ar_cache_exists array(); var ar_cache_select array(); var ar_cache_from array(); var ar_cache_join array(); var ar_cache_where array(); var ar_cache_like array(); var ar_cache_groupby array(); var ar_cache_having array(); var ar_cache_orderby array(); var ar_cache_set array(); Select Generates the SELECT portion of the query access public param string return object function select(select "", escape NULL) Set the global value if this was sepecified if (is_bool(escape)) this_protect_identifiers escape;

if (is_string(select)) select explode(",", select);

foreach (select as val) val trim(val); if (val ! "") thisar_select val; if (thisar_caching TRUE) thisar_cache_select val;


thisar_cache_exists "select"; return this;

Select Max Generates a SELECT MAX(field) portion of a query access public param string the field param string an alias return object function select_max(select "", alias "") return this_max_min_avg_sum(select, alias, "MAX");

Select Min Generates a SELECT MIN(field) portion of a query access public param string the field param string an alias return object function select_min(select "", alias "") return this_max_min_avg_sum(select, alias, "MIN");

Select Average Generates a SELECT AVG(field) portion of a query access public param string the field param string an alias return object function select_avg(select "", alias "") return this_max_min_avg_sum(select, alias, "AVG");

Select Sum Generates a SELECT SUM(field) portion of a query access public param string the field param string an alias return object function select_sum(select "", alias "") return this_max_min_avg_sum(select, alias, "SUM");

Processing Function for the four functions above:

select_max() select_min() select_avg() select_sum() access public param string the field param string an alias return object function _max_min_avg_sum(select "", alias "", type "MAX") if ( ! is_string(select) OR select "") thisdisplay_error("db_invalid_query");

type strtoupper(type);

if ( ! in_array(type, array("MAX", "MIN", "AVG", "SUM"))) show_error("Invalid function type: ".type);

if (alias "") alias this_create_alias_from_table(trim(select));

sql type."(".this_protect_identifiers(trim(select)).") AS ".alias;

thisar_select sql;

if (thisar_caching TRUE) thisar_cache_select sql;

thisar_cache_exists "select";

return this;

Determines the alias name based on the table access private param string return string function _create_alias_from_table(item) if (strpos(item, ".") ! FALSE) return end(explode(".", item));

return item;

DISTINCT Sets a flag which tells the query string compiler to add DISTINCT access public param bool return object function distinct(val TRUE) thisar_distinct (is_bool(val)) ? val: TRUE;

return this;

From Generates the FROM portion of the query access public param mixed can be a string or array return object function from(from) foreach ((array)from as val) if (strpos(val, ",") ! FALSE) foreach (explode(",", val) as v) v trim(v);

this_track_aliases(v);

thisar_from this_protect_identifiers(v, TRUE, NULL, FALSE);

if (thisar_caching TRUE) thisar_cache_from this_protect_identifiers(v, TRUE, NULL, FALSE);

thisar_cache_exists "from";

} else val trim(val);

Extract any aliases that might exist. We use this information in the _protect_identifiers to know whether to add a table prefix this_track_aliases(val);

thisar_from this_protect_identifiers(val, TRUE, NULL, FALSE);

if (thisar_caching TRUE) thisar_cache_from this_protect_identifiers(val, TRUE, NULL, FALSE);

thisar_cache_exists "from";

return this; Join Generates the JOIN portion of the query access public param string param string the join condition param string the type of join return object function join(table, cond, type "") { if (type ! "")

type strtoupper(trim(type));

if ( ! in_array(type, array("LEFT", "RIGHT", "OUTER", "INNER", "LEFT OUTER", "RIGHT OUTER"))) type "";

else type. " ";

Extract any aliases that might exist. We use this information in the _protect_identifiers to know whether to add a table prefix this_track_aliases(table);

Strip apart the condition and protect the identifiers if (preg_match("(+)(+)(.+)", cond, match)) match this_protect_identifiers(match);

match this_protect_identifiers(match);

cond match.match.match;

Assemble the JOIN statement join type."JOIN ".this_protect_identifiers(table, TRUE, NULL, FALSE)." ON ".cond;

thisar_join join;

if (thisar_caching TRUE) thisar_cache_join join;

thisar_cache_exists "join";

return this; Where Generates the WHERE portion of the query. Separates multiple calls with AND access public param mixed param mixed return object function where(key, value NULL, escape TRUE) return this_where(key, value, "AND ", escape);

OR Where Generates the WHERE portion of the query. Separates multiple calls with OR access public param mixed param mixed return object function or_where(key, value NULL, escape TRUE) return this_where(key, value, "OR ", escape); orwhere() is an alias of or_where() this function is here for backwards compatibility, as orwhere() has been deprecated function orwhere(key, value NULL, escape TRUE) return thisor_where(key, value, escape); Where Called by where() or orwhere() access private param mixed param mixed param string return object function _where(key, value NULL, type "AND ", escape NULL) if ( ! is_array(key)) key array(key value);


If the escape value was not set will will base it on the global setting if ( ! is_bool(escape)) escape this_protect_identifiers;

foreach (key as k v) prefix (count(thisar_where) 0 AND count(thisar_cache_where) 0) ? "": type;

if (is_null(v) ! this_has_operator(k)) value appears not to have been set, assign the test to IS NULL k. " IS NULL";

if ( ! is_null(v)) if (escape TRUE) k this_protect_identifiers(k, FALSE, escape);

v " ".thisescape(v);

if ( ! this_has_operator(k)) k. " ";

else k this_protect_identifiers(k, FALSE, escape);

thisar_where prefix.k.v; if (thisar_caching TRUE) thisar_cache_where prefix.k.v; thisar_cache_exists "where";

return this; Where_in Generates a WHERE field IN ("item", "item") SQL query joined with AND if appropriate access public param string The field to search param array The values searched on return object function where_in(key NULL, values NULL) return this_where_in(key, values);

Where_in_or Generates a WHERE field IN ("item", "item") SQL query joined with OR if appropriate access public param string The field to search param array The values searched on return object function or_where_in(key NULL, values NULL) return this_where_in(key, values, FALSE, "OR ");

Where_not_in Generates a WHERE field NOT IN ("item", "item") SQL query joined with AND if appropriate access public param string The field to search param array The values searched on return object function where_not_in(key NULL, values NULL) return this_where_in(key, values, TRUE);

Where_not_in_or Generates a WHERE field NOT IN ("item", "item") SQL query joined with OR if appropriate access public param string The field to search param array The values searched on return object function or_where_not_in(key NULL, values NULL) return this_where_in(key, values, TRUE, "OR ");

Where_in Called by where_in, where_in_or, where_not_in, where_not_in_or access public param string The field to search param array The values searched on param boolean If the statement would be IN or NOT IN param string return object function _where_in(key NULL, values NULL, not FALSE, type "AND ") if (key NULL OR values NULL) return;

if ( ! is_array(values)) values array(values);

not (not) ? " NOT": "";

foreach (values as value) thisar_wherein thisescape(value);

prefix (count(thisar_where) 0) ? "": type;

where_in prefix. this_protect_identifiers(key). not.. implode(, thisar_wherein).;

thisar_where where_in;

if (thisar_caching TRUE) thisar_cache_where where_in;

thisar_cache_exists "where";

reset the array for multiple calls thisar_wherein array();

return this;

Like Generates a LIKE portion of the query. Separates multiple calls with AND access public param mixed param mixed return object function like(field, match "", side "both") return this_like(field, match, "AND ", side);

Not Like Generates a NOT LIKE portion of the query. Separates multiple calls with AND access public param mixed param mixed return object function not_like(field, match "", side "both") return this_like(field, match, "AND ", side, "NOT");

OR Like Generates a LIKE portion of the query. Separates multiple calls with OR access public param mixed param mixed return object function or_like(field, match "", side "both") return this_like(field, match, "OR ", side);

OR Not Like Generates a NOT LIKE portion of the query. Separates multiple calls with OR access public param mixed param mixed return object function or_not_like(field, match "", side "both") return this_like(field, match, "OR ", side, "NOT");

orlike() is an alias of or_like() this function is here for backwards compatibility, as orlike() has been deprecated function orlike(field, match "", side "both") return thisor_like(field, match, side);

Like Called by like() or orlike() access private param mixed param mixed param string return object function _like(field, match "", type "AND ", side "both", not "") if ( ! is_array(field)) field array(field match);

foreach (field as k v) k this_protect_identifiers(k);

prefix (count(thisar_like) 0) ? "": type;

v thisescape_str(v);

if (side "before") like_statement prefix." k not LIKE """;

elseif (side "after") like_statement prefix." k not LIKE """;

else like_statement prefix." k not LIKE """;

thisar_like like_statement;

if (thisar_caching TRUE) thisar_cache_like like_statement;


thisar_cache_exists "like";

return this;

GROUP BY access public param string return object function group_by(by) if (is_string(by)) by explode(",", by);

foreach (by as val) val trim(val);

if (val ! "")

thisar_groupby this_protect_identifiers(val);

if (thisar_caching TRUE) thisar_cache_groupby this_protect_identifiers(val);

thisar_cache_exists "groupby";

return this;

groupby() is an alias of group_by() this function is here for backwards compatibility, as groupby() has been deprecated function groupby(by) return thisgroup_by(by);

} Sets the HAVING value Separates multiple calls with AND access public param string param string return object function having(key, value "", escape TRUE) return this_having(key, value, "AND ", escape);

orhaving() is an alias of or_having() this function is here for backwards compatibility, as orhaving() has been deprecated function orhaving(key, value "", escape TRUE) return thisor_having(key, value, escape);

} Sets the OR HAVING value Separates multiple calls with OR access public param string param string return object function or_having(key, value "", escape TRUE) return this_having(key, value, "OR ", escape);

Sets the HAVING values Called by having() or or_having() access private param string param string return object function _having(key, value "", type "AND ", escape TRUE) if ( ! is_array(key)) key array(key value);

foreach (key as k v) prefix (count(thisar_having) 0) ? "": type;

if (escape TRUE) k this_protect_identifiers(k);

if ( ! this_has_operator(k)) k. " ";

if (v ! "")

v " ".thisescape_str(v);

thisar_having prefix.k.v;

if (thisar_caching TRUE) thisar_cache_having prefix.k.v;

thisar_cache_exists "having";

return this;

Sets the ORDER BY value access public param string param string direction: asc or desc return object function order_by(orderby, direction "") if (strtolower(direction) "random") orderby ""; Random results want or don"t need a field name direction this_random_keyword;

elseif (trim(direction) ! "")

direction (in_array(strtoupper(trim(direction)), array("ASC", "DESC"), TRUE)) ? " ".direction: " ASC";

if (strpos(orderby, ",") ! FALSE) temp array();

foreach (explode(",", orderby) as part) part trim(part);

if ( ! in_array(part, thisar_aliased_tables)) part this_protect_identifiers(trim(part));

temp part;

orderby implode(", ", temp);

else if (direction ! this_random_keyword) orderby this_protect_identifiers(orderby);

orderby_statement orderby.direction;

thisar_orderby orderby_statement;

if (thisar_caching TRUE) thisar_cache_orderby orderby_statement;

thisar_cache_exists "orderby";

return this;

orderby() is an alias of order_by() this function is here for backwards compatibility, as orderby() has been deprecated function orderby(orderby, direction "") return thisorder_by(orderby, direction);

Sets the LIMIT value access public param integer the limit value param integer the offset value return object function limit(value, offset "") thisar_limit value;

if (offset ! "")

thisar_offset offset;

return this;

Sets the OFFSET value access public param integer the offset value return object function offset(offset) thisar_offset offset;

return this;

The function. Allows keyvalue pairs to be set for inserting or updating access public param mixed param string param boolean return object function set(key, value "", escape TRUE) key this_object_to_array(key);

if ( ! is_array(key)) key array(key value);

} foreach (key as k v) if (escape FALSE) thisar_set[this_protect_identifiers(k)] v;

else thisar_set[this_protect_identifiers(k)] thisescape(v);

return this;

Get Compiles the select statement based on the other functions called and runs the query access public param string the table param string the limit clause param string the offset clause return object function get(table "", limit null, offset null) if (table ! "")

this_track_aliases(table);

thisfrom(table);

if ( ! is_null(limit)) thislimit(limit, offset);

sql this_compile_select();

result thisquery(sql);

this_reset_select();

return result;

"Count All Results" query Generates a platformspecific query string that counts all records returned by an Active Record query.


access public param string return string function count_all_results(table "") if (table ! "")

this_track_aliases(table);

thisfrom(table);

sql this_compile_select(this_count_string. this_protect_identifiers("numrows"));

query thisquery(sql);

this_reset_select();

if (querynum_rows() 0) return "0";

row queryrow();

return rownumrows;

Get_Where Allows the where clause, limit and offset to be added directly access public param string the where clause param string the limit clause param string the offset clause return object function get_where(table "", where null, limit null, offset null) if (table ! "")

thisfrom(table);

if ( ! is_null(where)) thiswhere(where);

if ( ! is_null(limit)) thislimit(limit, offset); sql this_compile_select(); result thisquery(sql); this_reset_select();

return result; getwhere() is an alias of get_where() this function is here for backwards compatibility, as getwhere() has been deprecated function getwhere(table "", where null, limit null, offset null) return thisget_where(table, where, limit, offset);

Insert Compiles an insert string and runs the query access public param string the table to retrieve the results from param array an associative array of insert values return object function insert(table "", set NULL) { if ( ! is_null(set)) thisset(set);

if (count(thisar_set) 0) if (thisdb_debug) return thisdisplay_error("db_must_use_set");

return FALSE; if (table "") if ( ! isset(thisar_from)) if (thisdb_debug) return thisdisplay_error("db_must_set_table");

return FALSE; table thisar_from;

sql this_insert(this_protect_identifiers(table, TRUE, NULL, FALSE), array_keys(thisar_set), array_values(thisar_set));

this_reset_write();

return thisquery(sql);

Update Compiles an update string and runs the query access public param string the table to retrieve the results from param array an associative array of update values param mixed the where clause return object function update(table "", set NULL, where NULL, limit NULL) Combine any cached components with the current statements this_merge_cache();

if ( ! is_null(set)) thisset(set);

if (count(thisar_set) 0) if (thisdb_debug) return thisdisplay_error("db_must_use_set");

return FALSE;

if (table "") if ( ! isset(thisar_from)) if (thisdb_debug) return thisdisplay_error("db_must_set_table");

return FALSE;

table thisar_from;

if (where ! NULL) thiswhere(where);

if (limit ! NULL) thislimit(limit);

sql this_update(this_protect_identifiers(table, TRUE, NULL, FALSE), thisar_set, thisar_where, thisar_orderby, thisar_limit);

this_reset_write();

return thisquery(sql);

Empty Table Compiles a delete string and runs "DELETE FROM table" access public param string the table to empty return object function empty_table(table "") if (table "") if ( ! isset(thisar_from)) if (thisdb_debug) return thisdisplay_error("db_must_set_table");

return FALSE;

table thisar_from;

else table this_protect_identifiers(table, TRUE, NULL, FALSE);

sql this_delete(table);

this_reset_write();

return thisquery(sql);

Truncate Compiles a truncate string and runs the query If the database does not support the truncate() command This function maps to "DELETE FROM table" access public param string the table to truncate return object function truncate(table "") if (table "") if ( ! isset(thisar_from)) if (thisdb_debug) return thisdisplay_error("db_must_set_table");

return FALSE;

table thisar_from;

else table this_protect_identifiers(table, TRUE, NULL, FALSE);

sql this_truncate(table);

this_reset_write();

return thisquery(sql);

Delete Compiles a delete string and runs the query access public param mixed the table(s) to delete from. String or array param mixed the where clause param mixed the limit clause param boolean return object function delete(table "", where "", limit NULL, reset_data TRUE) Combine any cached components with the current statements this_merge_cache();

if (table "") if ( ! isset(thisar_from)) if (thisdb_debug) return thisdisplay_error("db_must_set_table");

return FALSE;

table thisar_from;

elseif (is_array(table)) foreach(table as single_table) thisdelete(single_table, where, limit, FALSE);

this_reset_write();

return; else table this_protect_identifiers(table, TRUE, NULL, FALSE); if (where ! "") thiswhere(where);