title: ColdFusion: Trying to query database in CFScript
body: <p>My boss wants me to use cfscript instead of tags for database interaction. Does anybody know of any good tutorials? I bought the Adobe ColdFusion application development book, vol 2.  But it does not have much on scripting.  I did google and found <a href="http://www.ppshein.net/index.cfm/2010/10/10/query-object-in-cfscript">this site</a>, but it did not explain much.</p>
  
  <p>Does any body know of any good tutorials on accessing the data base in CFScript?</p>
  
  <p>Basically I have to convert the following to using CFScript:</p>
  
  <pre><code>&lt;cfquery name="drafts" datasource="ICEchat"&gt;
      SELECT * from Messages where IsTemp=1 and LinkA=#FORM.LinkA# and LinkB=#FORM.LinkA#
  &lt;/cfquery&gt;
  &lt;cfif drafts.recordcount GT '0'&gt;
      &lt;cfquery name="Attachments" datasource="ICEchat"&gt;
          SELECT * FROM Attachments where id=2
      &lt;/cfquery&gt;
      { Message:"&lt;cfoutput query="drafts"&gt;#Message#&lt;/cfoutput&gt;", Attachments:[&lt;cfoutput query="attachments"&gt;
          "#url#"&lt;cfif attachments.currentRow LT attachments.recordcount&gt;,&lt;/cfif&gt;
      &lt;/cfoutput&gt;]}
  &lt;cfelse&gt;
      &lt;cfquery name="addrecord" datasource="ICEchat"&gt;
          INSERT INTO Messages 
          VALUES(1,1,' ',1)
      &lt;/cfquery&gt;
      { Message:"NA", Attachments:[]}
  &lt;/cfif&gt;
  </code></pre>