Development » API Functions » Database Functions

Etomite API - database related functions

Etomite database - access and update 

getIntTableRows($fields="*", $from="", $where="", $sort="", $dir="ASC", $limit="", $push=true)

  // function to get rows from ANY internal database table
  // This function works much the same as the getDocuments() function. The main differences are that it will accept a table name and can use a LIMIT clause.
  // $fields = a comma delimited string: $fields="name,email,age"
  // $from = name of the internal Etomite table which data will be selected from without database name or table prefix ($from="user_messages")
  // $where = any optional WHERE clause: $where="parent=10 AND published=1 AND type='document'"
  // $sort = field you wish to sort by: $sort="id"
  // $dir = ASCending or DESCending sort order
  // $limit = maximum results returned: $limit="3" or $limit="10,3"
  // $push = ( true = [default] array_push results into a multi-demensional array | false = return MySQL resultset )
  // Returns FALSE on failure.

putIntTableRow($fields="", $into="")

  // function to put a row into ANY internal database table
  // INSERT's a new table row into ANY internal Etomite database table. No data validation is performed.
  // $fields = a $key=>$value array: $fields=("name"=>$name,"email"=$email,"age"=>$age)
  // $into = name of the internal Etomite table which will receive the new data row without database name or table prefix: $into="user_messages"
  // Returns FALSE on failure. 

updIntTableRows($fields="", $into="", $where="", $sort="", $dir="ASC", $limit="")

  // function to update a row into ANY internal database table
  // $fields = a $key=>$value array: $fields=("name"=>$name,"email"=$email,"age"=>$age)
  // $into = name of the internal Etomite table which will receive the new data row without database name or table prefix: $into="user_messages"
  // $where = any optional WHERE clause: $where="parent=10 AND published=1 AND type='document'"
  // $sort = field you wish to sort by: $sort="id"
  // $dir = ASCending or DESCending sort order
  // $limit = maximum results returned: $limit="3" or $limit="10,3"
  // Returns FALSE on failure.

External Database - access and update

getExtTableRows($host="", $user="", $pass="", $dbase="", $fields="*", $from="", $where="", $sort="", $dir="ASC", $limit="", $push=true)

  // function to get table rows from an external MySQL database
  // Performance is identical to getIntTableRows plus additonal information regarding the external database.
  // $host is the hostname where the MySQL database is located: $host="localhost"
  // $user is the MySQL username for the external MySQL database: $user="username"
  // $pass is the MySQL password for the external MySQL database: $pass="password"
  // $dbase is the MySQL database name to which you wish to connect: $dbase="extdata"
  // $fields should be a comma delimited string: $fields="name,email,age"
  // $from is the name of the External database table that data rows will be selected from: $from="contacts"
  // $where can be any optional WHERE clause: $where="parent=10 AND published=1 AND type='document'"
  // $sort can be set to whichever field you wish to sort by: $sort="id"
  // $dir can be set to ASCending or DESCending sort order
  // $limit can be set to limit results returned: $limit="3" or $limit="10,3"
  // $push = ( true = [default] array_push results into a multi-demensional array | false = return MySQL resultset )
  // Returns FALSE on failure.

putExtTableRow($host="", $user="", $pass="", $dbase="", $fields="", $into="")

  // function to update a row into an external database table
  // $host = hostname where the MySQL database is located: $host="localhost"
  // $user = MySQL username for the external MySQL database: $user="username"
  // $pass = MySQL password for the external MySQL database: $pass="password"
  // $dbase = MySQL database name to which you wish to connect: $dbase="extdata"
  // $fields = a $key=>$value array: $fields=("name"=>$name,"email"=$email,"age"=>$age)
  // $into = name of the external database table which will receive the new data row: $into="contacts"
  // $where = optional WHERE clause: $where="parent=10 AND published=1 AND type='document'"
  // $sort = whichever field you wish to sort by: $sort="id"
  // $dir = ASCending or DESCending sort order
  // $limit = limit maximum results returned: $limit="3" or $limit="10,3"
  // Returns FALSE on failure.

updExtTableRows($host="", $user="", $pass="", $dbase="", $fields="", $into="", $where="", $sort="", $dir="ASC", $limit="")

  // function to put a row into an external database table
  // INSERT's a new table row into an external database table. No data validation is performed.
  // $host = hostname where the MySQL database is located: $host="localhost"
  // $user = MySQL username for the external MySQL database: $user="username"
  // $pass = MySQL password for the external MySQL database: $pass="password"
  // $dbase = MySQL database name to which you wish to connect: $dbase="extdata"
  // $fields = a $key=>$value array: $fields=("name"=>$name,"email"=$email,"age"=>$age)
  // $into = name of the external database table which will receive the new data row: $into="user_messages"
  // Returns FALSE on failure.

dbExtConnect($host, $user, $pass, $dbase)

  // function used to connect to external database
  // This function is called by other functions and should not need to be called directly.
  // $host = hostname where the MySQL database is located: $host="localhost"
  // $user = MySQL username for the external MySQL database: $user="username"
  // // $pass = MySQL password for the external MySQL database: $pass="password"
  // $dbase = MySQL database name to which you wish to connect: $dbase="extdata"

dbExtQuery($host, $user, $pass, $dbase, $query)

  // function to query an external database
  // This function can be used to perform queries on any external MySQL database.
  // $host = hostname where the MySQL database is located: $host="localhost"
  // $user = MySQL username for the external MySQL database: $user="username"
  // $pass = MySQL password for the external MySQL database: $pass="password"
  // $dbase = MySQL database name to which you wish to connect: $dbase="extdata"
  // $query = SQL query to be performed: $query="DELETE FROM sometable WHERE somefield='somevalue';"
  // Returns error on fialure.

Database - data handling

getFormVars($method="", $prefix="", $trim="", $REQUEST_METHOD)

  // function to retrieve form results into an associative $key=>$value array
  // This function is intended to be used to retrieve an associative $key=>$value array of form data which can be sent directly to the putIntTableRow() or putExttableRow() functions. This function performs no data validation. By utilizing $prefix it is possible to // retrieve groups of form results which can be used to populate multiple database tables. This funtion does not contain multi-record form capabilities.
  // $method = form method which can be POST or GET and is not case sensitive: $method="POST"
  // $prefix = used to specifiy prefixed groups of form variables so that a single form can be used to populate multiple database // tables. If $prefix is omitted all form fields will be returned: $prefix="frm_"
  // $trim = boolean value ([true or 1]or [false or 0]) which tells the function whether to trim off the field prefixes for a group // resultset
  // $RESULT_METHOD is sent so that if $method is omitted the function can determine the form method internally. This system variable cannot be assigned a user-specified value.
  // Returns FALSE if form method cannot be determined

arrayValuesToList($rs,$col)

  // Converts a column of a resultset array into a comma delimited list (col,col,col)
  // $rs = query resultset OR an two dimensional associative array
  // $col = the target column to compile into a comma delimited string
  // Returns error on fialure.

mergeCodeVariables($content="", $rs="", $prefix="{",$suffix="}", $oddStyle="", $evenStyle="", $tag="div")

  //  parses any string data for template tags and populates from a resultset or single associative array
  //  $content = the string data to be parsed
  //  $rs = the resultset or associateve array which contains the data to check for possible insertion
  //  $prefix & $suffix = the tags start and end characters for search and replace purposes
  //  $oddStyle & $evenStyle = CSS info sent as style='inline styles' or class='className'
  //  $tag = the HTML tag to use as a container for each template object record

makeList($array, $ulroot='root', $ulprefix='sub_', $type='', $ordered=false, $tablevel=0, $tabstr='t')

  // returns either ordered or unordered lists based on passed parameters
  // $array can be a single or multi-dimensional $key=>$value array
  // $ulroot is the lists root CSS class name for controlling list-item appearance
  // $ulprefix is the prefix to send with recursive calls to this function
  // $type can be used to specifiy the type of the list-item marker (examples:disc,square,decimal,upper-roman,etc...)
  // $ordered determines whether the list is alphanumeric or symbol based (true=alphanumeric|false=symbol)
  // $tablevel is an internally used variable for determining depth of indentation on recursion
  // $tabstr can be used to send an alternative indentation string in place of the default tab character (added in 0.6.1 RTM)


Hosting Costs Generously Provided By:
Hydraulikservice | Link Text 2 | Link Text 3 | Link Text 4 | Link Text 5
Link Text 6 | Link Text 7 | Link Text 8 | Link Text 9 | Link Text 10