Zend DB Update不起作用?

时间:2013-02-24 19:55:13

标签: database zend-framework

我有一个包含以下代码的设置页面:

    <?php
    $Model_Team = new Model_Team();
    $self = $Model_Team->getSelf($this->admin->id);

    $Form_Setting = new Form_Admin_Setting();
    $Form_Setting->setMethod('post')
                     ->setAttrib('id','profile_form')
                     ->setAttrib('enctype', 'multipart/form-data')
                     ->setAction('/admin/setting');
    $Form_Setting->populate($self->toArray());

    $result = true;
    if( $this->getRequest()->isPost() )
    {
        if( $Form_Setting->isValid( $this->getRequest()->getPost() ) )
        {
            $Model_Team = new Model_Team(SauderSummit_Setup::$Year);
            // Rename photo
            $adapter =  $Form_Setting->photo->getTransferAdapter();
            $info = $adapter->getFileInfo();
            $extension = pathinfo($info['photo']['name'], PATHINFO_EXTENSION); 
            $photo = strtolower($this->admin->first_name) . '.' . $extension;
            $adapter->addFilter('Rename', $photo);
            if( $extension )
            {
                $uploadedData = $Form_Setting->getValues();
            }
            $result = $Model_Team->update($this->getRequest()->getPost(), $this->admin->id );

        }
    }

    if( $result == false )
    {
        $error = 'Password was NOT changed. You entered a wrong old password, or the new password did not match up with the confirmed password.';
    } 

    $this->view->setting = $Form_Setting;
    $this->view->picture = '/team/' . SauderSummit_Setup::$Year . '/' . $self->photo;
    $this->view->error = $error;

这是我的模型中的更新功能

<?php

public function update($items,$id)
{
    $select = $this->select();
    $select = $select->where('year = ?', $this->_year)
                     ->where('id = ?', $id);
    $row = $this->fetchRow($select);

    if( $row )
    {
        $row->first_name = $items['first_name'];
        $row->last_name = $items['last_name'];
        $row->private_email = $items['private_email'];
        $row->work_email = $items['work_email'];
        $row->phone = $items['phone'];
        $row->biography = $items['biography'];

        if( $items['current_password'] )
        {
            if( $items['new_password'] == $items['conf_password'] && $items['new_password'] != null  && md5($items['current_password']) == $row->password)
            {
                $row->password = md5($items['new_password']);
                $row->save();
                return true;
            }
            return false;
        }
        $row->save();
        return true;
    }
    return false;
}

当我更新设置时,表单确实会更改,但如果我返回页面,则信息与旧页面相同!我也检查了数据库,他们没有改变!!为什么?

0 个答案:

没有答案