|
@@ -179,7 +179,15 @@ class AuditDataService
|
|
|
*/
|
|
|
private function buildSelect($entity, $count = false)
|
|
|
{
|
|
|
- $select = 'SELECT C.rev, C.id, C.revtype, R.username, R.timestamp ';
|
|
|
+ $entities = $this->getEntities();
|
|
|
+ $primaryKeyQuery = "SHOW KEYS FROM `{$entities[$entity]}` WHERE Key_name = 'PRIMARY';";
|
|
|
+ $primaryKey = $this->connection->fetchAll($primaryKeyQuery);
|
|
|
+ $id = 'id';
|
|
|
+ if (isset($primaryKey[0])) {
|
|
|
+ $id = $primaryKey[0]['Column_name'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $select = "SELECT C.rev, C.{$id} as id, C.revtype, R.username, R.timestamp ";
|
|
|
if ($count) {
|
|
|
$select = 'SELECT COUNT(*) as total ';
|
|
|
}
|