View Single Post
  #2 (permalink)  
Old 11-05-2007, 11:05 PM
troxy troxy is offline
Junior Member
 
Join Date: Oct 2007
Posts: 16
Default

Okay, so you have to extend the Zend_Db_Table and Zend_Db_Table_Row.
The extended table class might look like this:
PHP Code:
class MyTable extends Zend_Db_Table_Abstract {
    protected 
$_name 'TABLE_NAME';
    protected 
$_primary 'ID';
    protected 
$_rowClass 'MyTable_Row'// Tell it to use your custom extended row class

And in the extended row class is where the magic occurs:
PHP Code:
<?php
class MyTable_Row extends Zend_Db_Table_Row_Abstract {

    protected function 
_transformColumn($columnName) {
        if (!
is_string($columnName)) {
            require_once 
'Zend/Db/Table/Row/Exception.php';
            throw new 
Zend_Db_Table_Row_Exception('Specified column is not a string');
        }
        return 
strtoupper(preg_replace('/(?<=\\w)([A-Z])/''_\\1'$columnName)); // Transform the camelCase into UPPER_CASE
    
}
}
And then you can simply use it like this
PHP Code:
$table = new MyTable();
$result $table->find(10);
$row $result->current();
$value $row->fooBar// The actual name in the table is FOO_BAR 
Reply With Quote