ptb_merge
Connects to a $filename and "juxtaposes" table from it to the $database (ie. adds its fields). First columns of both tables must be equal (usually it will be ids). If $database is not an array, the other one (being juxtaposed) is returned. If the other (from $filename) isn't, $database is returned.
Syntax
$var = ptb_merge($database, $filename[, $location = PTB_DEFAULT_DB_LOCATION[, $keyField = '']]);
Syntax description
- $database
- connected database
- $filename
- name of file containing the second table
- $location
- optional: location of $filename; can be:
- G
- globally defined (in ptb_ini.php) directory
- L
- local directory (ie. the same where script calling ptb_connect is placed)
- <path>
- other, defined directory, eg. /samples/db (no trailing slash)
- F
- filename (ie. absolute or relative path without DOCUMENT_ROOT dependency)
- $keyField
- optional: name of field to be used as main key; use if $database was connected with $keyField, for details see ptb_connect
Return
This function returns array (unless both aren't arrays, then null).
Sample(s)
$myDatabase = ptb_merge($myDatabase, 'otherdbase.csv', 'L');