PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/laravel/database/query/join.php

https://bitbucket.org/masroore/tinybb
PHP | 68 lines | 20 code | 9 blank | 39 comment | 0 complexity | 4956e127b6a9bafab67bafcee5d0c985 MD5 | raw file
  1. <?php namespace Laravel\Database\Query;
  2. class Join {
  3. /**
  4. * The type of join being performed.
  5. *
  6. * @var string
  7. */
  8. public $type;
  9. /**
  10. * The table the join clause is joining to.
  11. *
  12. * @var string
  13. */
  14. public $table;
  15. /**
  16. * The ON clauses for the join.
  17. *
  18. * @var array
  19. */
  20. public $clauses = array();
  21. /**
  22. * Create a new query join instance.
  23. *
  24. * @param string $type
  25. * @param string $table
  26. * @return void
  27. */
  28. public function __construct($type, $table)
  29. {
  30. $this->type = $type;
  31. $this->table = $table;
  32. }
  33. /**
  34. * Add an ON clause to the join.
  35. *
  36. * @param string $column1
  37. * @param string $operator
  38. * @param string $column2
  39. * @param string $connector
  40. * @return Join
  41. */
  42. public function on($column1, $operator, $column2, $connector = 'AND')
  43. {
  44. $this->clauses[] = compact('column1', 'operator', 'column2', 'connector');
  45. return $this;
  46. }
  47. /**
  48. * Add an OR ON clause to the join.
  49. *
  50. * @param string $column1
  51. * @param string $operator
  52. * @param string $column2
  53. * @return Join
  54. */
  55. public function or_on($column1, $operator, $column2)
  56. {
  57. return $this->on($column1, $operator, $column2, 'OR');
  58. }
  59. }