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

Class: Execute

Source Location: /myphp-1.9/myphp-1.9-db/html/mysql/Execute.php

Class Execute

Class Overview

Used to perform a query against the database

DROP, CREATE, INSERT, UPDATE or REPLACE The data are comming from a form-POST command or through an external array of post data

  1. Usage:
  2. $execute = new Execute($table,$command,$id,$comment,$type);
  3. $rc = $execute->drop();
  4. $rc = $execute->create($extSql);
  5. $rc = $execute->insert($params);
  6. $rc = $execute->replace($params);
  7. $rc = $execute->update($params);
  8. $rc = $execute->delete($sid);
  9. $rc = $execute->getCount();
  10. $rc = $execute->updateBasket();
  11. $rc = $execute->getLastInsertId();
  12. $rc = $execute->printError();

Located in /myphp-1.9/myphp-1.9-db/html/mysql/Execute.php [line 43]

Object
   |
   --DatabaseCommon
      |
      --Database
         |
         --Execute
Author(s):
Information Tags:
Todo:  getLastInsertId() is NOT threadsafe

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Database

Database::$affectedRows
Database::$numRows
Database::$row
Database::$sql

Inherited From DatabaseCommon

DatabaseCommon::$connection
DatabaseCommon::$result

Inherited From Object

Object::$cachefile
Object::$html

Inherited From Database

Database::Database()
Constructor
Database::fetchArray()
Fetch the result of the query
Database::fetchAssoc()
Fetch the result of the query
Database::fetchObject()
Fetch the result of the query
Database::fetchRow()
Fetch one row of data from the result associated with the specified result identifier
Database::getAffectedRows()
Get the affected rows
Database::getFieldFlags()
Get the flags associated with the specified field in a result
Database::getFieldLen()
Get the length of the specified field
Database::getFieldName()
Get the name of the specified field in a result
Database::getFieldTable()
Get name of the table the specified field is in
Database::getFieldType()
Get the type of the specified field in a result
Database::getInsertId()
Return the ID generated for the INSERT statement for an AUTO_INCREMENT type
Database::getNumFields()
Returns the number of fields in the result
Database::getNumRows()
Get the number of rows
Database::query()
Execute the specified query. SELECT, UPDATE, INSERT etc...

Inherited From DatabaseCommon

DatabaseCommon::DatabaseCommon()
Constructor
DatabaseCommon::close()
Close the connection to the database
DatabaseCommon::freeResult()
Free the resources
DatabaseCommon::getError()
Get the error message
DatabaseCommon::open()
Connect to the host, and select the database to use
DatabaseCommon::set()
Set the named attribute of a class as: $this->key = $value

Inherited From Object

Object::Object()
Constructor
Object::addHtml()
Add the current html to the SourceCode object
Object::getCacheFileName()
Returns the name of the cache file name
Object::getClassName()
Returns the name of the instanciated class
Object::getHtml()
Returns the html for the element
Object::getMsg()
Get the formatted message and debug level and Log to file ?
Object::save()
Save the SQL cache file
Object::setCacheFileName()
Set the path/name of the cache file
Object::toString()
Returns the information for this class
Object::write()
Write the content to the file opened by fp

[ Top ]
Property Summary
mixed   $command  
mixed   $id  
mixed   $keys  
mixed   $keysvalues  
mixed   $table  
mixed   $values  

[ Top ]
Method Summary
Execute   Execute()   Constructor
void   buildInsert()   Builds the key/value pairs for the INSERT/REPLACE query
void   buildRow()   Builds the row for the INSERT/REPLACE query
void   buildUpdate()   Builds the key/value pairs for UPDATE the query
boolean   create()   Perform the query: CREATE table ( $extSql ) TYPE=MyISAM
boolean   delete()   Perform the query: DELETE FROM table WHERE ...
boolean   drop()   Perform the query: DROP table IF EXISTS ...
int   getCount()   Perform the query: SELECT count(table_id) FROM table [WHERE $key=$value] ...
int   getLastInsertId()   Perform the query: SELECT last_insert_id();
array   getParams()   Return the POST/GET params or the supplied request array
boolean   insert()   Perform the query: INSERT INTO table (keys) VALUES (values)...
void   parse()   Parses the $_POST in order to create the key/value pairs ...
String   printError()   Print an error message and other information
boolean   replace()   Perform the query: REPLACE INTO table (keys) VALUES (values)...
boolean   skip()   Checks the key, value pairs, if part of the post query
boolean   update()   Perform the query: UPDATE table SET ... WHERE ID=$id
boolean   updateBasket()   Perform specialized Basket query: UPDATE basket SET ... WHERE

[ Top ]
Properties
mixed   $command = '' [line 45]

[ Top ]
mixed   $id = '' [line 46]

[ Top ]
mixed   $keys = '' [line 49]

[ Top ]
mixed   $keysvalues = '' [line 51]

[ Top ]
mixed   $table = '' [line 44]

[ Top ]
mixed   $values = '' [line 50]

[ Top ]
Methods
Constructor Execute  [line 59]

  Execute Execute( String $table, [String $command = ''], [String $id = '']  )

Constructor

Parameters:
String   $table:  The Table to query. Note: The name is scrampled
String   $command:  The command to execute
String   $id:  The primary key


[ Top ]
buildInsert  [line 481]

  void buildInsert( array $row, array $rows  )

Builds the key/value pairs for the INSERT/REPLACE query

Parameters:
array   $row:  The row of keys to use
array   $rows:  One or more rows of values to use


[ Top ]
buildRow  [line 503]

  void buildRow( array $row  )

Builds the row for the INSERT/REPLACE query

Parameters:
array   $row:  The row of keys to use


[ Top ]
buildUpdate  [line 515]

  void buildUpdate( array $row  )

Builds the key/value pairs for UPDATE the query

Parameters:
array   $row:  The row of key value pairs to use


[ Top ]
create  [line 98]

  boolean create( String $extSql, [String $comment = ''], [String $type = 'MyISAM']  )

Perform the query: CREATE table ( $extSql ) TYPE=MyISAM

Parameters:
String   $extSql:  The external definitions of fields
String   $comment:  The Table comment
String   $type:  The Table type

API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]
delete  [line 220]

  boolean delete( [mixed $sid = ''], String $name  )

Perform the query: DELETE FROM table WHERE ...

Parameters:
String   $name:  The table_name, if present, overrules the table_id

API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]
drop  [line 70]

  boolean drop( )

Perform the query: DROP table IF EXISTS ...


API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]
getCount  [line 258]

  int getCount( [String $key = ''], [String $value = '']  )

Perform the query: SELECT count(table_id) FROM table [WHERE $key=$value] ...

Parameters:
String   $key:  Optional where key
String   $value:  Optional where value

API Tags:
Return:  The number of rows, FALSE if failure


[ Top ]
getLastInsertId  [line 357]

  int getLastInsertId( )

Perform the query: SELECT last_insert_id();


API Tags:
Return:  The last inserted auto increment value on succes, otherwise 0 on error

Information Tags:
Todo:  NOT Threadsafe !!! mySQL specific

[ Top ]
getParams  [line 408]

  array getParams( [array $params = '']  )

Return the POST/GET params or the supplied request array

The search order is: $param > $_POST > $_GET

Parameters:
array   $params:  The params to use

API Tags:
Return:  The request array


[ Top ]
insert  [line 130]

  boolean insert( [array $params = ''], [int $insert = DATABASE_EXECUTE_INSERT]  )

Perform the query: INSERT INTO table (keys) VALUES (values)...

Parameters:
array   $params:  An optionally key/value array, default $_POST
int   $insert:  INSERT (default) or REPLACE

API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]
parse  [line 428]

  void parse( [boolean $type = DATABASE_EXECUTE_INSERT], [array $params = '']  )

Parses the $_POST in order to create the key/value pairs ...

Skip the keywords: PROJECT, PAGE, COMMAND and TABLE and ID The function does also handles multiple rows like add rows to basket

Parameters:
boolean   $type:  either Insert, Replace (FALSE) or Update (TRUE)
array   $params:  An optionally key/value array, default $_POST


[ Top ]
printError  [line 380]

  String printError( [String $text = ''], [String $sql = '']  )

Print an error message and other information

Parameters:
String   $text:  Error message to print
String   $sql:  The sql query in question

API Tags:
Return:  The error message


[ Top ]
replace  [line 169]

  boolean replace( [array $params = '']  )

Perform the query: REPLACE INTO table (keys) VALUES (values)...

Parameters:
array   $params:  An optionally key/value array, default $_POST

API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]
skip  [line 528]

  boolean skip( String $key, String $value  )

Checks the key, value pairs, if part of the post query

Skip the keywords: COMMAND, TABLE, ID, PROJECT, PAGE, table_id

Parameters:
String   $key:  The key to check
String   $value:  The value to check

API Tags:
Return:  TRUE, if continue for next search


[ Top ]
update  [line 178]

  boolean update( [array $params = '']  )

Perform the query: UPDATE table SET ... WHERE ID=$id

Parameters:
array   $params:  An optionally key/value array, default $_POST

API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]
updateBasket  [line 305]

  boolean updateBasket( [array $params = '']  )

Perform specialized Basket query: UPDATE basket SET ... WHERE

  1. The Basket quantity field has the following format:
  2. <input type="text" name="quantity[$id]" value="$thedata" .../>

Parameters:
array   $params:  An optionally key/value array, default $_POST

API Tags:
Return:  TRUE on success and FALSE on error


[ Top ]

Documentation generated on Thu, 22 Dec 2005 17:07:56 +0100 by phpDocumentor 1.3.0RC3