RecordExists.php 819 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ tlZHF3xtCfhq1gmhq+oryCJ2jXDJB08NW0vRJ5D3/rM=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.3
  11. */
  12. namespace Cube\Validate\Db;
  13. class RecordExists extends AbstractDb
  14. {
  15. protected $_message = "No record matching '%value%' has been found.";
  16. /**
  17. *
  18. * check if the record exists
  19. *
  20. * @return bool
  21. */
  22. public function isValid()
  23. {
  24. $this->setMessage(
  25. str_replace('%value%', $this->_value, $this->getMessage()));
  26. $result = $this->_table->fetchRow(
  27. $this->getSelect());
  28. if (count($result) > 0) {
  29. return true;
  30. }
  31. return false;
  32. }
  33. }