Creating a Search feature with PHP and SQL

With a stored procedure you can move the SQL away from the code, allowing you to see more clearly what youre cleaning from inputs, it's something I always really strongly suggest as it makes everything so much easier and there really is no excuse for doing inline SQL.

Another small spanner to throw in the works is ranking, how are you going to determine a strong search vs a weak search? Ranking algorithms are usually the thing that takes the most time as it is wholly dependant on the data you want to send back as to how you rank it.

As said though, best of luck it seems like you're quite a quick learner so keep going!
 
More pain? How so? I'm a .net developer but I'm sure the ideas are the same for php/MySQL, SProcs are easy to set up, you can fit and forget them, and if you're hosting the database on a different server to your application it relieves a lot of stress.

I might be wrong and php (for some reason) doesn't benefit as greatly but I can't see why that would be the case
 
It's that separation that is entirely the reason for the pain. You've now got to maintain those SProcs entirely separately from your code solution. It's also a slippery slope that once using sprocs, logic can seep into those sprocs which is a VERY bad idea.

Any .NET developer worth his salt would be using something like NHibernate to manage data which makes sprocs and inline queries completely redundant :p
 
When you talk about stored procedures is that like creating classes in Java, C++ etc.

Where you have all the code in the class and then call it when you need it??
 
Done a good bit of research this morning and now im getting confused. There is so many different ways of doing things that each person suggests. So not sure how to go about it now:( lol
 
Done a good bit of research this morning and now im getting confused. There is so many different ways of doing things that each person suggests. So not sure how to go about it now:( lol

Keep it simple, stick to keeping all your code in one language, in this case php.

Stop copy pasting code off the internet, you won't learn anything doing that.

Learn to look up built in functions, and if you are really stuck have a glance at other people's solutions.
 
When you talk about stored procedures is that like creating classes in Java, C++ etc.

Where you have all the code in the class and then call it when you need it??
A stored procedure is a query that is cached in a sense. It performs far greater than passing a string to mysql_query but I wouldn't bother with this just yet. It's advanced SQL and the performance gains are for complex, heavy databases which you won't be working with just yet. Stick to the basics then work your way up. Use stored procedures when you need to know about them.

Done a good bit of research this morning and now im getting confused. There is so many different ways of doing things that each person suggests. So not sure how to go about it now:( lol
Go about it the way you're most comfortable with. Programming is an art and the beauty is there's always many ways to achieve the same goal. Don't worry too much, just learn what's in front of you. As you improve and better understand what's going on, you'll discover better, faster, cleaner ways of doing the same thing.

Try not to run before you can walk. Set a goal like build a simple shop and figure it out to make it work. Then you can research how to improve it.
 
Ed, thanks again your full of wisdom and helpful information:)

I am picking things up slowly through trial and error but i will get there in the end.

Cheers
 
Back
Top Bottom