PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/com/meldsolutions/MeldForums/core/displaytype/DisplaytypeDAO.cfc

http://github.com/meldsolutions/Meld-Forums
ColdFusion CFScript | 193 lines | 161 code | 32 blank | 0 comment | 2 complexity | 626b90f7494d35b02a22b7016673b97f MD5 | raw file
Possible License(s): GPL-2.0
  1. <!---This file is part of the Meld Forums application.
  2. Meld Forums is licensed under the GPL 2.0 license
  3. Copyright (C) 2010 2011 Meld Solutions Inc. http://www.meldsolutions.com/
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation, version 2 of that license..
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. --->
  15. <cfcomponent displayname="DisplaytypeDAO" output="false" extends="MeldForums.com.meldsolutions.core.MeldDAO">
  16. <!---^^GENERATEDSTART^^--->
  17. <cfset variables.instance = StructNew() />
  18. <cffunction name="init" access="public" output="false" returntype="DisplaytypeDAO">
  19. <cfargument name="MeldConfig" type="any" required="true">
  20. <cfset variables.MeldConfig = arguments.MeldConfig />
  21. <cfset structAppend(variables.instance,structCopy(variables.MeldConfig.getAllValues()),true) />
  22. <cfset structAppend(variables,structCopy(variables.MeldConfig.getAllValues()),true) />
  23. <cfreturn this>
  24. </cffunction>
  25. <cffunction name="save" access="public" output="false" returntype="boolean">
  26. <cfargument name="DisplaytypeBean" type="any" required="true" />
  27. <cfset var qCreate = "" />
  28. <cfquery name="qCreate" datasource="#variables.dsn#" username="#variables.dsnusername#" password="#variables.dsnpassword#">
  29. INSERT INTO
  30. #variables.dsnprefix#mf_displaytype
  31. (
  32. <!---^^SAVECOLUMNS-START^^--->
  33. Displaytypeid,
  34. ObjectID,
  35. Package,
  36. Name,
  37. Description,
  38. Settings,
  39. IsConfigurable,
  40. IsActive,
  41. Version,
  42. Defaults,
  43. ModuleID,
  44. DateCreate,
  45. DateLastUpdate
  46. <!---^^SAVECOLUMNS-END^^--->
  47. )
  48. VALUES
  49. (
  50. <!---^^SAVEVALUES-START^^--->
  51. <cfqueryparam value="#arguments.DisplaytypeBean.getDisplaytypeid()#" CFSQLType="cf_sql_char" maxlength="35" />,
  52. <cfqueryparam value="#arguments.DisplaytypeBean.getObjectID()#" CFSQLType="cf_sql_char" null="#(not len(arguments.DisplaytypeBean.getObjectID()))#" maxlength="35" />,
  53. <cfqueryparam value="#arguments.DisplaytypeBean.getPackage()#" CFSQLType="cf_sql_varchar" maxlength="45" />,
  54. <cfqueryparam value="#arguments.DisplaytypeBean.getName()#" CFSQLType="cf_sql_varchar" maxlength="45" />,
  55. <cfqueryparam value="#arguments.DisplaytypeBean.getDescription()#" CFSQLType="cf_sql_longvarchar" null="#(not len(arguments.DisplaytypeBean.getDescription()))#" />,
  56. <cfqueryparam value="#arguments.DisplaytypeBean.getSettings()#" CFSQLType="cf_sql_longvarchar" null="#(not len(arguments.DisplaytypeBean.getSettings()))#" />,
  57. <cfqueryparam value="#arguments.DisplaytypeBean.getIsConfigurable()#" CFSQLType="cf_sql_tinyint" />,
  58. <cfqueryparam value="#arguments.DisplaytypeBean.getIsActive()#" CFSQLType="cf_sql_tinyint" />,
  59. <cfqueryparam value="#arguments.DisplaytypeBean.getVersion()#" CFSQLType="cf_sql_varchar" maxlength="12" />,
  60. <cfqueryparam value="#arguments.DisplaytypeBean.getDefaults()#" CFSQLType="cf_sql_longvarchar" null="#(not len(arguments.DisplaytypeBean.getDefaults()))#" />,
  61. <cfqueryparam value="#arguments.DisplaytypeBean.getModuleID()#" CFSQLType="cf_sql_char" null="#(not len(arguments.DisplaytypeBean.getModuleID()))#" maxlength="35" />,
  62. <cfqueryparam value="#CreateODBCDateTime(now())#" CFSQLType="cf_sql_timestamp" />,
  63. <cfqueryparam value="#CreateODBCDateTime(now())#" CFSQLType="cf_sql_timestamp" />
  64. <!---^^SAVEVALUES-END^^--->
  65. )
  66. </cfquery>
  67. <cfset arguments.DisplaytypeBean.setBeanExists( 1 ) />
  68. <cfset arguments.DisplaytypeBean.setDateCreate( CreateODBCDateTime(now()) ) />
  69. <cfset arguments.DisplaytypeBean.setDateLastUpdate( CreateODBCDateTime(now()) ) />
  70. <cfreturn true />
  71. </cffunction>
  72. <cffunction name="read" access="public" output="false" returntype="void">
  73. <cfargument name="DisplaytypeBean" type="any" required="true" />
  74. <cfset var qRead = "" />
  75. <cfset var strReturn = structNew() />
  76. <cfquery name="qRead" datasource="#variables.dsn#" username="#variables.dsnusername#" password="#variables.dsnpassword#">
  77. SELECT
  78. *,1 AS BeanExists
  79. FROM
  80. #variables.dsnprefix#mf_displaytype
  81. WHERE
  82. 0=0
  83. <!---^^PRIMARYKEYS-START^^--->
  84. AND Displaytypeid = <cfqueryparam value="#arguments.DisplaytypeBean.getDisplaytypeid()#" CFSQLType="cf_sql_char" maxlength="35" />
  85. <!---^^PRIMARYKEYS-END^^--->
  86. </cfquery>
  87. <cfif qRead.recordCount>
  88. <cfset strReturn = queryRowToStruct(qRead)>
  89. <cfset arguments.DisplaytypeBean.init(argumentCollection=strReturn)>
  90. </cfif>
  91. </cffunction>
  92. <cffunction name="update" access="public" output="false" returntype="boolean">
  93. <cfargument name="DisplaytypeBean" type="any" required="true" />
  94. <cfset var qUpdate = "" />
  95. <cfquery name="qUpdate" datasource="#variables.dsn#" username="#variables.dsnusername#" password="#variables.dsnpassword#">
  96. UPDATE
  97. #variables.dsnprefix#mf_displaytype
  98. SET
  99. <!---^^UPDATEVALUES-START^^--->
  100. ObjectID = <cfqueryparam value="#arguments.DisplaytypeBean.getObjectID()#" CFSQLType="cf_sql_char" null="#(not len(arguments.DisplaytypeBean.getObjectID()))#" maxlength="35" />,
  101. Package = <cfqueryparam value="#arguments.DisplaytypeBean.getPackage()#" CFSQLType="cf_sql_varchar" maxlength="45" />,
  102. Name = <cfqueryparam value="#arguments.DisplaytypeBean.getName()#" CFSQLType="cf_sql_varchar" maxlength="45" />,
  103. Description = <cfqueryparam value="#arguments.DisplaytypeBean.getDescription()#" CFSQLType="cf_sql_longvarchar" null="#(not len(arguments.DisplaytypeBean.getDescription()))#" />,
  104. Settings = <cfqueryparam value="#arguments.DisplaytypeBean.getSettings()#" CFSQLType="cf_sql_longvarchar" null="#(not len(arguments.DisplaytypeBean.getSettings()))#" />,
  105. IsConfigurable = <cfqueryparam value="#arguments.DisplaytypeBean.getIsConfigurable()#" CFSQLType="cf_sql_tinyint" />,
  106. IsActive = <cfqueryparam value="#arguments.DisplaytypeBean.getIsActive()#" CFSQLType="cf_sql_tinyint" />,
  107. Version = <cfqueryparam value="#arguments.DisplaytypeBean.getVersion()#" CFSQLType="cf_sql_varchar" maxlength="12" />,
  108. Defaults = <cfqueryparam value="#arguments.DisplaytypeBean.getDefaults()#" CFSQLType="cf_sql_longvarchar" null="#(not len(arguments.DisplaytypeBean.getDefaults()))#" />,
  109. ModuleID = <cfqueryparam value="#arguments.DisplaytypeBean.getModuleID()#" CFSQLType="cf_sql_char" null="#(not len(arguments.DisplaytypeBean.getModuleID()))#" maxlength="35" />,
  110. DateLastUpdate = <cfqueryparam value="#CreateODBCDateTime(now())#" CFSQLType="cf_sql_timestamp" />
  111. <!---^^UPDATEVALUES-END^^--->
  112. WHERE
  113. 0=0
  114. <!---^^PRIMARYKEYS-START^^--->
  115. AND Displaytypeid = <cfqueryparam value="#arguments.DisplaytypeBean.getDisplaytypeid()#" CFSQLType="cf_sql_char" maxlength="35" />
  116. <!---^^PRIMARYKEYS-END^^--->
  117. </cfquery>
  118. <cfset arguments.DisplaytypeBean.setDateLastUpdate( CreateODBCDateTime(now()) ) />
  119. <cfreturn true />
  120. </cffunction>
  121. <cffunction name="delete" access="public" output="false" returntype="boolean">
  122. <cfargument name="DisplaytypeBean" type="any" required="true" />
  123. <cfset var qDelete = "">
  124. <cfquery name="qDelete" datasource="#variables.dsn#" username="#variables.dsnusername#" password="#variables.dsnpassword#">
  125. DELETE FROM
  126. #variables.dsnprefix#mf_displaytype
  127. WHERE
  128. 0=0
  129. <!---^^PRIMARYKEYS-START^^--->
  130. AND Displaytypeid = <cfqueryparam value="#arguments.DisplaytypeBean.getDisplaytypeid()#" CFSQLType="cf_sql_char" maxlength="35" />
  131. <!---^^PRIMARYKEYS-END^^--->
  132. </cfquery>
  133. <cfset arguments.DisplaytypeBean.setBeanExists( 0 ) />
  134. <cfreturn true />
  135. </cffunction>
  136. <cffunction name="exists" access="public" output="false" returntype="boolean">
  137. <cfargument name="DisplaytypeBean" type="any" required="true" />
  138. <cfset var qExists = "">
  139. <cfquery name="qExists" datasource="#variables.dsn#" username="#variables.dsnusername#" password="#variables.dsnpassword#">
  140. SELECT
  141. count(1) as idexists
  142. FROM
  143. #variables.dsnprefix#mf_displaytype
  144. WHERE
  145. 0=0
  146. <!---^^PRIMARYKEYS-START^^--->
  147. AND Displaytypeid = <cfqueryparam value="#arguments.DisplaytypeBean.getDisplaytypeid()#" CFSQLType="cf_sql_char" maxlength="35" />
  148. <!---^^PRIMARYKEYS-END^^--->
  149. </cfquery>
  150. <cfif qExists.idexists>
  151. <cfset arguments.DisplaytypeBean.setBeanExists( 1 ) />
  152. <cfreturn true />
  153. <cfelse>
  154. <cfset arguments.DisplaytypeBean.setBeanExists( 0 ) />
  155. <cfreturn false />
  156. </cfif>
  157. </cffunction>
  158. <!---^^GENERATEDEND^^--->
  159. <!---^^CUSTOMSTART^^--->
  160. <!---^^CUSTOMEND^^--->
  161. </cfcomponent>