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

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

Can't shake the "Warning: include()" error
I've just uploaded my site to a new server and where I have PHP include tags in my HTML, the browser

include problem
I have my root folder as:
Code: $root = $_SERVER["SITE_HTMLROOT"]; // the server root<

Bar charts using Graphical Framework.
I am using Graphical Frameworks(GFW) to create a chart Graphic . There is no problem with the data d

Help with ORDER BY
Hello. I would like to order by ascending States, then Cities, then Gyms in the following code, but

Echoing a Variable from a Object
How do I get a variable from the new User Class to echo out in this clasS?

class MyApp
{

Dynamic Data + Sql Server 2005 Enterprise?
Hi! I have just started to learn ASP.NET, and it looks like it is quite a lot to learn. Im not reall

Clean URLs
Hi I was wandering if anyone has ever implemented URLs on their PHP run website using URLS like wiki

How can I get my program to read a larger array ??
Hi:

I have this program that reads from an array to do calculations. The array are just t

Saas with SAP R/3
hi experts,

Is SaaS offer available in SAP? for SAP R/3? from where i can get the info a

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