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

Class: sql

Source Location: /modules/module_sql.php

Class sql

Class Overview

Class SQL: a simple DB class.

For more information and instructions, see: http://www.twokings.eu/tools/

This file is part of A Simple SQL Class. A Simple SQL Class and all its parts are licensed under the GPL version 2. see: http://www.twokings.eu/tools/license for more information.

Located in /modules/module_sql.php [line 27]



		
				Author(s):
		
		
		
Information Tags:
Version:  1.0
Copyright:  GPL, version 2
Link:  http://twokings.eu/tools/

Properties

Methods

[ Top ]
Property Summary
mixed   $dbase  
mixed   $dbhost  
mixed   $dbpass  
mixed   $dbuser  
mixed   $error_handler  
mixed   $halt_on_sql_error  
mixed   $last_num_results  
mixed   $last_query  
mixed   $num_affected_rows  
mixed   $return_silent  
mixed   $silent_after_failed_connect  
mixed   $sql_link  
mixed   $sql_query  
mixed   $sql_result  

[ Top ]
Method Summary
sql   __construct()  
void   affected_rows()   Gets the number of affected rows
string   build_delete()   A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
string   build_insert()   A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
string   build_select()   A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
string   build_update()   A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()
void   close()   Close Mysql link
void   connection()   Set up the Database connection, depending on the selected DB model.
void   error()   If an error has occured, we print a message. If 'halt_on_sql_error' is set, we die(), else we continue.
array   fetch_all_rows()   Fetch all rows from the last results.
array   fetch_row()   Fetch a single row from the last results.
void   get_last_id()   Get the last inserted id
void   get_last_query()   Get the last performed or stored query
string   get_server_info()   Gets the current MySQL version
boolean   is_mysqli_function()   Checks if the parameter is an mysql function or not. used to determine whether or not a parameter needs to be escaped.
void   num_rows()   Gets the number of selected rows
void   query()   Performs a query. Either pass the query to e executed as a parameter,
void   query_count()   Returns the number of executed queries
string   quote()   Quote variable to make safe to use in a SQL query. If you pass $skipquotes as true, the string will just have added slashes, otherwise it will be wrapped in quotes for convenience
void   set_allow_functions()   Set if we're allowed to use MySQL functions in our queries. This is disabled by default, for security reasons.
void   set_halt_on_error()   Sets whether or not execution of the script should stop when a mysql error has occured.

[ Top ]
Properties
mixed   $dbase [line 33]

[ Top ]
mixed   $dbhost [line 30]

[ Top ]
mixed   $dbpass [line 32]

[ Top ]
mixed   $dbuser [line 31]

[ Top ]
mixed   $error_handler [line 44]

[ Top ]
mixed   $halt_on_sql_error [line 41]

[ Top ]
mixed   $last_num_results [line 39]

[ Top ]
mixed   $last_query [line 38]

[ Top ]
mixed   $num_affected_rows [line 40]

[ Top ]
mixed   $return_silent [line 43]

[ Top ]
mixed   $silent_after_failed_connect [line 42]

[ Top ]
mixed   $sql_link [line 36]

[ Top ]
mixed   $sql_query [line 35]

[ Top ]
mixed   $sql_result [line 37]

[ Top ]
Methods
Constructor __construct  [line 46]

  sql __construct( [ $type = ""], [ $dbase = ""], [ $host = ""], [ $user = ""], [ $pass = ""], [ $port = ""]  )

Parameters:
   $type: 
   $dbase: 
   $host: 
   $user: 
   $pass: 
   $port: 


[ Top ]
affected_rows  [line 384]

  void affected_rows( )

Gets the number of affected rows



[ Top ]
build_delete  [line 854]

  string build_delete( array $q  )

A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()

Example 1:

// Initialize the sql object. $database = new sql();

$qry = array(); $qry['delete'] = "inventory"; $qry['where'][] = "uid=100"; $qry['limit'] = "3";

// build and execute query.. $database->build_delete($qry); if($database->query()) { echo "<p>deleted!</p>"; } else { echo "<p>not deleted!</p>"; }

Parameters:
array   $q: 

API Tags:
Return:  the compiled query


[ Top ]
build_insert  [line 689]

  string build_insert( array $q  )

A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()

Example 1:

// Initialize the sql object. $database = new sql();

$qry = array(); $qry['into'] = "employees"; $qry['value']['firstname'] = "Henk"; $qry['value']['lastname'] = "de Vries";

// build and execute query.. $database->build_insert($qry); if($database->query()) { echo "<p>updated!</p>"; } else { echo "<p>not updated!</p>"; }

Parameters:
array   $q: 

API Tags:
Return:  the compiled query


[ Top ]
build_select  [line 556]

  string build_select( array $q  )

A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()

Example 1:

// Initialize the sql object. $database = new sql();

// Simple select query instruction: $qry = array(); $qry['select'] = "*"; $qry['from'] = "employees"; $qry['where'][] = "firstname LIKE 'b%'";

// build and execute query.. $database->build_select($qry); $database->query();

$rows = $database->fetch_all_rows();

Example 2:

// Initialize the sql object. $database = new sql();

// Simple select query instruction: $qry = array(); $qry['select'] = "employees.*, inventory.*, computers.*"; $qry['from'] = "inventory"; $qry['leftjoin']['employees'] = "employees.uid = inventory.employee_uid"; $qry['leftjoin']['computers'] = "computers.uid = inventory.employee_uid"; $qry['limit'] = "3";

// build and execute query.. $database->build_select($qry); $database->query();

$rows = $database->fetch_all_rows();

Parameters:
array   $q: 

API Tags:
Return:  the compiled query


[ Top ]
build_update  [line 765]

  string build_update( array $q  )

A function to build select queries. After compiling the query it is stored internally, so we can use it when calling query()

Example 1:

// Initialize the sql object. $database = new sql();

$qry = array(); $qry['update'] = "inventory"; $qry['value']['amount'] = "(RAND())*100"; $qry['where'][] = "uid=100";

// build and execute query.. $database->build_update($qry); if($database->query()) { echo "<p>updated!</p>"; } else { echo "<p>not updated!</p>"; }

Parameters:
array   $q: 

API Tags:
Return:  the compiled query


[ Top ]
close  [line 169]

  void close( )

Close Mysql link



[ Top ]
connection  [line 73]

  void connection( )

Set up the Database connection, depending on the selected DB model.



[ Top ]
error  [line 199]

  void error( [string $error_msg = ""], string $sql_query, string $error_no  )

If an error has occured, we print a message. If 'halt_on_sql_error' is set, we die(), else we continue.

Parameters:
string   $error_msg: 
string   $sql_query: 
string   $error_no: 


[ Top ]
fetch_all_rows  [line 473]

  array fetch_all_rows( [string $getnames = "with_names"]  )

Fetch all rows from the last results.

Parameters:
string   $getnames: 

API Tags:
Return:  rows


[ Top ]
fetch_row  [line 443]

  array fetch_row( [string $getnames = "with_names"]  )

Fetch a single row from the last results.

Parameters:
string   $getnames: 

API Tags:
Return:  row


[ Top ]
get_last_id  [line 347]

  void get_last_id( none 0  )

Get the last inserted id

Parameters:
none   0: 


[ Top ]
get_last_query  [line 334]

  void get_last_query( none 0  )

Get the last performed or stored query

Parameters:
none   0: 


[ Top ]
get_server_info  [line 181]

  string get_server_info( )

Gets the current MySQL version



[ Top ]
is_mysqli_function  [line 909]

  boolean is_mysqli_function( string $str  )

Checks if the parameter is an mysql function or not. used to determine whether or not a parameter needs to be escaped.

$this->is_mysqli_function("some value"); // returns true

$this->is_mysqli_function("some value"); // returns true

Parameters:
string   $str:  string


[ Top ]
num_rows  [line 367]

  void num_rows( )

Gets the number of selected rows



[ Top ]
query  [line 251]

  void query( [string $query = ""]  )

Performs a query. Either pass the query to e executed as a parameter,

Parameters:
string   $query:  query


[ Top ]
query_count  [line 503]

  void query_count( )

Returns the number of executed queries



[ Top ]
quote  [line 408]

  string quote( string $value, [boolean $skipquotes = false]  )

Quote variable to make safe to use in a SQL query. If you pass $skipquotes as true, the string will just have added slashes, otherwise it will be wrapped in quotes for convenience

Parameters:
string   $value:  to quote
boolean   $skipquotes:  to skip adding quotes

API Tags:
Return:  quoted value


[ Top ]
set_allow_functions  [line 932]

  void set_allow_functions( boolean $value  )

Set if we're allowed to use MySQL functions in our queries. This is disabled by default, for security reasons.

Parameters:
boolean   $value: 


[ Top ]
set_halt_on_error  [line 944]

  void set_halt_on_error( boolean $value  )

Sets whether or not execution of the script should stop when a mysql error has occured.

Parameters:
boolean   $value:  value


[ Top ]

Documentation generated on Tue, 05 Sep 2017 01:06:11 +0200 by phpDocumentor 1.4.3