I did the voting like this:

<!--- check if voter allready voted for this poll --->

<cfset obj =
createObject('component',application.stcoapi.pollingvotes.typePath) />

<cfset props = {} />
<cfset props.dsn = application.dsn />
<cfset props.conditions = {userip='#cgi.remote_host#'} />
<cfset queryOfPollingObjects =
obj.getMultipleByQuery(argumentCollection=props) />

<cfif not len(queryOfPollingObjects.userip)>

if the current userip not exists show the poll

<cfelse>

show results

</cfif>

Cool!

On Oct 23, 9:44 pm, Marco van den Oever <[EMAIL PROTECTED]>
wrote:
> Thank you Sean, that helped a lot and gave way more insight, i'll go
> and try out some different ways to do stuff.
>
> Thanks
>
> On Oct 23, 8:00 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > /farcry/core/packages/fourq/fourq.cfc
>
> > Check out the getMultiple and getMultipleByQuery methods.
>
> > So you can do something like:
>
> > <cfset props = {} />
> > <cfset props.dsn = application.dsn />
> > <cfset props.conditions = {userip='127.0.0.1'} />
> > <cfset arrayOfPollingObjects =
> > obj.getMultiple(argumentCollection=props) />
> > or
> > <cfset queryOfPollingObjects =
> > obj.getMultipleByQuery(argumentCollection=props) />
>
> > And get what you are looking for.  Your Polling.cfc extends
> > farcry.core.packages.types.types which extends the fourq.cfc I
> > mentioned above, so all these methods are available to you.
>
> > You can also, in your Polling.cfc create your own custom method to do
> > something like hasUserResponed(ip='127.0.0.1') so
>
> > in polling.cfc add
>
> > <cffunction name="hasUserResponded" returntype="boolean"
> > output="false" access="public">
> > <cfargument name="ip" required="true" type="string" />
> > <cfset var props = {} />
> > <cfset var arr = [] />
> > <cfset props.dsn = application.dsn />
> > <cfset props.conditions = {userip=arguments.ip} />
> > <cfset arr = obj.getMultiple(argumentCollection=props) />
> > <cfreturn arrayLen(arr) />
>
> > </cffunction>
>
> > refresh the application scope (?updateapp=1) and then you can call
>
> > <cfset alreadyResponded = obj.hasUserResponded(ip='127.0.0.1') />
>
> > and alreadyResponded will contain a boolean value you can use.
>
> > Sean
>
> > On Oct 23, 1:35 pm, Marco van den Oever <[EMAIL PROTECTED]>
> > wrote:
>
> > > Geoff thanks, now i got the createData function right, i am not
> > > experienced in using structures and arrays yet so that gives me a bit
> > > of a handicap at the moment, at the other hand it's a perfect time to
> > > learn right now.
>
> > > Based on your advice i changed the "get polling data" code like this,
> > > is that the right way to do it (asking anyone that knows):
>
> > > <!--- get the pollingdata --->
>
> > > <cfset obj =
> > > createObject('component',application.stcoapi.polling.typePath) />
>
> > > <cfset stprops_polling = structNew() />
>
> > > <cfset stprops_polling = obj.getData(stobj.pollingobjectid) />
>
> > > <cfdump var="#stprops_polling#">
>
> > > And also i don't understand how to check on if a user ip is already in
> > > the pollingvotes as i need to search in multiple records to check if
> > > that is so, i now have:
>
> > > <!--- check if voter allready voted for this poll --->
>
> > > <cfset obj =
> > > createObject('component',application.stcoapi.pollingvotes.typePath) />
>
> > > <cfset stprops_pollingvotes = structNew() />
>
> > > <cfset stprops_pollingvotes = obj.getData(stobj.pollingobjectid) />
>
> > > <cfdump var="#stprops_pollingvotes#">
>
> > > How can i change this so i search on the "userip" field between the
> > > records of table pollingvotes.
>
> > > Sean also thanks for your insight.
>
> > > Thanks
>
> > > On Oct 23, 3:20 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
>
> > > > > Also i had to remove the [ ] because it gave me a "missing argument"
> > > > > error.
>
> > > > > Now the records getting inserted, just need to figure out why answer1
> > > > > is not set to 1.
>
> > > > You cant use the CF 8 array and struct short hand like that.  [ ]
> > > > creates an array, and { } creates a struct, but you need to do so in a
> > > > cfset, you can do it inline.
>
> > > > Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"farcry-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/farcry-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to