> THis is my first program ever outside of school, and I
learned about OOP with
> JAVA in school, but never really got to apply it, I know
there is some rule I
> am breaking or something for CFC's and maybe even the
OOP concept all
> together...
Right. First things first then: you might need to brush up a
bit on what
you're trying to achieve. Given yourself a refreshed in OO
concepts.
Here's one link:
http://en.wikipedia.org/wiki/Object-oriented_programming
And Google will have plenty more, if the Wikipedia article is
a bit dry (be
warned: almost all coverage of OO concepts will be a bit
dry!)
Next, read the docs on CFCs that Adobe very kindly expose to
the public,
here:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_01.html
Specifically, read and understand the coverage of the
different variables
scopes available to CFC instances, and how to use them:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_01.html
> <cffunction name="noShowFilterList" returntype="any"
access="remote">
> <cfset filterList = "69.15.59.174">
You should be VARing this variable. And all variables local
to a method.
If it IS actually your intent for the variable to be global
to the CFC
instance, SCOPE IT as variables.filterList. CF will work out
what you mean
without the scoping, but you can make the life easier of
humans reading the
code if you scope your variables as much as possible, whether
they "need"
it or not.
> <cfoutput query="getFilterIPInfo">
Where did this query come from? You didn't pass it in to the
method. Is
it an argument? (You should have a <cfargument> tag for
it, and you should
scope it. Is it a instance-wide variables (variables scope)?
Scope it for
clarity. Similarly if it is THIS-scoped.
> <cfset filterList = filterList & "," &
getFilterIPInfo.ipAddress>
> </cfoutput>
You don't need to have this loop. Just use valueList().
> <cffunction name="getFilteredLinkDetail"
access="remote" returntype="any">
> <cfparam name="PageNum_queryDetails" default="1">
I suspect this should be a VAR statement.
> <cfquery name="queryDetails"
datasource="clickTrackSystem">
This should be VARed.
> SELECT *
Using SELECT * is generally poor practice. Do you actually
WANT every
column from the query, irrespective of what those columns
are? I suspect
not. SELECT only the columns you intend to use; it's much
less work for
the DB server and the CF server.
> WHERE linkID = #url.l# AND NOT
(FIND_IN_SET(Clicks.ipAddy, "#filterList#"))
In referring to a URL-scoped variable directly in your CFC
code, you are
limiting the reusability of the CFC. This value should be
passed in.
And you should NEVER EVER use a URL-scope variable directly
in a query
anyhow. Google "SQL injection".
Always use <cfqueryparam> tags in your queries, when
using dynamic values.
Otherwise all your SQL will be treated as dynamic SQL by the
DB server, and
you'll end up with 100s of individually compiled and
never-reused queries
sitting on your DB server. Initial compilation has quite an
overhead which
you'll want to minimise. Parameterising queries also prevents
the chance
of SQL injection.
> <cfset newFilter=CreateObject('component',
'Filter')>
> <!--- Query all Filtered IPs --->
> <cfinvoke component="#newFilter#"
method="displayFilteredIPs"
> returnvariable="getFilterIPInfo">
Right. So this is where that query comes from. However...
> <cfinvoke component="#newFilter#"
method="noShowFilterList"
> returnvariable="filterList">
... you're never passing it in to the method call, are you?
So how's the
method supposed to know about it? Code in CFCs know ONLY
about their own
VARIABLES scope; they have no idea about the calling-code's
VARIABLES
scope. You need to pass in calling-code variables that you
wish the CFC
method to have access to.
> <cfinvoke component="#newLink#" method="displayLinks"
> returnvariable="getLinkInfo">
Can I recommend that instead of using all these clunky
<cfinvoke> tags, you
simply:
<cfset getLinkInfo = newLink.displayLinks()>
It's much cleaner.
<cfinvoke> is a bit of a lemon of a tag, for most of
its "recommended" (in
the docs, that is) uses.
> Variable filterList is undefined.
> The error occurred in /Links.cfc: line 57
>
> 55 : SELECT Clicks.linkID
> 56 : FROM Clicks
> 57 : WHERE Clicks.linkID = #getLinkInfo.linkID# AND NOT
I hope you understand why this is, now?
--
Adam