IdentifierExpression.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Database\Expression;
  16. use Cake\Database\ExpressionInterface;
  17. use Cake\Database\ValueBinder;
  18. /**
  19. * Represents a single identifier name in the database.
  20. *
  21. * Identifier values are unsafe with user supplied data.
  22. * Values will be quoted when identifier quoting is enabled.
  23. *
  24. * @see \Cake\Database\Query::identifier()
  25. */
  26. class IdentifierExpression implements ExpressionInterface
  27. {
  28. /**
  29. * Holds the identifier string
  30. *
  31. * @var string
  32. */
  33. protected $_identifier;
  34. /**
  35. * Constructor
  36. *
  37. * @param string $identifier The identifier this expression represents
  38. */
  39. public function __construct($identifier)
  40. {
  41. $this->_identifier = $identifier;
  42. }
  43. /**
  44. * Sets the identifier this expression represents
  45. *
  46. * @param string $identifier The identifier
  47. * @return void
  48. */
  49. public function setIdentifier($identifier)
  50. {
  51. $this->_identifier = $identifier;
  52. }
  53. /**
  54. * Returns the identifier this expression represents
  55. *
  56. * @return string
  57. */
  58. public function getIdentifier()
  59. {
  60. return $this->_identifier;
  61. }
  62. /**
  63. * Converts the expression to its string representation
  64. *
  65. * @param \Cake\Database\ValueBinder $generator Placeholder generator object
  66. * @return string
  67. */
  68. public function sql(ValueBinder $generator)
  69. {
  70. return $this->_identifier;
  71. }
  72. /**
  73. * This method is a no-op, this is a leaf type of expression,
  74. * hence there is nothing to traverse
  75. *
  76. * @param callable $callable The callable to traverse with.
  77. * @return void
  78. */
  79. public function traverse(callable $callable)
  80. {
  81. }
  82. }