paristemi
[ class tree: paristemi ] [ index: paristemi ] [ all elements ]

Source for file dbmodify.php

Documentation is available at dbmodify.php

  1. <?php
  2. /**
  3. * <b>Database Class : Modify</b><br />
  4. * Provides all database modify methods for various uses, and connections to the database.
  5. * @author Kristen O'Brien <kristen_paristemi-com>
  6. * @copyright Copyright 2004, Kristen O'Brien
  7. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8. * @link http://www.paristemi.com Paristemi Main Site
  9. * @package paristemi
  10. * @subpackage paristemi_database_layer
  11. * @since Build 0.5
  12. * @version Build 0.7
  13. * @filesource
  14. */
  15. /**
  16. * <b>Database Class : Modify</b><br />
  17. * Provides all database modify methods for various uses, and connections to the database.
  18. * @author Kristen O'Brien <kristen_paristemi-com>
  19. * @copyright Copyright 2004, Kristen O'Brien
  20. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  21. * @link http://www.paristemi.com Paristemi Main Site
  22. * @package paristemi
  23. * @subpackage paristemi_database_layer
  24. * @since Build 0.5
  25. * @version Build 0.7
  26. * @filesource
  27. */
  28. class DatabaseModify {
  29. var $Link;
  30. function DatabaseModify() {
  31. $this->Link = mysql_connect($GLOBALS['DATABASE_SERVER'],
  32. $GLOBALS['DATABASE_USER'],
  33. $GLOBALS['DATABASE_PASS'])
  34. or $this->Error('Unable to connect to db server.');
  35. mysql_select_db($GLOBALS['DATABASE_NAME'])
  36. or $this->Error('Unable to select db');
  37. }
  38.  
  39.  
  40. //Only needed if you want to reconnect to a different database. Otherwise
  41. //the call to mysql_close() occurs when the connection dies.
  42. function Close() {
  43. mysql_close($this->Link);
  44. }
  45.  
  46.  
  47. //For internal use, make sure to type $this->Error('some string');
  48. function Error($str) {
  49. die($str);
  50. }
  51.  
  52. function &SetCalItemData(&$title, &$start, &$stop, &$seriesid,
  53. &$subseriesid, &$type, &$locationid, &$contactid,
  54. &$contactemail, &$audioid, &$description, &$notes,
  55. &$rec, &$recday, &$recend)
  56. {
  57. $title = stripslashes($title);
  58. $type = stripslashes($type);
  59. $description = stripslashes($description);
  60. $notes = stripslashes($notes);
  61. $result = mysql_query("insert into Instance
  62. (Title, Start, Stop, SeriesID, SubSeriesID, Type,
  63. LocationID, ContactID, ContactEmail, AudioID, Description,
  64. Notes, Recursive, RecDay, RecEnd)
  65. values ('$title', '$start', '$stop', '$seriesid',
  66. '$subseriesid', '$type', '$locationid', '$contactid',
  67. '$contactemail', '$audioid', '$description', '$notes',
  68. '$rec', '$recday', '$recend');")
  69. or $this->Error('Nothing posted?');
  70. $result2 = mysql_query("update Announcement
  71. set Created = NOW()
  72. where ID = 2;")
  73. or $this->Error('Nothing posted6?');
  74.  
  75. return $result;
  76. }
  77. function &SetDevotionalItemData(&$title,&$text,&$keyverse,&$verses,
  78. &$showcase,&$prayer,&$authorid,&$showitem) {
  79. $result = mysql_query("insert into Devotional
  80. (Title,Text,KeyVerse,Verses,
  81. Prayer,AuthorID,ShowItem)
  82. values('$title','$text','$keyverse','$verses',
  83. '$prayer',$authorid,$showitem);");
  84. if($showcase) {
  85. $result2 = mysql_query("SELECT max(id) FROM Devotional;");
  86. $row = mysql_fetch_array($result2, MYSQL_ASSOC);
  87. foreach ($row as $item) { $devoid = $item; }
  88. $result3 = $this->IncreaseShowcase('Devotional',$devoid);
  89. }
  90. return ($result && $result2 && $result3);
  91. }
  92. function &SetAnnouncementItemData(&$title,&$desc,&$category,$enddate,&$contactid) {
  93. $result = mysql_query("insert into Announcement
  94. (Title,Description,Category,EndDate,ContactID,Created)
  95. values('$title','$desc','$category',
  96. '$enddate','$contactid',NOW());");
  97. return $result;
  98. }
  99. function &SetAudioItemData(&$title, &$link, &$linkdl, &$instanceid,
  100. &$showmultimedia, &$category, &$book,
  101. &$startverse, &$stopverse, &$topic, &$description)
  102. {
  103. $title = stripslashes($title);
  104. $topic = stripslashes($topic);
  105. $description = stripslashes($description);
  106. $result = mysql_query("insert into Audio
  107. (Title, Category, LinkStream, LinkDownload, Description, ShowMultimedia,
  108. BookReference, StartVerse, StopVerse, Topic)
  109. values ('$title', '$category', '$link', '$linkdl',
  110. '$description', '$showmultimedia',
  111. '$book', '$startverse', '$stopverse', '$topic');");
  112. //or $this->Error('Nothing posted?');
  113. $result4 = mysql_query("SELECT max(id) FROM Audio;")
  114. or $this->Error('Nothing found4?');
  115. $row = mysql_fetch_array($result4, MYSQL_ASSOC);
  116. foreach ($row as $item) { $audioid = $item; }
  117. echo $audioid." ".$instanceid;
  118. $result5 = mysql_query("update Instance
  119. set AudioID = $audioid
  120. where ID = $instanceid;")
  121. or $this->Error('Nothing posted5?');
  122. $result6 = mysql_query("update Announcement
  123. set Created = NOW()
  124. where ID = 1;")
  125. or $this->Error('Nothing posted6?');
  126.  
  127. return ($result);
  128. }
  129. function IncreaseShowcase($tablename,$newitemid=0)
  130. {
  131. $result = mysql_query("SELECT ID FROM $tablename WHERE Showcase = 1;");
  132. $row = mysql_fetch_array($result, MYSQL_ASSOC);
  133. if($row != null) {
  134. foreach($row as $item) { $itemid = $item; }
  135. if($newitemid == 0) {
  136. $result2 = mysql_query("SELECT MIN(ID) FROM $tablename
  137. WHERE Showcase = 0 AND ID > $itemid;");
  138. $row = mysql_fetch_array($result2, MYSQL_ASSOC);
  139. foreach($row as $item) { $newitemid = $item; }
  140. }
  141. $result3 = mysql_query("UPDATE $tablename SET Showcase = 0 WHERE ID = $itemid;");
  142. }
  143. $result4 = mysql_query("UPDATE $tablename
  144. SET Showcase = 1, ShowItem = 1
  145. WHERE ID = $newitemid;");
  146. return ($result4);
  147. }
  148. }
  149. ?>

Documentation generated on Mon, 10 May 2004 12:08:15 -0700 by phpDocumentor 1.3.0RC3