<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rabidGadfly &#187; beginner</title>
	<atom:link href="http://www.rabidgadfly.com/index.php/category/beginner/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rabidgadfly.com</link>
	<description>Glenn Gervais&#039;s methods, tips, and musings on Flash, ColdFusion, XML, and other web technology.</description>
	<lastBuildDate>Fri, 21 May 2010 11:58:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ColdFusion Function to Delete Generic Records from Generic Tables</title>
		<link>http://www.rabidgadfly.com/index.php/2007/02/07/coldfusion-function-to-delete-generic-records-from-generic-tables/</link>
		<comments>http://www.rabidgadfly.com/index.php/2007/02/07/coldfusion-function-to-delete-generic-records-from-generic-tables/#comments</comments>
		<pubDate>Wed, 07 Feb 2007 15:31:10 +0000</pubDate>
		<dc:creator>rabidGadfly</dc:creator>
				<category><![CDATA[beginner]]></category>
		<category><![CDATA[coldFusion]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=21</guid>
		<description><![CDATA[Thought I&#8217;d share a simple generic ColdFusion delete function I wrote this morning. We develop many sites where I work and often they each end up with their own set of unique content management tools. All of the sites share the need for CRUD (create, read, update, delete) functionality and often the query syntax is [...]]]></description>
			<content:encoded><![CDATA[<p>Thought I&#8217;d share a simple generic ColdFusion delete function I wrote this morning. We develop many sites where I work and often they each end up with their own set of unique content management tools. All of the sites share the need for CRUD (create, read, update, delete) functionality and often the query syntax is the same for data retrieval and deletion:</p>
<blockquote><p><strong>DELETE<br />
FROM  table<br />
WHERE table_id = variable_id</strong></p></blockquote>
<p>In writing a component for some of the tools I started wondering if, in addition to data, I could also pass the names of database tables and columns to create an all-purpose generic delete function.<br />
<span id="more-21"></span> I started by created a generic component, generic.cfc and wrote my function:</p>
<blockquote><p><strong>&lt;cffunction name=&#8221;deleteRecordByID&#8221; access=&#8221;public&#8221; returntype=&#8221;Boolean&#8221;<br />
hint=&#8221;Deletes a record from a passed table based on passed id&#8221; &gt;<br />
&lt;cfargument name=&#8221;tableName&#8221; type=&#8221;string&#8221; required=&#8221;yes&#8221; /&gt;</strong><br />
<strong> &lt;cfargument name=&#8221;idColumnName&#8221; type=&#8221;string&#8221; required=&#8221;yes&#8221; /&gt;</strong><br />
<strong> &lt;cfargument name=&#8221;idValue&#8221; type=&#8221;numeric&#8221; required=&#8221;yes&#8221; /&gt;</strong><br />
<strong> &lt;cfargument name=&#8221;dsn&#8221; type=&#8221;string&#8221; required=&#8221;no&#8221; default=&#8221;myDSN&#8221; /&gt;</strong><br />
<strong> &lt;cftry&gt;</strong><br />
<strong> &lt;cfquery name=&#8221;qDelRecord&#8221; datasource=&#8221;#arguments.dsn#&#8221;&gt;</strong><br />
<strong> DELETE</strong><br />
<strong> FROM        #arguments.tableName#</strong><br />
<strong> WHERE        #arguments.idColumnName# = &lt;cfqueryparam value=&#8221;#arguments.idValue#&#8221; cfsqltype=&#8221;cf_sql_integer&#8221;&gt;</strong><br />
<strong> &lt;/cfquery&gt;</strong><br />
<strong> &lt;cfcatch type=&#8221;any&#8221;&gt;</strong><br />
<strong> &lt;cfreturn false /&gt;</strong><br />
<strong> &lt;/cfcatch&gt;</strong><br />
<strong> &lt;/cftry&gt;</strong><br />
<strong> &lt;cfreturn true /&gt;<br />
&lt;/cffunction&gt;</strong></p></blockquote>
<p>Then I gave it a shot:</p>
<blockquote><p><strong>&lt;cfset objGeneric = createObject(&#8220;component&#8221;,&#8221;generic&#8221;) /&gt;<br />
&lt;cfset deleteResult = objGlobal.deleteRecordByID(&#8220;myTableName&#8221;, &#8220;myTableIDColumn&#8221;, idValue, request.dsn) /&gt;</strong></p></blockquote>
<p>To my surprise, er I mean just as I expected, it was successful. Whether you find the deleteByRecordID function clever or utterly ridiculous, the knowledge that you can pass database object names for query execution can be useful.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rabidgadfly.com/index.php/2007/02/07/coldfusion-function-to-delete-generic-records-from-generic-tables/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Output ColdFusion Query Results to XML</title>
		<link>http://www.rabidgadfly.com/index.php/2006/05/19/output-coldfusion-query-results-to-xml/</link>
		<comments>http://www.rabidgadfly.com/index.php/2006/05/19/output-coldfusion-query-results-to-xml/#comments</comments>
		<pubDate>Fri, 19 May 2006 15:51:56 +0000</pubDate>
		<dc:creator>rabidGadfly</dc:creator>
				<category><![CDATA[XML]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[coldFusion]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=7</guid>
		<description><![CDATA[I don&#8217;t claim to be a ColdFusion expert by any stretch of the imagination, but recently I found myself in need of coming up with a way to output query results to an XML file. My example below is based on an absolutely hideous article I stumbled across on the ColdFusion Developer Center. The example [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t claim to be a ColdFusion expert by any stretch of the imagination, but recently I found myself in need of coming up with a way to output query results to an XML file. My example below is based on an absolutely <a title="Hideous CF Doc" href="http://www.adobe.com/devnet/coldfusion/articles/cf_handbk_ch6.html">hideous article</a> I stumbled across on the ColdFusion Developer Center. The example they provide has several errors in syntax: unclosed tags, unclosed quotes, unOPENED pounds, etc. It also only outputs one record!</p>
<p>After about an hour of playing with it I was able to get the code working properly and I thought I&#8217;d share a very basic example. The following code queries a database for names and phone numbers then outputs them all to a file name phonelist.xml in the current path:</p>
<blockquote style="font-family:courier;"><p>
&lt;cfquery name=&quot;qGetPhoneList&quot; datasource=&quot;datasource&quot;&gt;<br />
		select first_name,last_name,phone from employees<br />
	&lt;/cfquery&gt;</p>
<p>	 &lt;!&#8212;Create a temporary variable &quot;tempxml&quot; to hold our XML document&#8212;&gt;</p>
<p>	&lt;cfset tempxml = &quot;&lt;?xml version =&quot;&quot;1.0&quot;&quot;?&gt;<br />
	&lt;!DOCTYPE phonelist [<br />
	&lt;!ELEMENT phonelist (firstname,lastname,phone)&gt;<br />
	]&gt;<br />
	&lt;phonelist&gt;&quot;&gt;<br />
	&lt;cfloop query=&quot;qGetPhoneList&quot;&gt;<br />
	&lt;cfset tempxml = &quot;#tempxml#<br />
	  &lt;cid&gt;#Trim(&quot;#XMLFormat(first_name)#&quot;)#&lt;/cid&gt;<br />
	  &lt;s&gt;#Trim(&quot;#XMLFormat(last_name)#&quot;)#&lt;/s&gt;<br />
	  &lt;r&gt;#Trim(&quot;#XMLFormat(phone)#&quot;)#&lt;/r&gt;<br />
	&quot;&gt;<br />
	&lt;/cfloop&gt;<br />
	&lt;cfset tempxml = &quot;<br />
	#tempxml#<br />
	&lt;/phonelist&gt;&quot;&gt;</p>
<p>	&lt;!&#8212;show the XML in the HTML output &#8212;&gt;<br />
	&lt;P&gt;This is a simple XML document that&#8217;s been generated by the ColdFusion code. &lt;/P&gt;<br />
	&lt;cfoutput&gt;<br />
	  &lt;xmp&gt;<br />
		#tempxml#<br />
	  &lt;/xmp&gt;<br />
	&lt;/cfoutput&gt;</p>
<p>	&lt;!&#8212;write out the XML&#8212;&gt;<br />
	&lt;cfset writePath=#ExpandPath(&quot;phonelist.xml&quot;)#&gt;<br />
	&lt;cfoutput&gt;<br />
	#writePath#&lt;br /&gt;<br />
	&lt;cffile action = &quot;Write&quot; file=&quot;#writePath#&quot; output=&quot;#tempxml#&quot;&gt;<br />
	&lt;/cfoutput&gt;
</p></blockquote>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rabidgadfly.com/index.php/2006/05/19/output-coldfusion-query-results-to-xml/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
