Re: Having Problems with DB_Table mappings in memory

From: Date: Tue, 22 Nov 2005 12:47:24 +0000
Subject: Re: Having Problems with DB_Table mappings in memory
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22058@lists.php.net to get a copy of this message
"Jay Callicott" wrote: > I am using a database feed with extremely poor field names, many have > spaces in the name (e.g. "List Date") and one even has a pound sign > ("MLS #"). This is a real pain for me because I'm trying to map that > database to memory and it's giving my tempate engine (smarty) all > kinds of trouble. Is there a way to MAP the DB_Table structure in > memory as something different (e.g. map "MLS #" as "MLS_num" in php)? > I'm trying to think of any solution that isn't too cumbersome or > expensive (I don't want to have to loop through a very large > associative array to remap all the names). Any ideas? Please help! Not sure, whether I understood your problem correctly, but there is currently no direct way in DB_Table to deal with other names than the original column names. A possible way would be: Build the column definition with the column names you expect to have for using with your templates. I.e. don't use the names with spaces or pound signs, but names that don't make problems in the templates. In the $sql array you can then do something like: var $sql = array('all' => array('select' => 'badname1 AS goodname1, badname2 AS goodname2, ...', ....)); with: badnameX = names with spaces / pound signs / ..., goodnameX = names that you used in the column definition Not ideal, of course, and you can't create the original tables with this column definition, but if you already have the table (should be the case), then this should solve your problem. HTH, Mark

« previous php.pear.general (#22058) next »