PhpToolCase
[ class tree: PhpToolCase ] [ index: PhpToolCase ] [ all elements ]

Class: PtcDb

Source Location: /workshop/PhpToolCase/current/PtcDb.php

Class PtcDb

Property Summary
string   $mySqlFlag   Mysql mode(MYSQL_BOTH,MYSQL_ASSOC,MYSQL_NUM)
array   $queryResults   Store query results in array

[ Top ]
Method Summary
returns   countRows()   Count rows of select query(based on reference)
void   dbClose()   Close link to DB
void   dbConnect()   Connect to database
returns   deleteRow()   Delete row from given table
returns   executeSql()   Execute sql statement and return result
returns   goFast()   Retrive value from given table based on 1 field
returns   insertRow()   Insert record from given table
returns   lastId()   Get last inerted id
returns   readRow()   Read 1 row from given table
returns   readTable()   Read records from given table
returns   sqlToArray()   Execute any select statement
returns   updateRow()   Update 1 record in given table
void   _cleanQuery()   Protect against sql injection
void   _queryFields()   Fields in the select statement WHERE clause

[ Top ]
Properties
string   $mySqlFlag = MYSQL_ASSOC [line 19]

Mysql mode(MYSQL_BOTH,MYSQL_ASSOC,MYSQL_NUM)

API Tags:
Access:  public

Information Tags:
Tutorial:  mySqlFlag Option

[ Top ]
array   $queryResults = array() [line 25]

Store query results in array

API Tags:
Access:  public

Information Tags:
Tutorial:  Using References

[ Top ]
Methods
countRows  [line 200]

  returns countRows( [string $ref = 0]  )

Count rows of select query(based on reference)

Parameters:
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  number rows from select statement
Access:  public

Information Tags:
Tutorial:  Count Rows

[ Top ]
dbClose  [line 216]

  void dbClose( [string $dbLink = null]  )

Close link to DB

Parameters:
string   $dbLink:  link resource

API Tags:
Access:  public

Information Tags:
Tutorial:  Closing The Connetion

[ Top ]
dbConnect  [line 35]

  void dbConnect( string $dbHost, string $dbUser, string $dbPass, [string $dbName = NULL], [string $dbCharset = NULL]  )

Connect to database

Parameters:
string   $dbHost:  address for mysql server
string   $dbUser:  user for mysql server
string   $dbPass:  password for mysql server
string   $dbName:  database name
string   $dbCharset:  charset to use

API Tags:
Access:  public

Information Tags:
Tutorial:  Connecting To Database

[ Top ]
deleteRow  [line 174]

  returns deleteRow( string $table, int $recordId, [string $ref = 0]  )

Delete row from given table

Parameters:
string   $table:  mysql table
int   $recordId:  the record id to be deleted
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  the sql reference.
Access:  public

Information Tags:
Tutorial:  Delete Row

[ Top ]
executeSql  [line 79]

  returns executeSql( string $sql, [string $ref = 0]  )

Execute sql statement and return result

Parameters:
string   $sql:  sql query to be returned
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  the sql reference.
Access:  public

Information Tags:
Tutorial:  ExecuteSql

[ Top ]
goFast  [line 188]

  returns goFast( string $table, string $key, string $value, [string $return = "id"]  )

Retrive value from given table based on 1 field

Parameters:
string   $table:  mysql table
string   $key:  table field name
string   $value:  the value to look for
string   $return:  the field to return

API Tags:
Return:  the value for the specified field,or null if query was empty
Access:  public

Information Tags:
Tutorial:  Retrieve only 1 Value

[ Top ]
insertRow  [line 124]

  returns insertRow( string $table, array $array, [string $ref = 0]  )

Insert record from given table

Parameters:
string   $table:  mysql table
array   $array:  query fields
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  the sql reference.
Access:  public

Information Tags:
Tutorial:  Insert Row

[ Top ]
lastId  [line 160]

  returns lastId( )

Get last inerted id


API Tags:
Return:  last inserted id
Access:  public

Information Tags:
Tutorial:  Last Inserted Id

[ Top ]
readRow  [line 95]

  returns readRow( string $table, array|string $fields, [string $ref = 0]  )

Read 1 row from given table

Parameters:
string   $table:  mysql table
array|string   $fields:  query fields
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  an array with values or null if query is empty.
Access:  public

Information Tags:
Tutorial:  Read Row

[ Top ]
readTable  [line 111]

  returns readTable( string $table, [array|string $fields = null], [string $order = null], [string $limit = null], [string $ref = 0]  )

Read records from given table

Parameters:
string   $table:  mysql table
array|string   $fields:  query fields
string   $order:  order records
string   $limit:  limit number of records
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  a multidimensional array or null if query is empty
Access:  public

Information Tags:
Tutorial:  Read Table

[ Top ]
sqlToArray  [line 62]

  returns sqlToArray( string $sql, [string $ref = 0]  )

Execute any select statement

Parameters:
string   $sql:  sql query to be returned
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  a 2 dimensions array with values or null if query is empty
Access:  public

Information Tags:
Tutorial:  SqlToArray

[ Top ]
updateRow  [line 147]

  returns updateRow( string $table, array $array, int $recordId, [string $ref = 0]  )

Update 1 record in given table

Parameters:
string   $table:  mysql table
array   $array:  array of values to update
int   $recordId:  the record id to be updated
string   $ref:  gives a reference to the resource. See Using References

API Tags:
Return:  the sql reference.
Access:  public

Information Tags:
Tutorial:  Update Row

[ Top ]
_cleanQuery  [line 231]

  void _cleanQuery( string $string  )

Protect against sql injection

Parameters:
string   $string:  clean values before sql query(prevent sql injection)

API Tags:
Access:  protected


[ Top ]
_queryFields  [line 242]

  void _queryFields( array|string $fields  )

Fields in the select statement WHERE clause

Parameters:
array|string   $fields:  query fields

API Tags:
Access:  protected


[ Top ]

Documentation generated on Fri, 30 Aug 2013 15:28:57 +0200 by phpDocumentor 1.4.3