I am new to PHP but an experienced C++ programmer. Of course, my first task with PHP is tackling a harder bit of coding... (why start simple).
I am writing a class with functions to be used to simplify the conversion of a customers ASP website to PHP. They used an access database with ADOdb and want everything moved to PHP and MySQL (not ADOdb)
Instead of rewritting hundred (or more) lines of code, I decided it was easier to create similar "functions" in a class. I actually have most of it working well.
Couple items that would make things easier... but can't figure out if it is doable in PHP or not.
My class is called SQLSet. We reference it my calling
$mySQLset=new SQLSet();
I have a function in the class, currently called Field() that allows me to return the value in a passed parameter from a stored database row. I also have another function called SetField() that lets me set that data for a value in a stored database row.
function Field($fldname)
{
return($this->SQLRow[$fldname]);
}
function SetField($fldname,$fldvalue)
{
$this->SQLRow[$fldname]=$fldvalue;
}
In ASP ADOdb, you can get the data from a field by calling the set to get the info by one of two ways...
myvariable=myset.field("fieldname")
or
myvariable=myset("fieldname")
You can set the value in ASP ADOdb with...
myset("fieldname")=myvariable
Can this be done similarily in PHP with a class? Right now I have to use the function name and appropriate parameters passed in the function. Works, but is a bit more "clunky".
Of course, this would be easier using ADOdb with PHP but they don't want it anymore.
Thanks