PageRenderTime 31ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/Kumbia/ActiveRecord/Generator/Strategies/Uniqid.php

http://kumbia-enterprise.googlecode.com/
PHP | 99 lines | 19 code | 13 blank | 67 comment | 0 complexity | 6d35a9d048a35134956be200d6acebe2 MD5 | raw file
  1. <?php
  2. /**
  3. * Kumbia Enterprise Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the New BSD License that is bundled
  8. * with this package in the file docs/LICENSE.txt.
  9. *
  10. * If you did not receive a copy of the license and are unable to
  11. * obtain it through the world-wide-web, please send an email
  12. * to license@loudertechnology.com so we can send you a copy immediately.
  13. *
  14. * @category Kumbia
  15. * @package ActiveRecord
  16. * @subpackage Generator
  17. * @copyright Copyright (c) 2008-2009 Louder Technology COL. (http://www.loudertechnology.com)
  18. * @copyright Copyright (c) 2008-2009 Andres Felipe Gutierrez (gutierrezandresfelipe at gmail.com)
  19. * @license New BSD License
  20. * @version $Id: Uniqid.php 5 2009-04-24 01:48:48Z gutierrezandresfelipe $
  21. */
  22. /**
  23. * UniqIdGenerator
  24. *
  25. * Genera identificadores a partir de Uniqid
  26. *
  27. * @category Kumbia
  28. * @package ActiveRecord
  29. * @subpackage Generator
  30. * @copyright Copyright (c) 2008-2009 Louder Technology COL. (http://www.loudertechnology.com)
  31. * @copyright Copyright (c) 2008-2009 Andres Felipe Gutierrez (gutierrezandresfelipe at gmail.com)
  32. * @license New BSD License
  33. * @link http://www.php.net/uniqid
  34. * @link http://en.wikipedia.org/wiki/UUID
  35. */
  36. class UuidGenerator implements ActiveRecordGeneratorInterface {
  37. /**
  38. * UniqId generado
  39. *
  40. * @var string
  41. */
  42. protected $_uniqid;
  43. /**
  44. * Constructor de UuidGenerator
  45. *
  46. */
  47. public function __construct(){
  48. $this->_uniqid = md5(uniqid(mt_rand(), true));
  49. }
  50. /**
  51. * Establece las opciones del generador
  52. *
  53. * @param array $options
  54. */
  55. public function setOptions($options){
  56. }
  57. /**
  58. * Establece el nombre de la columna identidad
  59. *
  60. * @param string $identityColumn
  61. */
  62. public function setIdentityColumn($identityColumn){
  63. $this->_identityColumn = $identityColumn;
  64. }
  65. /**
  66. * Objeto que solicita el identificador
  67. *
  68. * @param ActiveRecord $record
  69. */
  70. public function setIdentifier($record){
  71. $record->writeAttribute($this->_identityColumn, $this->_uniqid);
  72. }
  73. /**
  74. * Actualiza el consecutivo
  75. *
  76. * @return boolean
  77. */
  78. public function updateConsecutive($record){
  79. }
  80. /**
  81. * Finaliza el generador
  82. *
  83. */
  84. public function finalizeConsecutive(){
  85. }
  86. }