PropelQuery.php 776 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. /**
  10. * Factory for model queries
  11. *
  12. * @author François Zaninotto
  13. * @version $Revision: 1612 $
  14. * @package propel.runtime.query
  15. */
  16. class PropelQuery
  17. {
  18. public static function from($queryClassAndAlias)
  19. {
  20. list($class, $alias) = ModelCriteria::getClassAndAlias($queryClassAndAlias);
  21. $queryClass = $class . 'Query';
  22. if (!class_exists($queryClass)) {
  23. throw new PropelException('Cannot find a query class for ' . $class);
  24. }
  25. $query = new $queryClass();
  26. if ($alias !== null) {
  27. $query->setModelAlias($alias);
  28. }
  29. return $query;
  30. }
  31. }