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

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

Module pool selction screen parameters combination logic
Hi floks,
Am new to the module pool development ,Recently i have created one program based on

cURL Sending File as Post
This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a d

Open link with largest int string first
I have the following links i would like to open either all at once or one-by-one. How would i procee

"From field" in PHP email form
I used a wizard to create a PHP email form. I was able to customize it with the exception of the Fr

Displaying a record from mysql in a simple swf file
Hi,

I have a mysql database containing information I would like to display in my swf.

Sharing PHP Sessions Across Domains
I am in the process of writing a script to share a php session across various domains I have.
The

Using unserialize()
Hi there.

I have some data in my database that is serialized.

e.g.

a:2:{i:0

A WBS element with the name XXX already exists in version FREI_VERSION
Hi.
When I am trying to insert WBS element in a project, error occurs:

"A WBS eleme

Send inserts to mysql thru port 80
Hi!

I have an application that must do some inserts in a mysql db. This db is behind a firewa

getting weird error..
okay, I'm getting an error on this particular function, something about the syntax in the mysql LIMI

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