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
Re: Usage of class constants inside strings and heredocs [message #170509 is a reply to message #170500] Thu, 04 November 2010 09:01 Go to previous messageGo to previous message
Giuseppe Sacco is currently offline  Giuseppe Sacco
Messages: 5
Registered: November 2010
Karma:
Junior Member
Hi all,
just to be sure: when you suggest to use sprintf(), do you mean
something like this?

<?php

class myTable {
const F_CODE = "code";
const F_DESCRIPTION = "description";
const TABLENAME = "lookup";
public function insert($record)
{
// simplified: does not escape strings, does not use prepared
statemnts
$sql = sprintf("INSERT INTO %s (%s,%s) VALUES ('%s', '%s')",
self::TABLENAME, self::F_CODE, self::F_DESCRIPTION,
$record[self::F_CODE], $record[self::F_DESCRIPTION]);

echo $sql;
} // end method insert

} // end class myTable

$record = array(
'code' => 'This is the code',
'description' => 'This is the description',
);
$foo = new myTable;
$foo->insert($record);

?>
[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: Thu Nov 14 03:26:24 GMT 2024

Total time taken to generate the page: 0.04282 seconds