protected function fixOrderingOfForeignKeyDataInSameTable($resultsSets, $tableName, $column, $in = null)
{
$sql = sprintf('SELECT * FROM %s WHERE %s %s', $this->dbAdapter->quoteIdentifier(constant(constant($tableName . '::PEER') . '::TABLE_NAME')), $this->dbAdapter->quoteIdentifier(strtolower($column->getName())), null === $in ? 'IS NULL' : 'IN (' . $in . ')');
$stmt = $this->con->prepare($sql);
$stmt->execute();
$in = array();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$in[] = "'" . $row[strtolower($column->getRelatedColumnName())] . "'";
$resultsSets[] = $row;
}
if ($in = implode(', ', $in)) {
$resultsSets = $this->fixOrderingOfForeignKeyDataInSameTable($resultsSets, $tableName, $column, $in);
}
return $resultsSets;
}