Forum Moderators: coopster

Message Too Old, No Replies

separating sql from html

separating sql from html

         

drooh

9:35 pm on Jul 17, 2009 (gmt 0)

10+ Year Member



I was reading up and Ive heard this before about not having your SQL queries mixed in with your PHP/HTML.

So my question is, what is the best way to do this and what are some ways of doing this? Why is it helpful? What is the benefit?

LifeinAsia

9:43 pm on Jul 17, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You can put your SQL in stored procedures.

It's another layer of security. If you have separate servers for web/application and database, it can also mean fewer calls to the database. Depending on the database and specific queries, they may run faster through a stored procedure than calling them from PHP.

drooh

9:52 pm on Jul 17, 2009 (gmt 0)

10+ Year Member



hmmmm, what is a "stored procedure" ?

Can you give some examples and explain better.

LifeinAsia

10:09 pm on Jul 17, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



A stored procedure is basically a block of SQL code that is run on the database server. This sounds like a good tutorial- [dev.mysql.com...]

drooh

10:18 pm on Jul 17, 2009 (gmt 0)

10+ Year Member



yeah, thats flyin over the old noggin. if they could explain things in plain english then maybe more of us amateur coders could get better, until then