Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #595 Hyphens (which are valid in MySQL table names) aren't valid in PHP Classes
Submitted: 2004-01-17 17:56 UTC
From: thomas at unifiedconsulting dot com Assigned: alan_k
Status: Closed Package: DB_DataObject
PHP Version: Irrelevant OS: Linux 2.6.0
Roadmaps: (Not assigned)    
Subscription  


 [2004-01-17 17:56 UTC] thomas at unifiedconsulting dot com
Description: ------------ When createTables encounters a table with a name like "foo-bar" it creates a class with a hyphen in its name, which is invalid. Reproduce code: --------------- -Create a MySQL table with a hyphen in its name -Run createTables.php Expected result: ---------------- Hyphens should be converted to a valid character (e.g. '_') or the script should fail with a message Actual result: -------------- Classes like this one are created: class DataObjects_foo-bar extends DB_DataObject { ... }

Comments

 [2004-01-18 02:50 UTC] alan_k
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.
 [2004-02-02 15:47 UTC] tacker
Inspite of hyphens numbers are valid parts of PHP classes. - $this->classname = $class_prefix.preg_replace('/[^A-Z0-9]/i','_',ucfirst(strtolower($this->table))); + $this->classname = $class_prefix.preg_replace('/[^A-Z]/i','_',ucfirst($this->table)); - $outfilename = "{$base}/".preg_replace('/[^A-Z0-9]/i','_',ucfirst(strtolower($this->table))).".php"; + $outfilename = "{$base}/".preg_replace('/[^A-Z]/i','_',ucfirst($this->table)).".php";
 [2004-02-03 06:10 UTC] alan_k
numbers are accepted now
 [2004-12-07 10:35 UTC] eingfoan at yahoo dot de
hi all, with pear data object 1.7.2 i get the hyphen problems again ! any suggestion why? thx chris