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

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

How do I get the row number from from an sql table query
Hi all

I have a table that I query and it returns a number of rows.
mysql_num_rows($query)

Dynamic Array using glob?
Is there an easier way to do this?

I am trying to get create a dyamic array based on files wi

quotes changing
hi all

in my content

opening quotes " changes to “

close qu

Merger of 6 sister companies under one flagship company after go live
Dear Experts,
I need one help regarding Merger of sister companies of same group. currently we

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

I need desperate help with this php code integrated with flash please
Can someone please help me with this php code which I have been stuck on for weeks . I am trying to

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

insert/update functions for mysql, what do you think?
I am working on two really simple functions that automatically generate (and execute) insert and upd

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