protected static function _generateSelect($DBTable, $Properties, $Constraints) { assert(!empty($Constraints)); $SQL = new ImpSQLBuilder($DBTable); $SQL->addColumn('ID', 'integer'); foreach ($Properties as $name => $def) { if (is_array($def)) { if (!isset($def['type'])) { throw new Exception("{$DBTable} property {$name} must have a defined type"); } if ($def['type'] == 'collection') { continue; } $SQL->addColumn($name, $def['type']); } else { $SQL->addColumn($name, $def); } } if (is_array($Constraints)) { foreach ($Constraints as $c) { $SQL->addConstraint($c); } } else { $SQL->addConstraint($Constraints); } return $SQL->generateSelect(); }