changes until now.
Dieser Commit ist enthalten in:
Ursprung
9abf56d95f
Commit
642f0ffe29
|
@ -173,7 +173,7 @@ class DB_Sql extends DB_Sql_Abstract {
|
||||||
$this->Row = 0;
|
$this->Row = 0;
|
||||||
$this->Errno = $this->_getErrorNumber();
|
$this->Errno = $this->_getErrorNumber();
|
||||||
$this->Error = $this->_getErrorMessage();
|
$this->Error = $this->_getErrorMessage();
|
||||||
if (!$this->Query_ID) {
|
if (!is_resource($this->Query_ID)) {
|
||||||
$this->halt($sQuery);
|
$this->halt($sQuery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,9 @@ class DB_Sql extends DB_Sql_Abstract {
|
||||||
* @see DB_Sql_Abstract::next_record()
|
* @see DB_Sql_Abstract::next_record()
|
||||||
*/
|
*/
|
||||||
public function next_record() {
|
public function next_record() {
|
||||||
|
if (!$this->Query_ID instanceof mysqli_result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$this->Record = mysqli_fetch_array($this->Query_ID, MYSQLI_BOTH);
|
$this->Record = mysqli_fetch_array($this->Query_ID, MYSQLI_BOTH);
|
||||||
$this->Row += 1;
|
$this->Row += 1;
|
||||||
$this->Errno = $this->_getErrorNumber();
|
$this->Errno = $this->_getErrorNumber();
|
||||||
|
@ -323,74 +326,87 @@ class DB_Sql extends DB_Sql_Abstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DB_Sql_Abstract::_metaData()
|
* @see DB_Sql_Abstract::_metaData()
|
||||||
|
* * Due to compatibility problems with Table we changed the behavior
|
||||||
|
* of metadata();
|
||||||
|
* depending on $full, metadata returns the following values:
|
||||||
|
*
|
||||||
|
* - full is false (default):
|
||||||
|
* $result[]:
|
||||||
|
* [0]["table"] table name
|
||||||
|
* [0]["name"] field name
|
||||||
|
* [0]["type"] field type
|
||||||
|
* [0]["len"] field length
|
||||||
|
* [0]["flags"] field flags
|
||||||
|
*
|
||||||
|
* - full is true
|
||||||
|
* $result[]:
|
||||||
|
* ["num_fields"] number of metadata records
|
||||||
|
* [0]["table"] table name
|
||||||
|
* [0]["name"] field name
|
||||||
|
* [0]["type"] field type
|
||||||
|
* [0]["len"] field length
|
||||||
|
* [0]["flags"] field flags
|
||||||
|
* ["meta"][field name] index of field named "field name"
|
||||||
|
* This last one could be used if you have a field name, but no index.
|
||||||
|
* Test: if (isset($result['meta']['myfield'])) { ...
|
||||||
*/
|
*/
|
||||||
protected function _metaData($table = '', $full = false) {
|
protected function _metaData($table = '', $full = false) {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$id = 0;
|
$id = 0;
|
||||||
$res = array();
|
$res = array();
|
||||||
|
|
||||||
/*
|
|
||||||
* Due to compatibility problems with Table we changed the behavior
|
|
||||||
* of metadata();
|
|
||||||
* depending on $full, metadata returns the following values:
|
|
||||||
*
|
|
||||||
* - full is false (default):
|
|
||||||
* $result[]:
|
|
||||||
* [0]["table"] table name
|
|
||||||
* [0]["name"] field name
|
|
||||||
* [0]["type"] field type
|
|
||||||
* [0]["len"] field length
|
|
||||||
* [0]["flags"] field flags
|
|
||||||
*
|
|
||||||
* - full is true
|
|
||||||
* $result[]:
|
|
||||||
* ["num_fields"] number of metadata records
|
|
||||||
* [0]["table"] table name
|
|
||||||
* [0]["name"] field name
|
|
||||||
* [0]["type"] field type
|
|
||||||
* [0]["len"] field length
|
|
||||||
* [0]["flags"] field flags
|
|
||||||
* ["meta"][field name] index of field named "field name"
|
|
||||||
* This last one could be used if you have a field name, but no index.
|
|
||||||
* Test: if (isset($result['meta']['myfield'])) { ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
// if no $table specified, assume that we are working with a query
|
// if no $table specified, assume that we are working with a query
|
||||||
// result
|
// result
|
||||||
if ($table) {
|
if (!empty($table)) {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
$id = mysqli_query($this->Link_ID, sprintf("SELECT * FROM `%s` LIMIT 1", $table));
|
$id = mysqli_query($this->Link_ID, sprintf("SELECT * FROM `%s` LIMIT 1", $table));
|
||||||
if (!$id) {
|
if (!is_resource($id)) {
|
||||||
$this->halt('Metadata query failed.');
|
$this->halt('Metadata query failed.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//var_dump($this->Query_ID);
|
||||||
$id = $this->Query_ID;
|
$id = $this->Query_ID;
|
||||||
if (!$id) {
|
if (!$id instanceof mysqli_result) {
|
||||||
|
echo "back";
|
||||||
$this->halt('No query specified.');
|
$this->halt('No query specified.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = mysqli_num_fields($id);
|
//$count = mysqli_num_fields($id);
|
||||||
|
|
||||||
// made this IF due to performance (one if is faster than $count if's)
|
/*
|
||||||
for ($i = 0; $i < $count; $i ++) {
|
// made this IF due to performance (one if is faster than $count if's)
|
||||||
$finfo = mysqli_fetch_field($id);
|
for ($i = 0; $i < $count; $i ++) {
|
||||||
if (is_object($finfo)) {
|
$finfo = mysqli_fetch_field($id);
|
||||||
$res[$i]['table'] = $finfo->table;
|
$res[$i]['table'] = $finfo->table;
|
||||||
$res[$i]['name'] = $finfo->name;
|
$res[$i]['name'] = $finfo->name;
|
||||||
$res[$i]['type'] = $this->_aDataTypes[$finfo->type];
|
$res[$i]['type'] = $this->_aDataTypes[$finfo->type];
|
||||||
$res[$i]['len'] = $finfo->max_length;
|
$res[$i]['len'] = $finfo->max_length;
|
||||||
$res[$i]['flags'] = $finfo->flags;
|
$res[$i]['flags'] = $finfo->flags;
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$res['meta'][$res[$i]['name']] = $i;
|
$res['meta'][$res[$i]['name']] = $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} */
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
while ($finfo = $id->fetch_field()) {
|
||||||
|
//rint_r($finfo);
|
||||||
|
$res[$count]['table'] = $finfo->table;
|
||||||
|
$res[$count]['name'] = $finfo->name;
|
||||||
|
$res[$count]['type'] = $this->_aDataTypes[$finfo->type];
|
||||||
|
$res[$count]['len'] = $finfo->length;
|
||||||
|
$res[$count]['flags'] = $finfo->flags;
|
||||||
|
if ($full) {
|
||||||
|
$res['meta'][$res[$count]['name']] = $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$res['num_fields'] = $count;
|
$res['num_fields'] = $count + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// free the result only if we were called on a table
|
// free the result only if we were called on a table
|
||||||
|
|
|
@ -465,15 +465,6 @@ abstract class DB_Sql_Abstract {
|
||||||
* @return array Depends on used database and on parameter $full
|
* @return array Depends on used database and on parameter $full
|
||||||
*/
|
*/
|
||||||
public function metadata($table = '', $full = false) {
|
public function metadata($table = '', $full = false) {
|
||||||
if(empty($table)) {
|
|
||||||
$aMeta = $this->_metaData(NULL, true);
|
|
||||||
if(is_array($aMeta) && isset($aMeta[0]['table'])) {
|
|
||||||
$table = $aMeta[0]['table'];
|
|
||||||
} else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = (string) $this->Database . '_' . $table . '_' . (($full) ? '1' : '0');
|
$key = (string) $this->Database . '_' . $table . '_' . (($full) ? '1' : '0');
|
||||||
|
|
||||||
if (!isset(self::$_metaCache[$key])) {
|
if (!isset(self::$_metaCache[$key])) {
|
||||||
|
|
|
@ -110,7 +110,6 @@ class DB_ConLite extends DB_Sql {
|
||||||
|
|
||||||
$aMetadata = $this->metadata($sTable);
|
$aMetadata = $this->metadata($sTable);
|
||||||
|
|
||||||
|
|
||||||
if (!is_array($aMetadata) || count($aMetadata) == 0) {
|
if (!is_array($aMetadata) || count($aMetadata) == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Laden…
In neuem Issue referenzieren