mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-05 20:57:49 +02:00
XMLDB: fixes for issue #62
This commit is contained in:
@@ -626,31 +626,11 @@
|
|||||||
// $users->select('[status="active"]', 'all');
|
// $users->select('[status="active"]', 'all');
|
||||||
// or
|
// or
|
||||||
// $users->select('[status="active"]');
|
// $users->select('[status="active"]');
|
||||||
if ($row_count == 'all') {
|
foreach ($tmp as $record) {
|
||||||
|
$data[] = $record;
|
||||||
foreach ($tmp as $record) {
|
|
||||||
$data[] = $record;
|
|
||||||
}
|
|
||||||
|
|
||||||
$_records = $data;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Else select records like
|
|
||||||
// eg: $users->select(null, 2, 1);
|
|
||||||
|
|
||||||
foreach($tmp as $record) {
|
|
||||||
$data[] = $record;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If offset is null slice array from end else from begin
|
|
||||||
if ($offset === null) {
|
|
||||||
$_records = array_slice($data, -$row_count, $row_count);
|
|
||||||
} else {
|
|
||||||
$_records = array_slice($data, $offset, $row_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$_records = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If array of fields is exits then get records with this fields only
|
// If array of fields is exits then get records with this fields only
|
||||||
@@ -665,7 +645,6 @@
|
|||||||
$record_array[$count][$field] = (string)$record->$field;
|
$record_array[$count][$field] = (string)$record->$field;
|
||||||
}
|
}
|
||||||
|
|
||||||
//$record_array[$count]['id'] = (int)$record['id'];
|
|
||||||
$record_array[$count]['id'] = (int)$record->id;
|
$record_array[$count]['id'] = (int)$record->id;
|
||||||
|
|
||||||
if ($order_by == 'id') {
|
if ($order_by == 'id') {
|
||||||
@@ -677,7 +656,17 @@
|
|||||||
$count++;
|
$count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort records
|
||||||
$records = Table::subvalSort($record_array, 'sort', $order);
|
$records = Table::subvalSort($record_array, 'sort', $order);
|
||||||
|
|
||||||
|
// Slice records array
|
||||||
|
if ($offset === null && is_int($row_count)) {
|
||||||
|
$records = array_slice($records, -$row_count, $row_count);
|
||||||
|
} elseif($offset !== null && is_int($row_count)) {
|
||||||
|
$records = array_slice($records, $offset, $row_count);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -687,19 +676,41 @@
|
|||||||
if ( ! $one_record) {
|
if ( ! $one_record) {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($_records as $xml_objects) {
|
foreach ($_records as $xml_objects) {
|
||||||
|
|
||||||
$vars = get_object_vars($xml_objects);
|
$vars = get_object_vars($xml_objects);
|
||||||
|
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
$records[$count][$key] = (string)$value;
|
$records[$count][$key] = (string)$value;
|
||||||
|
|
||||||
|
if ($order_by == 'id') {
|
||||||
|
$records[$count]['sort'] = (int)$vars['id'];
|
||||||
|
} else {
|
||||||
|
$records[$count]['sort'] = (string)$value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort records
|
||||||
|
$records = Table::subvalSort($records, 'sort', $order);
|
||||||
|
|
||||||
|
// Slice records array
|
||||||
|
if ($offset === null && is_int($row_count)) {
|
||||||
|
$records = array_slice($records, -$row_count, $row_count);
|
||||||
|
} elseif($offset !== null && is_int($row_count)) {
|
||||||
|
$records = array_slice($records, $offset, $row_count);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// Single record
|
||||||
$vars = get_object_vars($_records[0]);
|
$vars = get_object_vars($_records[0]);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
$records[$key] = (string)$value;
|
$records[$key] = (string)$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return records
|
// Return records
|
||||||
|
Reference in New Issue
Block a user