function __construct(Am_Table $table, $alias = 't') { $this->db = $table->getAdapter(); $this->table = $table; $this->alias = $alias; $this->tableName = $table->getName(); $this->keyField = $table->getKeyField(); }
/** * Constructor */ function __construct(Am_Table $table) { $this->_table = $table; $this->_db = $this->_table->getAdapter(); $this->init(); }
public function addFieldSelect($name, Am_Table $table, $title, array $options) { $fs = $this->form->addFieldset()->setLabel($title . ' Columns: ' . $table->getName(true)); $sampleRows = $table->getAdapter()->select("SELECT * FROM ?#\n LIMIT ?d,3", $table->getName(true), max($table->countBy() - 3, 0)); $sample = "<div style='color: lightgray'>"; foreach ($sampleRows as $r) { $sample .= nl2br(Am_Controller::escape(substr(print_r($r, true), 0, 1024))) . "\n"; } $sample .= "</div>"; $fs->addStatic()->setLabel('Sample Rows')->setContent($sample); $fields = $table->getFields(true); $fields = array_merge(array(''), $fields); foreach ($options as $k => $v) { $el = $fs->addSelect('field[' . $name . '][' . $k . ']')->setLabel($v)->loadOptions(array_combine($fields, $fields)); if (!in_array($k, array('Am_Protect_SessionTable::FIELD_UID', 'Am_Protect_SessionTable::FIELD_IP', 'Am_Protect_SessionTable::FIELD_UA', 'Am_Protect_SessionTable::FIELD_CREATED', 'Am_Protect_SessionTable::FIELD_CHANGED'))) { $el->addRule('required'); } } }