db.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * ZeroBin
  4. *
  5. * a zero-knowledge paste bin
  6. *
  7. * @link http://sebsauvage.net/wiki/doku.php?id=php:zerobin
  8. * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
  9. * @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
  10. * @version 0.15
  11. */
  12. /**
  13. * zerobin_db
  14. *
  15. * Model for DB access, implemented as a singleton.
  16. */
  17. class zerobin_db extends zerobin_abstract
  18. {
  19. /*
  20. * @access private
  21. * @static
  22. * @var PDO instance of database connection
  23. */
  24. private static $_db;
  25. /**
  26. * get instance of singleton
  27. *
  28. * @access public
  29. * @static
  30. * @return zerobin
  31. */
  32. public static function getInstance($options)
  33. {
  34. // if needed initialize the singleton
  35. if(null === self::$_instance) {
  36. parent::$_instance = new self;
  37. }
  38. if (
  39. is_array($options) &&
  40. array_key_exists('dsn', $options) &&
  41. array_key_exists('usr', $options) &&
  42. array_key_exists('pwd', $options) &&
  43. array_key_exists('opt', $options)
  44. ) self::$_db = new PDO(
  45. $options['dsn'],
  46. $options['usr'],
  47. $options['pwd'],
  48. $options['opt']
  49. );
  50. return parent::$_instance;
  51. }
  52. /**
  53. * Create a paste.
  54. *
  55. * @access public
  56. * @param string $pasteid
  57. * @param array $paste
  58. * @return int|false
  59. */
  60. public function create($pasteid, $paste)
  61. {
  62. }
  63. /**
  64. * Read a paste.
  65. *
  66. * @access public
  67. * @param string $pasteid
  68. * @return string
  69. */
  70. public function read($pasteid)
  71. {
  72. }
  73. /**
  74. * Delete a paste and its discussion.
  75. *
  76. * @access public
  77. * @param string $pasteid
  78. * @return void
  79. */
  80. public function delete($pasteid)
  81. {
  82. }
  83. /**
  84. * Test if a paste exists.
  85. *
  86. * @access public
  87. * @param string $dataid
  88. * @return void
  89. */
  90. public function exists($pasteid)
  91. {
  92. }
  93. /**
  94. * Create a comment in a paste.
  95. *
  96. * @access public
  97. * @param string $pasteid
  98. * @param string $parentid
  99. * @param string $commentid
  100. * @param array $comment
  101. * @return int|false
  102. */
  103. public function createComment($pasteid, $parentid, $commentid, $comment)
  104. {
  105. }
  106. /**
  107. * Read all comments of paste.
  108. *
  109. * @access public
  110. * @param string $pasteid
  111. * @return array
  112. */
  113. public function readComments($pasteid)
  114. {
  115. }
  116. /**
  117. * Test if a comment exists.
  118. *
  119. * @access public
  120. * @param string $dataid
  121. * @param string $parentid
  122. * @param string $commentid
  123. * @return void
  124. */
  125. public function existsComment($pasteid, $parentid, $commentid)
  126. {
  127. }
  128. }