Usage of class constants inside strings and heredocs [message #170489] |
Tue, 02 November 2010 16:14 |
Giuseppe Sacco
Messages: 5 Registered: November 2010
Karma:
|
Junior Member |
|
|
Hi all,
I created a class that encapsulates all methods for accessing a
database table. That class have class constants for defining all table
fields. I would like to create strings that include those constants,
but I fail to see how I might do it.
a simple (and not working) example:
class myTable {
const F_CODE = "code";
const F_DESCRIPTIOM = "description";
const TABLENAME = "lookup";
public function insert($record)
{
$sql = <<<SQLQ
INSERT INTO {self::TABLENAME}
VALUES ({$record[self::F_CODE]},{$record[self::F_DESCRIPTION]}
SQLQ;
// ....
} // end method insert
} // end class myTable
So, again, my question is: how do I put constants inside strings or
heredocs?
Thank you very much,
Giuseppe
|
|
|