NoRecordExists.php 915 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ RDFHTyjuxFhcBRlrGkQHfM/HAq7Z277ZLwXpSnkfoGo=
  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 NoRecordExists extends AbstractDb
  14. {
  15. /**
  16. *
  17. * error message
  18. *
  19. * @var string
  20. */
  21. protected $_message = "A record matching '%value%' has been found.";
  22. /**
  23. *
  24. * check if the record exists and returns false if it does
  25. *
  26. * @return bool
  27. */
  28. public function isValid()
  29. {
  30. $this->setMessage(
  31. str_replace('%value%', $this->_value, $this->_message));
  32. $result = $this->_table->fetchRow(
  33. $this->getSelect());
  34. if (count($result) > 0) {
  35. return false;
  36. }
  37. return true;
  38. }
  39. }