PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/src/MMIBundle/Model/om/BaseIndustryQuery.php

https://gitlab.com/Isaki/le331.fr
PHP | 397 lines | 190 code | 31 blank | 176 comment | 34 complexity | a2ea237ea3796ac4ca6a73102856460d MD5 | raw file
  1. <?php
  2. namespace MMIBundle\Model\om;
  3. use \Criteria;
  4. use \Exception;
  5. use \ModelCriteria;
  6. use \ModelJoin;
  7. use \PDO;
  8. use \Propel;
  9. use \PropelCollection;
  10. use \PropelException;
  11. use \PropelObjectCollection;
  12. use \PropelPDO;
  13. use MMIBundle\Model\Company;
  14. use MMIBundle\Model\Industry;
  15. use MMIBundle\Model\IndustryPeer;
  16. use MMIBundle\Model\IndustryQuery;
  17. /**
  18. * @method IndustryQuery orderById($order = Criteria::ASC) Order by the id column
  19. * @method IndustryQuery orderByName($order = Criteria::ASC) Order by the name column
  20. *
  21. * @method IndustryQuery groupById() Group by the id column
  22. * @method IndustryQuery groupByName() Group by the name column
  23. *
  24. * @method IndustryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
  25. * @method IndustryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
  26. * @method IndustryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
  27. *
  28. * @method IndustryQuery leftJoinCompany($relationAlias = null) Adds a LEFT JOIN clause to the query using the Company relation
  29. * @method IndustryQuery rightJoinCompany($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Company relation
  30. * @method IndustryQuery innerJoinCompany($relationAlias = null) Adds a INNER JOIN clause to the query using the Company relation
  31. *
  32. * @method Industry findOne(PropelPDO $con = null) Return the first Industry matching the query
  33. * @method Industry findOneOrCreate(PropelPDO $con = null) Return the first Industry matching the query, or a new Industry object populated from the query conditions when no match is found
  34. *
  35. * @method Industry findOneByName(string $name) Return the first Industry filtered by the name column
  36. *
  37. * @method array findById(int $id) Return Industry objects filtered by the id column
  38. * @method array findByName(string $name) Return Industry objects filtered by the name column
  39. */
  40. abstract class BaseIndustryQuery extends ModelCriteria
  41. {
  42. /**
  43. * Initializes internal state of BaseIndustryQuery object.
  44. *
  45. * @param string $dbName The dabase name
  46. * @param string $modelName The phpName of a model, e.g. 'Book'
  47. * @param string $modelAlias The alias for the model in this query, e.g. 'b'
  48. */
  49. public function __construct($dbName = null, $modelName = null, $modelAlias = null)
  50. {
  51. if (null === $dbName) {
  52. $dbName = 'default';
  53. }
  54. if (null === $modelName) {
  55. $modelName = 'MMIBundle\\Model\\Industry';
  56. }
  57. parent::__construct($dbName, $modelName, $modelAlias);
  58. }
  59. /**
  60. * Returns a new IndustryQuery object.
  61. *
  62. * @param string $modelAlias The alias of a model in the query
  63. * @param IndustryQuery|Criteria $criteria Optional Criteria to build the query from
  64. *
  65. * @return IndustryQuery
  66. */
  67. public static function create($modelAlias = null, $criteria = null)
  68. {
  69. if ($criteria instanceof IndustryQuery) {
  70. return $criteria;
  71. }
  72. $query = new IndustryQuery(null, null, $modelAlias);
  73. if ($criteria instanceof Criteria) {
  74. $query->mergeWith($criteria);
  75. }
  76. return $query;
  77. }
  78. /**
  79. * Find object by primary key.
  80. * Propel uses the instance pool to skip the database if the object exists.
  81. * Go fast if the query is untouched.
  82. *
  83. * <code>
  84. * $obj = $c->findPk(12, $con);
  85. * </code>
  86. *
  87. * @param mixed $key Primary key to use for the query
  88. * @param PropelPDO $con an optional connection object
  89. *
  90. * @return Industry|Industry[]|mixed the result, formatted by the current formatter
  91. */
  92. public function findPk($key, $con = null)
  93. {
  94. if ($key === null) {
  95. return null;
  96. }
  97. if ((null !== ($obj = IndustryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
  98. // the object is already in the instance pool
  99. return $obj;
  100. }
  101. if ($con === null) {
  102. $con = Propel::getConnection(IndustryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  103. }
  104. $this->basePreSelect($con);
  105. if ($this->formatter || $this->modelAlias || $this->with || $this->select
  106. || $this->selectColumns || $this->asColumns || $this->selectModifiers
  107. || $this->map || $this->having || $this->joins) {
  108. return $this->findPkComplex($key, $con);
  109. } else {
  110. return $this->findPkSimple($key, $con);
  111. }
  112. }
  113. /**
  114. * Alias of findPk to use instance pooling
  115. *
  116. * @param mixed $key Primary key to use for the query
  117. * @param PropelPDO $con A connection object
  118. *
  119. * @return Industry A model object, or null if the key is not found
  120. * @throws PropelException
  121. */
  122. public function findOneById($key, $con = null)
  123. {
  124. return $this->findPk($key, $con);
  125. }
  126. /**
  127. * Find object by primary key using raw SQL to go fast.
  128. * Bypass doSelect() and the object formatter by using generated code.
  129. *
  130. * @param mixed $key Primary key to use for the query
  131. * @param PropelPDO $con A connection object
  132. *
  133. * @return Industry A model object, or null if the key is not found
  134. * @throws PropelException
  135. */
  136. protected function findPkSimple($key, $con)
  137. {
  138. $sql = 'SELECT `id`, `name` FROM `industry` WHERE `id` = :p0';
  139. try {
  140. $stmt = $con->prepare($sql);
  141. $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
  142. $stmt->execute();
  143. } catch (Exception $e) {
  144. Propel::log($e->getMessage(), Propel::LOG_ERR);
  145. throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
  146. }
  147. $obj = null;
  148. if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
  149. $obj = new Industry();
  150. $obj->hydrate($row);
  151. IndustryPeer::addInstanceToPool($obj, (string) $key);
  152. }
  153. $stmt->closeCursor();
  154. return $obj;
  155. }
  156. /**
  157. * Find object by primary key.
  158. *
  159. * @param mixed $key Primary key to use for the query
  160. * @param PropelPDO $con A connection object
  161. *
  162. * @return Industry|Industry[]|mixed the result, formatted by the current formatter
  163. */
  164. protected function findPkComplex($key, $con)
  165. {
  166. // As the query uses a PK condition, no limit(1) is necessary.
  167. $criteria = $this->isKeepQuery() ? clone $this : $this;
  168. $stmt = $criteria
  169. ->filterByPrimaryKey($key)
  170. ->doSelect($con);
  171. return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
  172. }
  173. /**
  174. * Find objects by primary key
  175. * <code>
  176. * $objs = $c->findPks(array(12, 56, 832), $con);
  177. * </code>
  178. * @param array $keys Primary keys to use for the query
  179. * @param PropelPDO $con an optional connection object
  180. *
  181. * @return PropelObjectCollection|Industry[]|mixed the list of results, formatted by the current formatter
  182. */
  183. public function findPks($keys, $con = null)
  184. {
  185. if ($con === null) {
  186. $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
  187. }
  188. $this->basePreSelect($con);
  189. $criteria = $this->isKeepQuery() ? clone $this : $this;
  190. $stmt = $criteria
  191. ->filterByPrimaryKeys($keys)
  192. ->doSelect($con);
  193. return $criteria->getFormatter()->init($criteria)->format($stmt);
  194. }
  195. /**
  196. * Filter the query by primary key
  197. *
  198. * @param mixed $key Primary key to use for the query
  199. *
  200. * @return IndustryQuery The current query, for fluid interface
  201. */
  202. public function filterByPrimaryKey($key)
  203. {
  204. return $this->addUsingAlias(IndustryPeer::ID, $key, Criteria::EQUAL);
  205. }
  206. /**
  207. * Filter the query by a list of primary keys
  208. *
  209. * @param array $keys The list of primary key to use for the query
  210. *
  211. * @return IndustryQuery The current query, for fluid interface
  212. */
  213. public function filterByPrimaryKeys($keys)
  214. {
  215. return $this->addUsingAlias(IndustryPeer::ID, $keys, Criteria::IN);
  216. }
  217. /**
  218. * Filter the query on the id column
  219. *
  220. * Example usage:
  221. * <code>
  222. * $query->filterById(1234); // WHERE id = 1234
  223. * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
  224. * $query->filterById(array('min' => 12)); // WHERE id >= 12
  225. * $query->filterById(array('max' => 12)); // WHERE id <= 12
  226. * </code>
  227. *
  228. * @param mixed $id The value to use as filter.
  229. * Use scalar values for equality.
  230. * Use array values for in_array() equivalent.
  231. * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
  232. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  233. *
  234. * @return IndustryQuery The current query, for fluid interface
  235. */
  236. public function filterById($id = null, $comparison = null)
  237. {
  238. if (is_array($id)) {
  239. $useMinMax = false;
  240. if (isset($id['min'])) {
  241. $this->addUsingAlias(IndustryPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
  242. $useMinMax = true;
  243. }
  244. if (isset($id['max'])) {
  245. $this->addUsingAlias(IndustryPeer::ID, $id['max'], Criteria::LESS_EQUAL);
  246. $useMinMax = true;
  247. }
  248. if ($useMinMax) {
  249. return $this;
  250. }
  251. if (null === $comparison) {
  252. $comparison = Criteria::IN;
  253. }
  254. }
  255. return $this->addUsingAlias(IndustryPeer::ID, $id, $comparison);
  256. }
  257. /**
  258. * Filter the query on the name column
  259. *
  260. * Example usage:
  261. * <code>
  262. * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
  263. * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
  264. * </code>
  265. *
  266. * @param string $name The value to use as filter.
  267. * Accepts wildcards (* and % trigger a LIKE)
  268. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  269. *
  270. * @return IndustryQuery The current query, for fluid interface
  271. */
  272. public function filterByName($name = null, $comparison = null)
  273. {
  274. if (null === $comparison) {
  275. if (is_array($name)) {
  276. $comparison = Criteria::IN;
  277. } elseif (preg_match('/[\%\*]/', $name)) {
  278. $name = str_replace('*', '%', $name);
  279. $comparison = Criteria::LIKE;
  280. }
  281. }
  282. return $this->addUsingAlias(IndustryPeer::NAME, $name, $comparison);
  283. }
  284. /**
  285. * Filter the query by a related Company object
  286. *
  287. * @param Company|PropelObjectCollection $company the related object to use as filter
  288. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  289. *
  290. * @return IndustryQuery The current query, for fluid interface
  291. * @throws PropelException - if the provided filter is invalid.
  292. */
  293. public function filterByCompany($company, $comparison = null)
  294. {
  295. if ($company instanceof Company) {
  296. return $this
  297. ->addUsingAlias(IndustryPeer::ID, $company->getIndustryId(), $comparison);
  298. } elseif ($company instanceof PropelObjectCollection) {
  299. return $this
  300. ->useCompanyQuery()
  301. ->filterByPrimaryKeys($company->getPrimaryKeys())
  302. ->endUse();
  303. } else {
  304. throw new PropelException('filterByCompany() only accepts arguments of type Company or PropelCollection');
  305. }
  306. }
  307. /**
  308. * Adds a JOIN clause to the query using the Company relation
  309. *
  310. * @param string $relationAlias optional alias for the relation
  311. * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
  312. *
  313. * @return IndustryQuery The current query, for fluid interface
  314. */
  315. public function joinCompany($relationAlias = null, $joinType = Criteria::INNER_JOIN)
  316. {
  317. $tableMap = $this->getTableMap();
  318. $relationMap = $tableMap->getRelation('Company');
  319. // create a ModelJoin object for this join
  320. $join = new ModelJoin();
  321. $join->setJoinType($joinType);
  322. $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
  323. if ($previousJoin = $this->getPreviousJoin()) {
  324. $join->setPreviousJoin($previousJoin);
  325. }
  326. // add the ModelJoin to the current object
  327. if ($relationAlias) {
  328. $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
  329. $this->addJoinObject($join, $relationAlias);
  330. } else {
  331. $this->addJoinObject($join, 'Company');
  332. }
  333. return $this;
  334. }
  335. /**
  336. * Use the Company relation Company object
  337. *
  338. * @see useQuery()
  339. *
  340. * @param string $relationAlias optional alias for the relation,
  341. * to be used as main alias in the secondary query
  342. * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
  343. *
  344. * @return \MMIBundle\Model\CompanyQuery A secondary query class using the current class as primary query
  345. */
  346. public function useCompanyQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
  347. {
  348. return $this
  349. ->joinCompany($relationAlias, $joinType)
  350. ->useQuery($relationAlias ? $relationAlias : 'Company', '\MMIBundle\Model\CompanyQuery');
  351. }
  352. /**
  353. * Exclude object from result
  354. *
  355. * @param Industry $industry Object to remove from the list of results
  356. *
  357. * @return IndustryQuery The current query, for fluid interface
  358. */
  359. public function prune($industry = null)
  360. {
  361. if ($industry) {
  362. $this->addUsingAlias(IndustryPeer::ID, $industry->getId(), Criteria::NOT_EQUAL);
  363. }
  364. return $this;
  365. }
  366. }