2009年8月1日星期六

Re: [fw-db] fecthing data with option BA7-899

Erdal YAZICIOGLU ha scritto:
> Hello all
>
> I have data coming from text box and select box.
>
> <select name="choice">
> <option label="cg1a" value="MMT_Number">MMT
> Number</option>
> <option label="cg1a" value="BOM">BOM
> Number</option>
> <option label="cg1a" value="CIN">CIN
> Number</option>
> </select>
>
> I am trying to fecth result regarding the choice of user.
>
> In the controller
>
> $filter = new Zend_Filter_StripTags();
> $material= $filter->filter($this->_request->getPost('material'));
> //data coming from input text.
> $choice = $filter->filter($this->_request->getPost('choice'));//data
> from select box.
>
> I set the object
> $searchDatabase = new Model_DbTable_MMT();
> $where = $choice . '=' . $material
> $this->view->searchDatabase = $searchDatabase->fetchAll($where);
>
$searchDatabase = new Model_DbTable_MMT();
// first verify if the col passed really exists
if ( in_array( $choice, $searchDatabase->info(
Zend_Db_Table_Abstract::COLS ) ) )
{
$where = $searchDatabase->getAdapter()->quoteInto($choice . '= ?'
, $material);
$select = $searchDatabase->select()->where($where);
$rows = $searchDatabase->fetchAll($select);
$this->view->searchDatabase = $rows;
}else throw new Exception('WTF ??');

--
fsockopen
ZF n00b

没有评论: