Jump to content

returning a recordset through external functions file


otuatail

Recommended Posts

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).

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.