FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
This file contains common database functions. More...
Go to the source code of this file.
Functions | |
DBconnect ($sysconfdir, $options="", $exitOnFail=true) | |
Connect to database engine. This is a no-op if $PG_CONN already has a value. More... | |
GetSingleRec ($Table, $Where="") | |
Retrieve a single database record. More... | |
DB2KeyValArray ($Table, $KeyCol, $ValCol, $Where="") | |
Create an associative array by using table rows to source the key/value pairs. More... | |
DB2ValArray ($Table, $ValCol, $Uniq=false, $Where="") | |
Create an array by using table rows to source the values. More... | |
DBCheckResult ($result, $sql, $filenm, $lineno) | |
Check the postgres result for unexpected errors. If found, treat them as fatal. More... | |
DB_TableExists ($tableName) | |
Check if table exists. More... | |
DB_ColExists ($tableName, $colName, $DBName='fossology') | |
Check if a column exists. More... | |
DB_ConstraintExists ($ConstraintName, $DBName='fossology') | |
Check if a constraint exists. More... | |
GetLastSeq ($seqname, $tablename) | |
Get last sequence number. More... | |
This file contains common database functions.
Definition in file common-db.php.
DB2KeyValArray | ( | $Table, | |
$KeyCol, | |||
$ValCol, | |||
$Where = "" |
|||
) |
Create an associative array by using table rows to source the key/value pairs.
string | $Table | tablename |
string | $KeyCol | Key column name in $Table |
string | $ValCol | Value column name in $Table |
string | $Where | SQL where clause (optional) This can really be any clause following the table name in the sql |
Definition at line 121 of file common-db.php.
DB2ValArray | ( | $Table, | |
$ValCol, | |||
$Uniq = false , |
|||
$Where = "" |
|||
) |
Create an array by using table rows to source the values.
string | $Table | tablename |
string | $ValCol | Value column name in $Table |
string | $Uniq | Sort out duplicates |
string | $Where | SQL where clause (optional) This can really be any clause following the table name in the sql |
Definition at line 153 of file common-db.php.
DB_ColExists | ( | $tableName, | |
$colName, | |||
$DBName = 'fossology' |
|||
) |
Check if a column exists.
string | $tableName | Table to check in |
string | $colName | Column to check |
string | $DBName | Database name, default "fossology" |
Definition at line 240 of file common-db.php.
DB_ConstraintExists | ( | $ConstraintName, | |
$DBName = 'fossology' |
|||
) |
Check if a constraint exists.
string | $ConstraintName | Constraint to check |
string | $DBName | Database name, default "fossology" |
Definition at line 264 of file common-db.php.
DB_TableExists | ( | $tableName | ) |
Check if table exists.
string | $tableName | Table to check |
Definition at line 214 of file common-db.php.
DBCheckResult | ( | $result, | |
$sql, | |||
$filenm, | |||
$lineno | |||
) |
Check the postgres result for unexpected errors. If found, treat them as fatal.
$result | command result object | |
string | $sql | SQL command (optional) |
string | $filenm | File name (FILE) |
int | $lineno | Line number of the caller (LINE) |
Definition at line 187 of file common-db.php.
DBconnect | ( | $sysconfdir, | |
$options = "" , |
|||
$exitOnFail = true |
|||
) |
Connect to database engine. This is a no-op if $PG_CONN already has a value.
string | $sysconfdir | fossology configuration directory (location of Db.conf) |
string | $options | an optional list of attributes for connecting to the database. E.g.: "dbname=text host=text user=text password=text" |
bool | $exitOnFail | true (default) to print error and call exit on failure false to return $PG_CONN === false on failure |
If $options is empty, then connection parameters will be read from Db.conf.
Definition at line 33 of file common-db.php.
GetLastSeq | ( | $seqname, | |
$tablename | |||
) |
Get last sequence number.
This is typically used to get the primary key of a newly inserted record. This must be called immediately after the insert.
string | $seqname | Sequence Name of key just added |
string | $tablename | Table containing $seqname |
Definition at line 293 of file common-db.php.
GetSingleRec | ( | $Table, | |
$Where = "" |
|||
) |
Retrieve a single database record.
This function does a:
and returns the result as an associative array.
string | $Table | Table name |
string | $Where | SQL where clause e.g. "where uploadtree_pk=2" . Though a WHERE clause is the typical use, $Where can really be any options following the sql tablename. |
Definition at line 91 of file common-db.php.