mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-54947 database: Update PostgreSQL binary handling.
PostgreSQL 9.1 allows hex formating for binary which is handled better by pg_query_params(). Getting bytea isn't required on connection, it can be used as pg_field_type() when binary needs to be checked.
This commit is contained in:
parent
b8474fe0c7
commit
1b0b082a08
3 changed files with 70 additions and 172 deletions
|
@ -38,18 +38,21 @@ class pgsql_native_moodle_recordset extends moodle_recordset {
|
|||
protected $result;
|
||||
/** @var current row as array.*/
|
||||
protected $current;
|
||||
protected $bytea_oid;
|
||||
protected $blobs = array();
|
||||
|
||||
public function __construct($result, $bytea_oid) {
|
||||
$this->result = $result;
|
||||
$this->bytea_oid = $bytea_oid;
|
||||
/**
|
||||
* Build a new recordset to iterate over.
|
||||
*
|
||||
* @param resource $result A pg_query() result object to create a recordset from.
|
||||
*/
|
||||
public function __construct($result) {
|
||||
$this->result = $result;
|
||||
|
||||
// find out if there are any blobs
|
||||
$numrows = pg_num_fields($result);
|
||||
for($i=0; $i<$numrows; $i++) {
|
||||
$type_oid = pg_field_type_oid($result, $i);
|
||||
if ($type_oid == $this->bytea_oid) {
|
||||
// Find out if there are any blobs.
|
||||
$numfields = pg_num_fields($result);
|
||||
for ($i = 0; $i < $numfields; $i++) {
|
||||
$type = pg_field_type($result, $i);
|
||||
if ($type == 'bytea') {
|
||||
$this->blobs[] = pg_field_name($result, $i);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue