Class dbi

Description

StockManiac Database Interface (DBI)

This class contains generically usable SQL statements which are packaged into methods ready for use.

All of this is available through a StockManiac object. Plugins should make use of this whenever possible to avoid the need for plugin specific SQL statements for almost everything. Less SQL statements in the application is beautiful. :-)

Located in /lib/dbi.class.php (line 50)

session
   |
   --gui
      |
      --dbc
         |
         --dbi
Direct descendents
Class Description
 class stockmaniac StockManiac
Method Summary
 bool __construct ()
 void sql_assign_document (int $id_document, [int $id_position = false], [int $id_order = false], [int $id_portfolio = false], [bool $is_assigned = true])
 void sql_close_position (int $id_position, int $date)
 void sql_delete_broken_document (int $id_user, int $id_document)
 void sql_delete_document (int $id_user, int $id_document)
 void sql_delete_setting (int $id_user, string $type, [string $name = false], [string $var = false])
 void sql_get_user_details (string $login)
 void sql_select_acls (int $id_user)
 void sql_select_comments (int $id_user, int $start, int $end, [int $id_comment = false])
 void sql_select_documents (int $id_user, [int $id_position = false], [int $id_portfolio = false], [int $id_order = false], [bool $descending = false])
 void sql_select_document_content (int $id_user, int $id_document)
 void sql_select_first_position (int $id_user, int $id_portfolio)
 void sql_select_order (int $id_position, int $id_order)
 void sql_select_orders (int $id_position, [array $id_order = false], [bool $_has_quote = false])
 void sql_select_portfolios (int $id_user)
 void sql_select_positions (int $id_user, int $end_date, [int $start_date = false], [int $id_portfolio = false], [bool $is_open = false], [bool $is_closed = false])
 void sql_select_position_details (int $id_position)
 void sql_select_position_uid (int $id_position)
 void sql_select_quotes (int $date, [array $id_stock_list = false])
 void sql_select_settings (int $id_user, [string $plugin = false])
 void sql_select_split ([int $id_stock = false], [ $order = false], [int $id_split = false], bool $asc)
 void sql_select_stocks ([array $exclude_ids = ''])
 void sql_select_timetags (int $id_user, [int $id_timetag = false], [int $start = false], [int $end = false])
 void sql_store_document (int $id_user, array $document)
 void sql_store_document_content (int $id_document, string $data, [bool $die_on_failure = true])
 void sql_store_position (object $vo_position)
 void sql_store_setting (int $uid, string $type, string $name, string $var, string $val)
 void sql_update_password (int $id_user, string $pass)
 void sql_verify_password (string $login, string $pass)
Variables
Methods
Constructor __construct (line 56)
  • access: public
bool __construct ()

Redefinition of:
dbc::__construct()

Redefined in descendants as:
sql_assign_document (line 935)

Assing document to a position, order or portfolio. At least one of those must be given.

  • stockmaniac-tables: document_assign
  • access: public
void sql_assign_document (int $id_document, [int $id_position = false], [int $id_order = false], [int $id_portfolio = false], [bool $is_assigned = true])
  • int $id_document
  • int $id_position
  • int $id_order
  • int $id_portfolio
  • bool $is_assigned
sql_check_version (line 85)

Select most recent database schema version./

  • todo: remove compat code for old Version table
  • stockmaniac-tables: Version
  • access: public
void sql_check_version ()
sql_close_position (line 603)

Close a position.

ATTENTION: close is performed without any checks. This might not be what you want, especially if it still contains shares.

  • stockmaniac-tables: position
  • access: public
void sql_close_position (int $id_position, int $date)
  • int $id_position
  • int $date
sql_delete_broken_document (line 789)

Delete document content as well as its metadata even if contraints do not exist the way they should.

ATTENTION: Only useful during the upload phase. Do not use otherwise.

  • stockmaniac-tables: document, document_data, document_assign
  • access: public
void sql_delete_broken_document (int $id_user, int $id_document)
  • int $id_user
  • int $id_document
sql_delete_document (line 758)

Delete document content as well as its metadata.

  • stockmaniac-tables: document, document_data, document_assign
  • access: public
void sql_delete_document (int $id_user, int $id_document)
  • int $id_user
  • int $id_document
sql_delete_setting (line 687)

Delete a user setting.

  • stockmaniac-tables: setting
  • access: public
void sql_delete_setting (int $id_user, string $type, [string $name = false], [string $var = false])
  • int $id_user
  • string $type
  • string $name
  • string $var
sql_get_user_details (line 104)

Select detailed information from given login name.

  • todo: remove compat code for old User table
  • stockmaniac-tables: user
  • access: public
void sql_get_user_details (string $login)
  • string $login
sql_select_acls (line 709)

Select user Access Control Lists (ACLs)

  • stockmaniac-tables: access
  • access: public
void sql_select_acls (int $id_user)
  • int $id_user
sql_select_comments (line 1025)

Select user comment(s) by user id and time, optionally comment id.

  • stockmaniac-tables: comment
  • access: public
void sql_select_comments (int $id_user, int $start, int $end, [int $id_comment = false])
  • int $id_user
  • int $start
  • int $end
  • int $id_comment
sql_select_documents (line 845)

Select document meta data by various criteria. At least a UID must be given.

  • stockmaniac-tables: document, document_assign
  • access: public
void sql_select_documents (int $id_user, [int $id_position = false], [int $id_portfolio = false], [int $id_order = false], [bool $descending = false])
  • int $id_user
  • int $id_position
  • int $id_portfolio
  • int $id_order
  • bool $descending
sql_select_document_content (line 725)

Select document content.

ATTENTION: result is likely to contain binary data.

  • stockmaniac-tables: document, document_data, document_assign
  • access: public
void sql_select_document_content (int $id_user, int $id_document)
  • int $id_user
  • int $id_document
sql_select_first_position (line 570)

Select first position id and its stock id from a user portfolio.

  • stockmaniac-tables: position, portfolio, stock
  • access: public
void sql_select_first_position (int $id_user, int $id_portfolio)
  • int $id_user
  • int $id_portfolio
sql_select_last_insert_id (line 72)

Select last insert id.

Depends on what the previous query did. If it was a INSERT query on a table with AUTO_INCREMENT column it should return the value created by AUTO_INCREMENT.

  • stockmaniac-tables: _any_
  • access: public
void sql_select_last_insert_id ()
sql_select_order (line 280)

Select order details by given position and order id.

  • stockmaniac-tables: order, document_assign, document
  • access: public
void sql_select_order (int $id_position, int $id_order)
  • int $id_position
  • int $id_order
sql_select_orders (line 333)

Select orders by position and (optionally) list of order ids and presense of a current quote.

NOTE: a present quote value actually means that the order has been executed and is not pending anymore.

  • stockmaniac-tables: order, position, position_revision, document_assign
  • access: public
void sql_select_orders (int $id_position, [array $id_order = false], [bool $_has_quote = false])
  • int $id_position
  • array $id_order
  • bool $_has_quote
sql_select_portfolios (line 258)

Select User Portfolios.

  • stockmaniac-tables: portfolio
  • access: public
void sql_select_portfolios (int $id_user)
  • int $id_user
sql_select_positions (line 457)

Select list of positions matching various criteria.

  • stockmaniac-tables: position, position_revision, stock, portfolio, order, dividend
  • access: public
void sql_select_positions (int $id_user, int $end_date, [int $start_date = false], [int $id_portfolio = false], [bool $is_open = false], [bool $is_closed = false])
  • int $id_user
  • int $end_date
  • int $start_date
  • int $id_portfolio
  • bool $is_open
  • bool $is_closed
sql_select_position_details (line 425)

Select details for given position.

  • stockmaniac-tables: stock, position
  • access: public
void sql_select_position_details (int $id_position)
  • int $id_position
sql_select_position_uid (line 547)

Select the owner of a position.

  • stockmaniac-tables: portfolio, position
  • access: public
void sql_select_position_uid (int $id_position)
  • int $id_position
sql_select_quotes (line 227)

Select quotes for a specific date and (optionaly) specific stock(s).

  • stockmaniac-tables: quote
  • access: public
void sql_select_quotes (int $date, [array $id_stock_list = false])
  • int $date
  • array $id_stock_list
sql_select_settings (line 617)

Select settings by user, optionally limited to a specific plugin.

  • stockmaniac-tables: setting
  • access: public
void sql_select_settings (int $id_user, [string $plugin = false])
  • int $id_user
  • string $plugin
sql_select_split (line 979)

Select split data for a given security or split.

  • stockmaniac-tables: split, stock
  • access: public
void sql_select_split ([int $id_stock = false], [ $order = false], [int $id_split = false], bool $asc)
  • int $id_stock
  • bool $asc
  • int $id_split
  • $order
sql_select_stocks (line 208)

Select a list of all Stocks in the System.

Ueful with sql_get_indexedlist_result(). Optionally pass a array of IDs to be exclude from the listing.

  • stockmaniac-tables: stock
  • access: public
void sql_select_stocks ([array $exclude_ids = ''])
  • array $exclude_ids
sql_select_timetags (line 1064)

Select timetags.

NOTE:

  • start and end is *not* a exact match on the columns
  • specify *some* time range and the query will find all tags that either start or end or exist within the range

  • stockmaniac-tables: timetag
  • access: public
void sql_select_timetags (int $id_user, [int $id_timetag = false], [int $start = false], [int $end = false])
  • int $id_user
  • int $id_timetag
  • int $start
  • int $end
sql_store_document (line 820)

Store document meta data.

  • deprecated: use vo_*->store() to insert/update records
  • stockmaniac-tables: document
  • access: public
void sql_store_document (int $id_user, array $document)
  • int $id_user
  • array $document
sql_store_document_content (line 904)

Store document content data (often binary).

  • deprecated: use vo_*->store() to insert/update records
  • stockmaniac-tables: document_data
  • access: public
void sql_store_document_content (int $id_document, string $data, [bool $die_on_failure = true])
  • int $id_document
  • string $data
  • bool $die_on_failure
sql_store_position (line 394)

Store position data.

  • deprecated: use vo_*->store() to insert/update records
  • stockmaniac-tables: position
  • access: public
void sql_store_position (object $vo_position)
  • object $vo_position
sql_store_setting (line 663)

Store a user setting.

  • deprecated: use vo_*->store() to insert/update records
  • stockmaniac-tables: Setting
  • access: public
void sql_store_setting (int $uid, string $type, string $name, string $var, string $val)
  • int $uid
  • string $type
  • string $name
  • string $var
  • string $val
sql_update_password (line 191)

Update user password.

NOTE: we rely on PHPs md5() public function, not on mySQL.

void sql_update_password (int $id_user, string $pass)
  • int $id_user
  • string $pass
sql_verify_password (line 143)

Verify username/password combination.

NOTE: we rely on PHPs md5() public function, not on mySQL.

void sql_verify_password (string $login, string $pass)
  • string $login
  • string $pass

Inherited Methods

Inherited From dbc

 dbc::__construct()
 dbc::sql()
 dbc::sql_escape_string()
 dbc::sql_get_array_result()
 dbc::sql_get_indexedlist_result()
 dbc::sql_get_objectarray_result()
 dbc::sql_get_object_result()
 dbc::sql_get_result()
 dbc::sql_max_packet_size()
 dbc::sql_script()

Inherited From gui

 gui::__construct()
 gui::append()
 gui::assign()
 gui::debug()
 gui::display()
 gui::get_microtime()
 gui::get_template_vars()
 gui::get_themes()
 gui::register_object()
 gui::set_default_theme()

Inherited From session

 session::__construct()
 session::sess_destroy()
 session::sess_exists()
 session::sess_get_var()
 session::sess_store_var()
 session::sess_unset_var()

Documentation generated on Sun, 22 Aug 2010 11:20:17 +0200 by phpDocumentor 1.4.3