Start ::
Developers Corner ::
Module Development ::
Building a search function??
Moderated by: Support Team
-
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
Hey all I have my module just about done now ( all the standard functions work ) and now I need to add a search function to the pnuser & pnuserapi.php files and I am not quite sure how to do it, so I was wondering if you all could give me some pointers on the matter. Here is what I have built thus far:
pnuser.php search function:
The above is called to from a link in the users menu.
this is what I have in my template file now:
Now from this file I will call to a pnuser.php query function to run the API function to do the search, this is where I am having a bit of trouble I am not 100% sure what this function should look like since the Example module doesn't have a search function and every module I have loaded on my system does not make use of the pnrender engine.
Any pointers anyone could provide would be awesome.
Thanks
-SUNADMN -
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
Ok so I have reached the point of trying to call to the API function but for some reason I have an issue with my SQL and am not sure how to adjust it to work correctly can anyone give me some advice please. Below is my API function:
Thanks
-SUNADMN -
- rank:
-
Helper
- registered:
- June 2002
- Status:
- offline
- last visit:
- 05.08.08
- Posts:
- 286
jediping is correct.
You need to use either SELECT * FROM $pnDiagramtable WHERE ( {your LIKE statements from above} )
or
SELECT $pnDiagramcolumn[column1],$pnDiagramcolumn[column2],$pnDiagramcolumn[column3]... FROM $pnDiagramtable WHERE ( {your LIKE statements from above} )
-----
cyber_wolf
http://www.bkbsolutions.com - My Zikula module development site. -
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
It looks like you're not passing any args to your query, as in function pnDiagram_userapi_query($args).
A question on the design of this search thing, though. Might it not be easier for the user to just enter one term in one box and then have the search function check that one term against all the columns? Or am I thinking too simplistically? Guess it depends on what you anticipating them searching for. The planning stages of programming always intrigue me. :D -
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
OK so I get my args passed now but for some stupid reason I am not getting any data in the vars in the SQL statement. Here is what I have now:
API function:
and when I print the SQL out I get this:
I have tried building the vars in the statement in the above method and like this:
Neither of these work, am I building this incorrectly???
Thanks
-SUNADMN -
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
Ok so jedi do you have any idea how I would use the render engine to produce results from that quewry and I run the SQL??? I am a little lost here as this is a stand alone function and nothing in the module really looks like anything I would use her.
Thanks
-SUNADMN -
- rank:
-
Helper
- registered:
- October 2004
- Status:
- offline
- last visit:
- 01.03.06
- Posts:
- 437
Ok so it has to be back to basics here as I can't figure out how to port the logic of the view/dispaly function to port to a search as the view/display functions dont really return a single item for a given match rather produce all items in the DB.
So I am going to make a list here of what is needed and hope for some insite on what else I am missing:
1st) a Menu link to a user function that produces a pntemplate file for a seach form ( done I have this part working )
2nd) a query function for the pntemplate file to call to that will run the pnuserapi function to get the data ( for the most part this is done but I think I am missing some logic here )
3rd) a userapi function that takes the form data from the pntemplate and runs a SQL query to produce a data set ( I believe I have this done, the part I am hung on is the display portion of code how do I translate the data returned from the API function to a pntemplate )
I know this may sound trivial to some, but for the life of me I just can't grasp the logic behind it please please I need some help.
Thanks
-SUNADMN -
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
Are you sure the search function will return only one result? It seems possible that there would be more than one result, yes? For example, there's going to (probably) be more than one person with tech1, yes? The SQL result will be all the details about everyone who has tech1.
Now you need to get the SQL result into something you can use. This is similar to what you use in the main view function, by putting the results into an $items variable, sending it to the pnuser file, which then gets it ready for display.
Does that help?
Start ::
Developers Corner ::
Module Development ::
Building a search function??
