otuatail Posted October 19, 2011 Share Posted October 19, 2011 Hi I am trying to get as much code out of my PHP pages mainly for security but also to make the website easier to manage. I have lots of functions in a functions page which is in a folder protected by htaccess. I am making calls to a database in the php pages for example $sql = “SELECT DOB FROM Children WHERE Surname = ‘Robinson’”; ConnectDB(5); $query = mysql_query ($sql) or die ("E010A"); $rs = mysql_fetch_array($query) or die ("E110A"); $Surname = $rs[‘Surname’]; Admitedly this is not a good example for only retrieving one value but it is an example. I could move all the code out and create a function in the functions.php file $Surname = GetSurname(‘Robinson’); Now I am keeping most of my database query and table names secret. My problem is I might want to return a recordset not just one value. If I wanted the surname of all the children in Class ‘B’ could I do the same like $Class = GetChildrenInClass(‘B’); This is returning a record set now. I want to get all this code out also in the case that I want to use a different database. If I wanted to to use database 4, I would have to go through tons of web pages changing ConnectDB(5). Quote Link to comment https://forums.phpfreaks.com/topic/249386-returning-a-recordset-through-external-functions-file/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.