FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Usage of class constants inside strings and heredocs
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Usage of class constants inside strings and heredocs [message #170489] Tue, 02 November 2010 16:14 Go to previous message
Giuseppe Sacco is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Free Web Space for our Experiments
Next Topic: There is some framework/tool to generate PHP code
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 00:17:25 GMT 2024

Total time taken to generate the page: 4.40874 seconds