2008年9月8日星期一

Re: [fw-db] Zend DB Table and Oracle

Hi,

You must have a sequence on Oracle if you want retrieve a "SOFTWARE_ID" like
an auto_increment field of MySQL.
My remember is that sequence must be name: $_tableName . '_SEQ'

Mickael

PS: can you also check my recent comment on
http://framework.zend.com/issues/browse/ZF-3663
http://framework.zend.com/issues/browse/ZF-3663


Gabriel Baez-2 wrote:
>
> I downloaded Zend Framework 1.6
>
> I just started messing around with it.
>
> When using the following code I get the following error message:
>
> Error: SQLSTATE[IM001]: Driver does not support this function: driver
> does
> not support lastInsertId()
>
> Any ideas what might be causing this? the entry still gets inserted in
> the
> database.
>
> I want to make sure I'm not missing anything before I file a bug.
>
> Code:
>
> try {
>
> $form = new SoftwareForm();
> $form->submit->setLabel('Add');
> $form->published->addMultiOptions(array( 'Y' => 'Yes', 'N' => 'No'));
> $this->view->form = $form;
>
> if($this->getRequest()->isPost()):
> $formData = $this->getRequest()->getPost();
> if($form->isValid($formData)):
> $software = new Software();
>
> $data = array (
> 'SOFTWARE_NAME' => $form->getValue('name'),
> 'SOFTWARE_DESC' => $form->getValue('description'),
> 'PUBLISHED' => $form->getValue('published'),
> 'CREATED_BY' => $id,
> 'CREATION_DATE' => new Zend_Db_Expr('CURRENT_TIMESTAMP')
>
> );
>
> $row = $software->createRow($data);
> $row->save();
>
>
> //$this->_redirect('/administrator');
> else:
> $form->populate($formData);
> endif;
> }
> catch (Exception $e)
> {
> $msg = $e->getMessage();
> print_r($msg);
>
> }
>
>
> My Form Code:
>
>
> class SoftwareForm extends Zend_Form
> {
> public function __construct($options = null)
> {
> parent::__construct($options);
> $this->setName('addsoftware');
>
> $name = new Zend_Form_Element_Text('name');
> $name->setLabel('Software')
> ->setRequired(true)
> ->addFilter('StripTags')
> ->addFilter('StringTrim')
> ->addValidator('NotEmpty');
>
> $published = new Zend_Form_Element_Select('published');
> $published->setLabel('Published')
> ->setRequired(true)
> ->addFilter('StripTags')
> ->addFilter('StringTrim')
> ->addValidator('NotEmpty');
>
> $desc = new Zend_Form_Element_Textarea('description');
> $desc->setLabel('Description')
> ->setRequired(true)
> ->addFilter('StripTags')
> ->addFilter('StringTrim')
> ->addValidator('NotEmpty');
>
> $id = new Zend_Form_Element_Hidden('id');
>
> $submit = new Zend_Form_Element_Submit('submit');
> $submit->setAttrib('id', 'submitbutton');
>
> $this->addElements(array($id, $name, $published,$desc, $submit));
> }
> }
>
>
>
> Table:
>
>
> Describing software....
>
> NAME Null? Type
> ------------------------------- --------- -----
> SOFTWARE_ID NOT NULL NUMBER
> SOFTWARE_NAME VARCHAR2(200)
> SOFTWARE_DESC VARCHAR2(4000)
> CREATION_DATE TIMESTAMP (6)
> CREATED_BY NUMBER
> PUBLISHED VARCHAR2(1)
> LAST_UPDATE TIMESTAMP (7)
> LAST_UPDATE_BY NUMBER
>
>

--
View this message in context: http://www.nabble.com/Zend-DB-Table-and-Oracle-tp19380170p19380600.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: