0

新しいモデルを構築するときに失敗する Zend Framework アプリケーションがありますが、エラーは生成されません。モデルをインスタンス化するコードは次のとおりです。

    public function connectionAction()
    {
        $clientid= $this->session->client_id;
        try {
$this->_log->debug('partner connection');      
      $partnerModel = new Model_PartnerSettings();
$this->_log->debug('get partners');
      } catch(Exception $e) {
        $this->_log->debug('failed: '.print_r($e, 1));
      }      
      $partners = $partnerModel->getPartners($clientid);

      if(count($partners) == 0) {
        $partnerModel->addPartners($clientid);
        $partners = $partnerModel->getPartners($clientid);
      }

      $this->view->partners = $partners;
    }

モデルクラスは次のとおりです。

class Model_PartnerSettings extends Zend_Db_Table_Abstract{

  protected $_name='partner_settings';

  public function getType($clientId, $partnerId)
  {
    $log = Zend_Registry::get('log');
    $db = Zend_Registry::get('db');

    $currRow = $this->getPartners($clientId, $partnerId);

    return $currRow['type'];
  }

  public function getName($clientId, $partnerId)
  {
    $log = Zend_Registry::get('log');
    $db = Zend_Registry::get('db');

    $currRow = $this->getPartners($clientId, $partnerId);

    return $currRow['name'];
  }

  public function getPartnerId($settingsId)
  {
    $where = $this->_db->quoteInto('rowid = ?', $settingsId);
    $row = $this->fetchRow($where);
    return $row['partnerinfoid'];
  }

  public function getActiveShipper($clientId)
  {
    $log = Zend_Registry::get('log');
    $db = Zend_Registry::get('db');

    $joinOn = 'partner_info.rowid = partner_settings.partnerinfoid';

    $select = $this->_db->select()
                        ->from($this->_name)
                        ->joinInner(
                            'partner_info',
                            $joinOn,
                            array('logo_file', 'status', 'type', 'name'))
                        ->where('partner_info.type = ?', 'shipping') 
                        ->where('clientid = ?', $clientId)
                        ->where('toggle_value = ?', 'on')
                        ->limit(1);
    return $currRow;
  }

  public function getPartners($clientId, $partnerId = null, $where = array())
  {
$this->_log->debug('getpartners');
    $log = Zend_Registry::get('log');
    $db = Zend_Registry::get('db');

    if(!$clientId || (count($where) > 0 && count($where) < 2)) {
      throw new Exception('Invalid Parameters');
    }

    if(!$partnerId) {
      $joinOn = 'partner_info.rowid = partner_settings.partnerinfoid';
    } else {
      $joinOn = $db->quoteInto('partner_info.rowid = ?', $partnerId);
    } 
    $select = $this->_db->select()
                        ->from($this->_name)
                        ->joinInner(
                            'partner_info',
                            $joinOn,
                            array('logo_file', 'status', 'type', 'name')) 
                        ->where('clientid = ?', $clientId);
    if(count($where)) { 
      $select->where($where[0] => $where[1]);
    }
$this->_log->debug('select='.print_r($select, 1));
    $result = ($partnerId) ? $db->fetchRow($select) : $db->fetchAll($select);
$this->_log->debug('res='.print_r($result, 1));
    return $result;
  } 

  public function addPartners($clientid)
  {
    $partnerInfoModel = new Model_PartnerInfo();

    $partners = $partnerInfoModel->fetchAll();

    foreach($partners as $partner) {
      $data = array(
        'partnerinfoid' => $partner['rowid'],
        'clientid' => $clientid,
        'toggle_value' => 'off'
      );
      $this->insert($data);
    }
  }

  public function toggleActivation($clientId, $partnerId)
  {
    $db = Zend_Registry::get('db');

    $where = array();
    $where[] = $db->quoteInto('clientid = ?', $clientId);
    $where[] = $db->quoteInto('partnerinfoid = ?', $partnerId);

    $currRow = $this->fetchRow($where);

    $toggleValue = ($currRow['toggle_value'] == 'on') ? 'off' : 'on';

    $this->update(array('toggle_value' => $toggleValue), $where);

    return $toggleValue;
  }

  public function getActiveShippingVendor($clientId, $partnerId)
  {
    return $this->getShipperName($clientId, $partnerId);
  }
}

connectionAction() コードでは、「$partnerModel = new Model_PartnerSettings();」よりも先に進むことはありません。ライン。何が悪いのかわかりません。ご協力いただきありがとうございます。

4

0 に答える 0