/** * Collection initializer * * @param array $from Array of model objects of the same class * @param string $class Optional classname of the desired objects * @param string $class Optional column name of the primary key * * @return DbFinder a finder object * @throws Exception If the array is empty, contains not model objects or composite objects */ public static function fromCollection($collection, $class = '', $pkName = '') { if (count($collection) == 0) { if (!$class) { throw new Exception('A DbFinder cannot be initialized with an empty array and no class'); } else { return self::fromClass($class); } } $testObject = $collection[0]; list($adapterClass) = DbFinderAdapterUtils::getParams($collection[0]); $finder = call_user_func(array($adapterClass, 'fromCollection'), $collection, $class, $pkName); if (class_exists($finderClass = get_class($testObject) . 'Finder')) { $dbFinder = new $finderClass(); $dbFinder->setQueryObject($finder->getQueryObject()); } else { $me = __CLASS__; $dbFinder = new $me($finder); } return $dbFinder; }
public function getColumnType($column) { $columnFinder = DbFinderAdapterUtils::getColumn($this->orm); return call_user_func(array($columnFinder, 'getColumnType'), $column); }