Access database inside of a validation class


Posted on 16th Feb 2014 07:03 pm by admin

Hello,

For quite some time, I have been using functions to validate form input and access the databse. I have recently started using OOP, which is far faster and better when it comes to programming (performance aside).

Did you know?Explore Trending and Topic pages for more stories like this.
My question:
How do I access the database within a specific validation class.

Example:

class validateLogin {

// Class properties
public $value;
public $msg;
public $valid = 0;

// Access database and do some stuff to check

}

I added in the "public" to show how I would get values into the class from the public variable scope. Would I do the same for the database? A problem would arise because I use a database class to access mysql. Can I have a class within another class? I could use a normal function and basic coding, but I like php classes. Thank you
No comments posted yet

Your Answer:

Login to answer
56 Like 23 Dislike
Previous forums Next forums
Other forums

calendar dates and hours compare problem
i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same

RSS poster script?
I have found a script that posts RSS's for me on a site that I'm building. However I would like to a

Need Help with a query
Hello,
For some reason I am just not getting the right answer when I do this query and not quite

problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mi

Display data returned from Ajaxservices!!
I have a question about displaying results using ajax. I have part of the code below.
$.ajax({

help with image upload code
Hello,

right now this code I have resizes images and then places them into the uploads folder

extract content from a website
i have written a code that will grab the content from the index page..
i would like to know how c

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

max() problem
I have a while loop to get image names.
Code: $imagequery = mysql_query("SELECT * FROM ad_i

Question about GD library
I am trying to make an image that shows a random quote from my database.


However I want t

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash