phpDocumentor Swift
[ class tree: Swift ] [ index: Swift ] [ all elements ]

Class: SwiftDb

Source Location: /classes/SwiftDb.php

Class SwiftDb

Class Overview

The SwiftDb class contains functions to connect to any MySQL database.

Once connected you can add/remove/update data quickly and easily.

Located in /classes/SwiftDb.php [line 43]



		
		
		
		

Methods

[ Top ]
Method Summary
SwiftDb   __construct()   Creates a new SwiftDb object. The object will attempt to automatically connect to a database if connection paramters are provided when calling.
MySQLi|true|false   connect()   Connects to the MySQL database with the provided connection params.
boolean   disconnect()   Disconnects for the currently connected MySQL database. Returns false if not connected.
string|false   escapeString()   Converts any string to a safe, escaped version for using on queries.
array   fetchRow()   Fetches the next row of the current or given query result and returns and associative array.
void   freeResult()   Connects to the MySQL database with the provided connection params.
integer   getError()   Gets the most recent error from the MySQL database.
integer   getNumResults()   Gets the number of rows from the current result.
mysqli_result   getResult()   Gets the most recently queried result from the database.
mysqli_stmt   prepare()   Prepares the SQL query, and returns a statement handle to be used for further operations on the statement.
mysqli_result   query()   Executes a query on the currently connected MySQL database.
string   stripSlashes()   Strips slashes from an escapped string. Single slashes are removed. Double slashes become single slashes.

[ Top ]
Methods
Constructor __construct  [line 62]

  SwiftDb __construct( string $host, string $user, string $pass, string $db  )

Creates a new SwiftDb object. The object will attempt to automatically connect to a database if connection paramters are provided when calling.

Parameters:
string   $host:  Host IP or address of the MySQL server
string   $user:  Username for the MySQL database
string   $pass:  Password for the MySQL user
string   $db:  Name of the MySQL database

API Tags:
Return:  The new SwiftDb object
Access:  public


[ Top ]
connect  [line 81]

  MySQLi|true|false connect( [string $host = null], [string $user = null], [string $pass = null], [string $db = null]  )

Connects to the MySQL database with the provided connection params.

Parameters:
string   $host:  Host IP or address of the MySQL server
string   $user:  Username for the MySQL database
string   $pass:  Password for the MySQL user
string   $db:  Name of the MySQL database

API Tags:
Return:  Link for the current connection if successful. True if already connected to given host, or false on connection error
Access:  public


[ Top ]
disconnect  [line 101]

  boolean disconnect( )

Disconnects for the currently connected MySQL database. Returns false if not connected.


API Tags:
Return:  True on success. False on error or if there is no current connection
Access:  public


[ Top ]
escapeString  [line 187]

  string|false escapeString( string $str  )

Converts any string to a safe, escaped version for using on queries.

Note: It is recommended to only store escaped strings into columns with a utf8 collation.

Parameters:
string   $str:  The query string you want to make safe

API Tags:
Return:  The safe version of the string or false
Access:  public


[ Top ]
fetchRow  [line 137]

  array fetchRow( [mysqli_result $res = null]  )

Fetches the next row of the current or given query result and returns and associative array.

Parameters:
mysqli_result   $res:  MySQLi result object

API Tags:
Access:  public


[ Top ]
freeResult  [line 114]

  void freeResult( [mysqli_result $res = null]  )

Connects to the MySQL database with the provided connection params.

Parameters:
mysqli_result   $res:  MySQLi result object

API Tags:
Access:  public


[ Top ]
getError  [line 151]

  integer getError( )

Gets the most recent error from the MySQL database.


API Tags:
Access:  public


[ Top ]
getNumResults  [line 172]

  integer getNumResults( [string $res = null]  )

Gets the number of rows from the current result.

Parameters:
string   $res:  Id for a given MySQL result query

API Tags:
Return:  Number of rows
Access:  public


[ Top ]
getResult  [line 163]

  mysqli_result getResult( )

Gets the most recently queried result from the database.


API Tags:
Return:  Result from MySQL query
Access:  public


[ Top ]
prepare  [line 213]

  mysqli_stmt prepare( string $q  )

Prepares the SQL query, and returns a statement handle to be used for further operations on the statement.

The query must consist of a single SQL statement.

Parameters:
string   $q:  The query string to prepare in the MySQL database. This parameter can include one or more parameter markers in the SQL statement by embedding question mark (?) characters at the appropriate positions.

API Tags:
Return:  A mysqli statement object or FALSE if an error occurred.
Access:  public


[ Top ]
query  [line 127]

  mysqli_result query( string $q  )

Executes a query on the currently connected MySQL database.

Parameters:
string   $q:  The query string to run on the database.

API Tags:
Return:  MySQLi result object
Access:  public


[ Top ]
stripSlashes  [line 201]

  string stripSlashes( string $str  )

Strips slashes from an escapped string. Single slashes are removed. Double slashes become single slashes.

Note: This function behaves identical to the PHP stipslashes() function.

Parameters:
string   $str:  The query string you want to strip slashes from.

API Tags:
Return:  The string after removing slashes.
Access:  public


[ Top ]

Documentation generated on Tue, 08 Oct 2013 05:37:15 +0200 by phpDocumentor 1.4.4