示例#1
0
 /**
  * Binds data to node structure
  *
  * @param int $id
  * @param array|Axis_NSTree_Node $data
  * @return Axis_NSTree_Node
  */
 protected function _bindNode($id, $data)
 {
     if ($data instanceof Axis_NSTree_Node) {
         $this->_bindNode($id, $data->toArray());
     }
     if (is_array($data) && count($data)) {
         if ($this->_2tables) {
             $dataId = $this->_table2->insert($data);
         } else {
             $dataColumns = array_diff_key($data, $this->_systemColumns);
             $this->_table->update($dataColumns, $this->_db->quoteInto("{$this->_primary} = ?", $id));
         }
     } elseif (is_numeric($data) && $this->_type == self::TYPE_NETWORK) {
         $dataId = $data;
     }
     // update data Id
     if (isset($dataId)) {
         $set = array($this->_dataForeign => $dataId);
         $this->_table->update($set, $this->_db->quoteInto($this->_primary . ' = ?', $id));
     }
     return $this->select($id)->current();
 }