tce_db_dal_postgresql.php

PostgreSQL driver for TCExam Database Abstraction Layer (DAL).

Source: shared/code/tce_db_dal_postgresql.php

PostgreSQL driver for TCExam Database Abstraction Layer (DAL). This abstraction layer uses the same SQL syntax of MySQL.

Functions

F_db_affected_rows()

Returns number of rows (tuples) affected by the last INSERT, UPDATE or DELETE query associated with link_identifier.

function F_db_affected_rows(mixed $link_identifier, mixed $result): Number

Parameters:

  • $link_identifier (mixed): (resource) database link identifier [UNUSED].
  • $result (mixed): (resource) result resource to the query result.

Returns: Number: of rows.

Source: shared/code/tce_db_dal_postgresql.php:125

F_db_close()

Closes the non-persistent connection to a database associated with the given connection resource.

function F_db_close(mixed $link_identifier): bool

Parameters:

  • $link_identifier (mixed): (resource) database link identifier.

Returns: bool: TRUE on success or FALSE on failure

Source: shared/code/tce_db_dal_postgresql.php:69

F_db_connect()

Open a connection to a PostgreSQL Server and select a database.

If a second call is made to this function with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned.

function F_db_connect(
    mixed $host = 'localhost',
    mixed $port = '5432',
    mixed $username = 'postgres',
    mixed $password = '',
    mixed $database = 'template1'
): PostgreSQL

Parameters:

  • $host (mixed): (string) database server host name.
  • $port (mixed): (string) database connection port
  • $username (mixed): (string) Name of the user that owns the server process.
  • $password (mixed): (string) Password of the user that owns the server process.
  • $database (mixed): (string) Database name.

Returns: PostgreSQL: link identifier on success, or FALSE on failure.

Source: shared/code/tce_db_dal_postgresql.php:37

F_db_datetime_diff_seconds()

Returns the SQL string to calculate the difference in seconds between to datetime fields.

function F_db_datetime_diff_seconds(mixed $start_date_field, mixed $end_date_field): SQL

Parameters:

  • $start_date_field (mixed)
  • $end_date_field (mixed)

Returns: SQL: query string

Source: shared/code/tce_db_dal_postgresql.php:165

F_db_error()

Returns the text of the error message from previous database operation

function F_db_error(mixed $link_identifier = null): string

Parameters:

  • $link_identifier (mixed)

Returns: string: error message.

Source: shared/code/tce_db_dal_postgresql.php:78

F_db_fetch_array()

Fetch a result row as an associative and numeric array.

Note: This function sets NULL fields to PHP NULL value.

function F_db_fetch_array(mixed $result): Returns

Parameters:

  • $result (mixed): (resource) result resource to the query result.

Returns: Returns: an array that corresponds to the fetched row, or FALSE if there are no more rows.

Source: shared/code/tce_db_dal_postgresql.php:103

F_db_fetch_assoc()

Fetch a result row as an associative array.

Note: This function sets NULL fields to PHP NULL value.

function F_db_fetch_assoc(mixed $result): Returns

Parameters:

  • $result (mixed): (resource) result resource to the query result.

Returns: Returns: an array that corresponds to the fetched row, or FALSE if there are no more rows.

Source: shared/code/tce_db_dal_postgresql.php:114

F_db_insert_id()

Get the ID generated from the previous INSERT operation

function F_db_insert_id(
    mixed $link_identifier,
    mixed $tablename = '',
    mixed $fieldname = ''
): int

Parameters:

  • $link_identifier (mixed): (resource) database link identifier.
  • $tablename (mixed): (string) Table name.
  • $fieldname (mixed): (string) Field name (column name).

Returns: int: ID generated from the last INSERT operation.

Source: shared/code/tce_db_dal_postgresql.php:147

F_db_num_rows()

Get number of rows in result.

function F_db_num_rows(mixed $result): Number

Parameters:

  • $result (mixed): (resource) result resource to the query result.

Returns: Number: of affected rows.

Source: shared/code/tce_db_dal_postgresql.php:135

F_db_query()

Sends a query to the currently active database on the server that’s associated with the specified link identifier.<br> NOTE: Convert MySQL RAND() function to PostgreSQL RANDOM() on ORDER BY clause of selection queries.

function F_db_query(mixed $query, mixed $link_identifier): false

Parameters:

  • $query (mixed): (string) The query tosend. The query string should not end with a semicolon.
  • $link_identifier (mixed): (resource) database link identifier.

Returns: false: in case of error, TRUE or resource-identifier in case of success.

Source: shared/code/tce_db_dal_postgresql.php:90

F_escape_sql()

Escape a string for insertion into a SQL text field (avoiding SQL injection).

function F_escape_sql(mixed $link_identifier, mixed $str, mixed $stripslashes = true): string

Parameters:

  • $link_identifier (mixed): (resource) database link identifier.
  • $str (mixed): (string) The string that is to be escaped.
  • $stripslashes (mixed): (boolean) if true strip slashes from string

Returns: string: Returns the escaped string, or FALSE on error.

Source: shared/code/tce_db_dal_postgresql.php:178