private function getChanges($limit, $offset, $constraints) { #list of columns available in the audit_table $cols = array('id', 'title', 'artist', 'descr', 'year', 'year_cmt', 'type', 'material', 'inside', 'address', 'county', 'muni', 'district', 'lat', 'lon', 'source', 'official_url', 'owner', 'cmt', 'created'); #prepare sql statement $mainCols = '`main_table`.`' . implode(', `main_table`.`', array_map('self::colAsmPrefix', $cols)); $auditCols = '`audit_table`.`' . implode(', `audit_table`.`', array_map('self::colAsaPrefix', $cols)); $query = ' SELECT SQL_CALC_FOUND_ROWS ' . $mainCols . ', ' . $auditCols . ' FROM `main_table`, `audit_table` WHERE `main_table`.`ugc` = 1 AND `main_table`.`id` = `audit_table`.`id` '; $query = isset($constraints) ? ApiBase::addConstraints($query . 'AND `main_table`.', $constraints, '`main_table`.') : $query; $query .= 'LIMIT ' . mysql_real_escape_string($offset) . ', ' . mysql_real_escape_string($limit) . ' '; #run query $error = false; try { $response = ApiBase::doQuery($query); $hits = ApiBase::doQuery('SELECT FOUND_ROWS()'); } catch (Exception $e) { throw $e; $error = true; } if (!$error) { #go through each row of response and compare audit to main $body = array(); foreach ($response as $r) { $r = ApiBase::sanitizeBit1diff($r); $diff = array(); $diff['id'] = $r['m_id']; foreach ($cols as $c) { if ($r['m_' . $c] != $r['a_' . $c]) { $diff[$c] = array('new' => $r['m_' . $c], 'old' => $r['a_' . $c]); } } if (count($diff) > 1) { #so as to remove any entries with only an id (i.e. only image added) $body[] = array('diff' => $diff); } } return array($body, $hits); } }