当前位置: 首页>>代码示例>>PHP>>正文


PHP WebVista_Model_ORM::nextSequenceId方法代码示例

本文整理汇总了PHP中WebVista_Model_ORM::nextSequenceId方法的典型用法代码示例。如果您正苦于以下问题:PHP WebVista_Model_ORM::nextSequenceId方法的具体用法?PHP WebVista_Model_ORM::nextSequenceId怎么用?PHP WebVista_Model_ORM::nextSequenceId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebVista_Model_ORM的用法示例。


在下文中一共展示了WebVista_Model_ORM::nextSequenceId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: persist

 public function persist()
 {
     $db = Zend_Registry::get('dbAdapter');
     $reportBaseId = (int) $this->reportBaseId;
     if ($this->_persistMode == self::DELETE) {
         try {
             $db->delete($this->_table, 'reportBaseId = ' . $reportBaseId);
             $db->delete('reportQueries', 'reportBaseId = ' . $reportBaseId);
             $db->delete('reportViews', 'reportBaseId = ' . $reportBaseId);
             return true;
         } catch (Exception $e) {
             return false;
         }
     }
     $data = $this->toArray();
     unset($data['reportFilters']);
     unset($data['reportQueries']);
     unset($data['reportViews']);
     if (strlen($data['guid']) <= 0) {
         $data['guid'] = uniqid('', true);
     }
     if ($reportBaseId > 0) {
         $ret = $db->update($this->_table, $data, 'reportBaseId = ' . $reportBaseId);
     } else {
         $this->reportBaseId = WebVista_Model_ORM::nextSequenceId();
         $data['reportBaseId'] = $this->reportBaseId;
         $ret = $db->insert($this->_table, $data);
     }
     return $ret;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:30,代码来源:ReportBase.php

示例2: persist

 public function persist()
 {
     $db = Zend_Registry::get('dbAdapter');
     $clinicalNoteTemplateId = (int) $this->clinicalNoteTemplateId;
     $data = $this->toArray();
     if ($clinicalNoteTemplateId > 0) {
         $ret = $db->update($this->_table, $data, 'clinicalNoteTemplateId = ' . $clinicalNoteTemplateId);
     } else {
         $this->clinicalNoteTemplateId = WebVista_Model_ORM::nextSequenceId();
         $data['clinicalNoteTemplateId'] = $this->clinicalNoteTemplateId;
         $ret = $db->insert($this->_table, $data);
     }
     return $ret;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:14,代码来源:ClinicalNoteTemplate.php

示例3: persist

 public function persist()
 {
     $db = Zend_Registry::get('dbAdapter');
     $reportViewId = (int) $this->reportViewId;
     $data = $this->toArray();
     unset($data['reportBase']);
     if ($reportViewId > 0) {
         $ret = $db->update($this->_table, $data, 'reportViewId = ' . $reportViewId);
     } else {
         $this->reportViewId = WebVista_Model_ORM::nextSequenceId();
         $data['reportViewId'] = $this->reportViewId;
         $data['viewOrder'] = $this->_getNextViewOrder();
         $ret = $db->insert($this->_table, $data);
     }
     return $ret;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:16,代码来源:ReportView.php

示例4: persist

 public function persist()
 {
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         return parent::persist();
     }
     $db = Zend_Registry::get('dbAdapter');
     $dataIntegrationTemplateId = (int) $this->dataIntegrationTemplateId;
     $data = $this->toArray();
     if ($dataIntegrationTemplateId > 0) {
         $ret = $db->update($this->_table, $data, 'dataIntegrationTemplateId = ' . $dataIntegrationTemplateId);
     } else {
         $this->dataIntegrationTemplateId = WebVista_Model_ORM::nextSequenceId();
         $data['dataIntegrationTemplateId'] = $this->dataIntegrationTemplateId;
         $ret = $db->insert($this->_table, $data);
     }
     return $this;
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:17,代码来源:DataIntegrationTemplate.php

示例5: addNode

 function addNode($parentId = 0, $newNodeName)
 {
     $db = Zend_Registry::get('dbAdapter');
     $newNodeId = WebVista_Model_ORM::nextSequenceId();
     $db->beginTransaction();
     try {
         $sql = "SELECT @lftVal := lft FROM enumerations WHERE enumerationId = " . (int) $parentId;
         $db->query($sql);
         $sql = "UPDATE enumerations SET rgt = rgt + 2 WHERE rgt > @lftVal";
         $db->query($sql);
         $sql = "UPDATE enumerations SET lft = lft + 2 WHERE lft > @lftVal";
         $db->query($sql);
         $sql = "INSERT INTO enumerations(enumerationId, name, parentId, lft, rgt) VALUES({$newNodeId}," . $db->quote($newNodeName) . ", " . (int) $parentId . ",@lftVal + 1, @lftVal + 2)";
         $db->query($sql);
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
     }
 }
开发者ID:lucianobenetti,项目名称:clearhealth,代码行数:19,代码来源:EnumerationsTree.php

示例6: createRevision

 public static function createRevision($objectClass, $objectId, $revisionId = 0)
 {
     $db = Zend_Registry::get('dbAdapter');
     $gd = new self();
     if ($revisionId <= 0) {
         $revisionId = self::getUnsignedRevisionId($objectClass, $objectId);
     }
     $sqlSelect = $db->select()->from($gd->_table)->where('objectClass = ?', $objectClass)->where('objectId = ?', $objectId)->where('revisionId = ?', $revisionId);
     //trigger_error($sqlSelect->__toString(),E_USER_NOTICE);
     if ($rows = $db->fetchAll($sqlSelect)) {
         $newRevisionId = WebVista_Model_ORM::nextSequenceId();
         foreach ($rows as $row) {
             $gd = new self();
             $gd->populateWithArray($row);
             $gd->genericDataId = 0;
             $gd->revisionId = $newRevisionId;
             //trigger_error(print_r($gd->toArray(),true),E_USER_NOTICE);
             $gd->persist();
         }
     }
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:21,代码来源:GenericData.php

示例7: persist

 public function persist()
 {
     $db = Zend_Registry::get('dbAdapter');
     if (!strlen($this->messagingId) > 0) {
         $this->messagingId = WebVista_Model_ORM::nextSequenceId();
     }
     $db->delete('messaging', 'messagingId=' . $db->quote($this->messagingId));
     if ($this->_persistMode != WebVista_Model_ORM::DELETE) {
         $data = $this->toArray();
         foreach ($data as $key => $value) {
             if (!is_array($value) && strlen($value) > 0) {
                 continue;
             }
             unset($data[$key]);
         }
         $db->insert('messaging', $data);
     }
     if ($this->object !== null) {
         $this->object->persist();
     }
     return $this;
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:22,代码来源:Messaging.php

示例8: processNewPatientAction

 public function processNewPatientAction()
 {
     $params = $this->_getParam('patient');
     $patient = new Patient();
     $patient->populateWithArray($params);
     if (!strlen($patient->recordNumber) > 0) {
         $patient->recordNumber = WebVista_Model_ORM::nextSequenceId('record_sequence');
     }
     $patient->persist();
     $personId = (int) $patient->personId;
     // save addresses and phones
     $addresses = $this->_getParam('addresses');
     if (is_array($addresses)) {
         foreach ($addresses as $row) {
             $address = new Address();
             $address->populateWithArray($row);
             $address->personId = $personId;
             $address->persist();
         }
     }
     $phones = $this->_getParam('phones');
     if (is_array($phones)) {
         foreach ($phones as $row) {
             $phone = new PhoneNumber();
             $phone->populateWithArray($row);
             $phone->personId = $personId;
             $phone->persist();
         }
     }
     $ret = array();
     $ret['msg'] = 'Record Saved for Patient: ' . ucfirst($patient->firstName) . ' ' . ucfirst($patient->lastName);
     $ret['personId'] = $personId;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($ret);
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:36,代码来源:PatientNewController.php

示例9: _dispatch


//.........这里部分代码省略.........
         $dataContents = $tmpData;
     }
     $recipients = array();
     $addresses = explode(',', $headers['to']);
     $db = Zend_Registry::get('dbAdapter');
     foreach ($addresses as $address) {
         if (preg_match('/<(.*)>/', $address, $matches)) {
             $address = $matches[1];
         }
         $x = explode('@', $address);
         $username = $x[0];
         $domain = $x[1];
         $sqlSelect = $db->select()->from('patient', 'person_id')->where('record_number = ?', $username);
         $personId = 0;
         if ($row = $db->fetchRow($sqlSelect)) {
             $personId = $row['person_id'];
         }
         $recipients[] = array('personId' => $personId, 'address' => $address, 'username' => $username, 'domain' => $domain);
     }
     file_put_contents('/tmp/smtp.log', "\ndata contents: " . print_r($dataContents, true), FILE_APPEND);
     foreach ($dataContents as $content) {
         $contentTypes = $content['contentTypes'];
         $filename = null;
         // email has an attachments
         if (isset($contentTypes['content-disposition']) && (isset($contentTypes['content-transfer-encoding']) && strtolower($contentTypes['content-transfer-encoding']) == 'base64')) {
             // temporarily accept base64 encoding that serves as an attachment
             $contentType = $contentTypes['content-type'];
             // image/jpeg; name="sample-signature.jpeg"
             $types = explode(';', $contentType);
             $mimeType = array_shift($types);
             foreach ($types as $type) {
                 $type = ltrim($type);
                 if (preg_match('/^name="(.*)"/', $type, $matches)) {
                     $filename = '/tmp/' . $matches[1];
                     break;
                 }
             }
             if ($filename === null) {
                 // try to create a random filename with specific extension based on mime type
                 $extension = MimeType::extension($mimeType);
                 $tmpFile = tempnam('/tmp', 'ch30_attach_');
                 $filename = $tmpFile . '.' . $extension;
                 //rename($tmpFile,$filename);
                 unlink($tmpFile);
             }
             $content['content'] = base64_decode($content['content']);
             // decode the base64 encoded file
         }
         foreach ($recipients as $recipient) {
             $personId = $recipient['personId'];
             $messagingId = WebVista_Model_ORM::nextSequenceId();
             $messaging = array();
             $messaging['note'] = 'Email message: ' . $content['content'];
             $attachmentId = 0;
             if ($filename !== null) {
                 $attachmentId = WebVista_Model_ORM::nextSequenceId();
                 $attachment = array();
                 $attachment['attachmentId'] = $attachmentId;
                 $attachment['attachmentReferenceId'] = md5($headers['messageId']);
                 $attachment['name'] = basename($filename);
                 $attachment['dateTime'] = date('Y-m-d H:i:s', strtotime($headers['date']));
                 $attachment['mimeType'] = $mimeType;
                 $attachment['md5sum'] = md5($content['content']);
                 $db->insert('attachments', $attachment);
                 $audit = array();
                 $audit['objectClass'] = 'Attachment';
                 $audit['objectId'] = $attachment['attachmentId'];
                 $audit['auditValues'] = $attachment;
                 Audit::persistManualAuditArray($audit);
                 $attachmentBlob = array();
                 $attachmentBlob['attachmentId'] = $attachment['attachmentId'];
                 $attachmentBlob['data'] = $content['content'];
                 $db->insert('attachmentBlobs', $attachmentBlob);
                 $messaging['note'] = 'Scanned document for ' . $recipient['address'];
             }
             $messaging['messagingId'] = $messagingId;
             $messaging['objectType'] = Messaging::TYPE_INBOUND_FAX;
             $messaging['status'] = 'Fax/Email Received';
             $messaging['dateStatus'] = date('Y-m-d H:i:s');
             $db->insert('messaging', $messaging);
             $messagingInboundFax = array();
             $messagingInboundFax['messagingId'] = $messaging['messagingId'];
             $messagingInboundFax['personId'] = $personId;
             $messagingInboundFax['mrn'] = $recipient['username'];
             $messagingInboundFax['subject'] = $headers['subject'];
             $messagingInboundFax['from'] = $headers['from'];
             $messagingInboundFax['to'] = $recipient['address'];
             $messagingInboundFax['messageId'] = $headers['messageId'];
             $messagingInboundFax['attachmentId'] = $attachmentId;
             $db->insert('messagingInboundFaxes', $messagingInboundFax);
             $audit = array();
             $audit['objectClass'] = 'MessagingInboundFax';
             $audit['objectId'] = $messagingInboundFax['messagingId'];
             $audit['auditValues'] = $messagingInboundFax;
             Audit::persistManualAuditArray($audit);
         }
     }
     unlink($this->messageFilename);
     return $this;
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:101,代码来源:HandleInboundMessages.php

示例10: _sendToPayer

 protected function _sendToPayer($claimId, $payerId)
 {
     $id = WebVista_Model_ORM::nextSequenceId('claimSequences');
     $userId = (int) Zend_Auth::getInstance()->getIdentity()->personId;
     $iterator = new ClaimLineIterator();
     $iterator->setFilters(array('claimId' => (int) $claimId));
     $visits = array();
     //$discountPayerId = InsuranceProgram::lookupSystemId('Discounts'); // ID of System->Discounts
     foreach ($iterator as $claimLine) {
         $oldPayerId = (int) $claimLine->insuranceProgramId;
         $claimLine->claimLineId = 0;
         $claimLine->claimId = $id;
         $claimLine->insuranceProgramId = (int) $payerId;
         $claimLine->dateTime = date('Y-m-d H:i:s');
         $oldBaseFee = (double) $claimLine->baseFee;
         $visitId = (int) $claimLine->visitId;
         if (!isset($visits[$visitId])) {
             $visit = new Visit();
             $visit->visitId = $visitId;
             $visit->populate();
             $visits[$visitId] = $visit;
         }
         $visit = $visits[$visitId];
         // recalculates baseFee for new payer
         $claimLine->recalculateBaseFee($visit);
         $newBaseFee = (double) $claimLine->baseFee;
         $claimLine->persist();
         // if new amount billed is less than than last amount billed then a writeoff is added to account for the difference
         if ($newBaseFee < $oldBaseFee) {
             $diff = $oldBaseFee - $newBaseFee;
             // add writeoffs
             $writeOff = new WriteOff();
             $writeOff->personId = (int) $visit->patientId;
             $writeOff->claimLineId = $claimLine->claimLineId;
             $writeOff->visitId = $visitId;
             $writeOff->appointmentId = $visit->appointmentId;
             $writeOff->amount = $diff;
             $writeOff->userId = $userId;
             $writeOff->timestamp = date('Y-m-d H:i:s');
             $writeOff->title = '';
             $writeOff->payerId = $oldPayerId;
             $writeOff->persist();
         }
     }
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:45,代码来源:ClaimsController.php

示例11: _processEdit

 protected function _processEdit()
 {
     $title = $this->_getParam('title');
     $message = $this->_getParam('message');
     $groupId = (int) $this->_getParam('groupId');
     $event = (int) $this->_getParam('event');
     $rules = $this->_getParam('rules');
     $ret = false;
     if (is_array($rules)) {
         $validIds = array();
         if ($groupId > 0) {
             $iterator = new ClaimRuleIterator();
             $iterator->setFilters(array('groupId' => $groupId));
             foreach ($iterator as $claimRule) {
                 if (!isset($rules[$claimRule->claimRuleId])) {
                     // delete  orphaned rule
                     $claimRule->setPersistMode(WebVista_Model_ORM::DELETE);
                     $claimRule->persist();
                 } else {
                     $validIds[$claimRule->claimRuleId] = $claimRule->claimRuleId;
                 }
             }
         } else {
             $groupId = WebVista_Model_ORM::nextSequenceId();
         }
         foreach ($rules as $claimRuleId => $value) {
             $claimRule = new ClaimRule();
             $claimRule->populateWithArray($value);
             if (isset($validIds[$claimRuleId])) {
                 $claimRule->claimRuleId = $claimRuleId;
             } else {
                 $claimRule->claimRuleId = 0;
                 $claimRule->dateTime = date('Y-m-d H:i:s');
             }
             $claimRule->title = $title;
             $claimRule->message = $message;
             $claimRule->groupId = $groupId;
             $claimRule->event = $event;
             $claimRule->persist();
         }
         $ret = true;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(true);
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:46,代码来源:ClaimRulesController.php

示例12: persistManualAuditArray

 public static function persistManualAuditArray(array $data)
 {
     $db = Zend_Registry::get('dbAdapter');
     $seqTable = Zend_Registry::get('config')->audit->sequence->table;
     if (!isset($data['auditId']) || !(int) $data['auditId'] > 0) {
         $data['auditId'] = WebVista_Model_ORM::nextSequenceId($seqTable);
     }
     $audit = array();
     $audit['auditId'] = (int) $data['auditId'];
     $audit['objectClass'] = isset($data['objectClass']) ? $data['objectClass'] : '';
     $audit['objectId'] = isset($data['objectId']) ? $data['objectId'] : '';
     $audit['userId'] = isset($data['userId']) ? $data['userId'] : '';
     $audit['patientId'] = isset($data['patientId']) ? $data['patientId'] : '';
     $audit['type'] = isset($data['type']) ? $data['type'] : WebVista_Model_ORM::REPLACE;
     $audit['message'] = isset($data['message']) ? $data['message'] : '';
     $audit['dateTime'] = isset($data['dateTime']) ? $data['dateTime'] : date('Y-m-d H:i:s');
     $audit['startProcessing'] = isset($data['startProcessing']) ? $data['startProcessing'] : '';
     $audit['endProcessing'] = isset($data['endProcessing']) ? $data['endProcessing'] : '';
     $audit['ipAddress'] = isset($data['ipAddress']) ? $data['ipAddress'] : '127.0.0.1';
     $db->insert('audits', $audit);
     if (isset($data['auditValues']) && is_array($data['auditValues'])) {
         foreach ($data['auditValues'] as $key => $value) {
             if (is_array($value)) {
                 $value = serialize($value);
             }
             $auditValue = array();
             $auditValue['auditValueId'] = WebVista_Model_ORM::nextSequenceId($seqTable);
             $auditValue['auditId'] = $audit['auditId'];
             $auditValue['key'] = $key;
             $auditValue['value'] = (string) $value;
             $db->insert('auditValues', $auditValue);
         }
     }
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:34,代码来源:Audit.php

示例13: buildDefaultGenericData

 public function buildDefaultGenericData(SimpleXMLElement $xml = null)
 {
     if ($xml === null) {
         if (!strlen($this->clinicalNoteDefinition->clinicalNoteTemplate->template) > 0) {
             $this->clinicalNoteDefinition->populate();
         }
         $xml = new SimpleXMLElement($this->clinicalNoteDefinition->clinicalNoteTemplate->template);
     }
     $revisionId = WebVista_Model_ORM::nextSequenceId();
     $nsdrData = array();
     if ((string) $xml->attributes()->useNSDR && (string) $xml->attributes()->useNSDR == 'true') {
         $nsdrData = ClinicalNote::getNSDRData($xml, $this, $revisionId);
     }
     $dateTime = date('Y-m-d H:i:s');
     foreach ($xml as $question) {
         foreach ($question as $key => $item) {
             if ($key != 'dataPoint') {
                 continue;
             }
             $namespace = NSDR2::extractNamespace((string) $item->attributes()->namespace);
             $name = preg_replace('/[-\\.]/', '_', $namespace);
             $value = '';
             if (strlen((string) $item->attributes()->templateText) > 0) {
                 $templateName = (string) $item->attributes()->templateText;
                 $view = Zend_Layout::getMvcInstance()->getView();
                 $value = $view->action('templated-text', 'template-text', null, array('personId' => $this->personId, 'templateName' => $templateName));
             }
             if ((string) $item->attributes()->default == true) {
                 $value = (string) $item->attributes()->value;
             }
             if (isset($nsdrData[$name])) {
                 $value = $nsdrData[$name];
             }
             $gd = new GenericData();
             $gd->objectClass = get_class($this);
             $gd->objectId = $this->clinicalNoteId;
             $gd->dateTime = $dateTime;
             $gd->name = $name;
             $gd->value = $value;
             $gd->revisionId = $revisionId;
             $gd->persist();
             //trigger_error('PERSISTED:'.print_r($gd->toArray(),true),E_USER_NOTICE);
         }
     }
     return $revisionId;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:46,代码来源:ClinicalNote.php

示例14: _checkTableData

 protected function _checkTableData($structure, $withSql = true)
 {
     $db = Zend_Registry::get('dbAdapter');
     $ret = false;
     $tableName = (string) $structure->attributes()->name;
     trigger_error("Checking data for table: {$tableName}", E_USER_NOTICE);
     $rows = array();
     foreach ($structure as $row) {
         if ((string) $row->getName() != 'row') {
             continue;
         }
         $ret = true;
         $tableColumns = $this->_tables[$tableName];
         $primaryKey = null;
         foreach ($row as $objType => $field) {
             $fieldName = (string) $field->attributes()->name;
             if ($objType != 'field' || !array_key_exists($fieldName, $tableColumns)) {
                 continue;
             }
             $fieldValue = (string) $field;
             if ($fieldName == 'guid') {
                 $sqlSelect = $db->select()->from($tableName)->where('guid != ?', '')->where('guid = ?', $fieldValue);
                 if ($guidRow = $db->fetchRow($sqlSelect)) {
                     // data already exists
                     continue 2;
                     // proceed to the outer loop
                 }
             }
             if (preg_match('/\\[@lastSequenceId(.*)\\]/', $fieldValue, $matches)) {
                 $key = -1;
                 if (strlen($matches[1]) > 0) {
                     $index = substr($matches[1], 1);
                     if (isset($this->_sequenceIds[$index])) {
                         $key = $index;
                     }
                 }
                 $fieldValue = $this->_sequenceIds[$key];
             }
             $tableColumns[$fieldName] = $fieldValue;
             if ($this->_tables[$tableName][$fieldName]['Key'] == 'PRI' && !isset($matches[1])) {
                 $primaryKey = $fieldName;
             }
         }
         if ($withSql && $primaryKey !== null) {
             if (preg_match('/\\[@nextSequenceId(.*)\\]/', $tableColumns[$primaryKey], $matches)) {
                 $tableColumns[$primaryKey] = WebVista_Model_ORM::nextSequenceId();
                 $key = -1;
                 if (strlen($matches[1]) > 0) {
                     $key = substr($matches[1], 1);
                 }
                 $this->_sequenceIds[$key] = $tableColumns[$primaryKey];
                 trigger_error('nextSequenceId generated for: ' . $tableName . '.' . $primaryKey, E_USER_NOTICE);
             }
         }
         $rows[] = $tableColumns;
     }
     $ctr = count($rows);
     if ($ctr > 0) {
         $this->_changes[] = $ctr . ' insert statements to table ' . $tableName;
     }
     if (!$withSql) {
         return $ret;
     }
     $columnNames = array();
     foreach ($this->_tables[$tableName] as $fieldName => $col) {
         $columnNames[] = $db->quoteIdentifier($fieldName);
     }
     $sql = "INSERT INTO " . $db->quoteTableAs($tableName) . " (" . implode(',', $columnNames) . ") VALUES";
     foreach ($rows as $row) {
         $sql .= PHP_EOL . '(' . $db->quote($row) . '),';
     }
     $sql = substr($sql, 0, -1) . ';' . PHP_EOL;
     return $sql;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:74,代码来源:AlterTable.php

示例15: _checkTableDataRow

 protected function _checkTableDataRow()
 {
     $data = $this->_tdRowData;
     $db = Zend_Registry::get('dbAdapter');
     $tableName = isset($this->_tdData['attribs']['name']) ? $this->_tdData['attribs']['name'] : '';
     //trigger_error("Checking data for table: $tableName",E_USER_NOTICE);
     $rows = array();
     $ret = true;
     $tableColumns = isset($this->_tables[$tableName]) ? $this->_tables[$tableName] : array();
     if ($tableColumns === true) {
         $tableColumns = array();
     }
     $primaryKey = null;
     $guidRow = null;
     foreach ($data['data'] as $val) {
         $fieldName = isset($val['attribs']['name']) ? $val['attribs']['name'] : '';
         if (isset($this->_tables[$tableName]) && isset($this->_tables[$tableName][$fieldName]) && $this->_tables[$tableName][$fieldName]['Key'] == 'PRI') {
             $primaryKey = $fieldName;
         }
         $objType = isset($val['name']) ? $val['name'] : '';
         if ($objType != 'field' || !array_key_exists($fieldName, $tableColumns)) {
             continue;
         }
         $fieldValue = isset($val['value']) ? $val['value'] : '';
         if ($fieldName == 'guid') {
             $sqlSelect = $db->select()->from($this->_dbName . '.' . $tableName)->where('guid != ?', '')->where('guid = ?', $fieldValue);
             if ($guidRow = $db->fetchRow($sqlSelect)) {
                 // data already exists
                 if ($this->_withSql && $primaryKey !== null) {
                     if (preg_match('/\\[@nextSequenceId=(\\d+)\\]/', $tableColumns[$primaryKey], $matches)) {
                         $tableColumns[$primaryKey] = $guidRow['enumerationId'];
                         $key = -1;
                         if (strlen($matches[1]) > 0) {
                             $key = $matches[1];
                         }
                         $this->_sequenceIds[$key] = $tableColumns[$primaryKey];
                         $this->_existingEnums[$tableColumns[$primaryKey]] = $tableColumns[$primaryKey];
                     }
                 }
             }
         }
         if (preg_match_all('/\\[@lastSequenceId=(\\d+)\\]/', $fieldValue, $matches)) {
             $key = -1;
             if (strlen($matches[1][0]) > 0) {
                 $index = $matches[1][0];
                 if (isset($this->_sequenceIds[$index])) {
                     $key = $index;
                 }
             }
             if (count($matches[1]) > 1) {
                 foreach ($matches[1] as $match) {
                     $index = -1;
                     if (isset($this->_sequenceIds[$match])) {
                         $index = $match;
                     }
                     $fieldValue = preg_replace('/\\[@lastSequenceId=' . $match . '\\]/mi', $this->_sequenceIds[$index], $fieldValue);
                 }
             } else {
                 $fieldValue = $this->_sequenceIds[$key];
             }
         }
         $tableColumns[$fieldName] = $fieldValue;
     }
     if ($this->_withSql && $primaryKey !== null) {
         if (preg_match('/\\[@nextSequenceId=(\\d+)\\]/', $tableColumns[$primaryKey], $matches)) {
             $tableColumns[$primaryKey] = WebVista_Model_ORM::nextSequenceId();
             $key = -1;
             if (strlen($matches[1]) > 0) {
                 $key = $matches[1];
             }
             $this->_sequenceIds[$key] = $tableColumns[$primaryKey];
             trigger_error('nextSequenceId generated for: ' . $tableName . '.' . $primaryKey, E_USER_NOTICE);
         }
     }
     if (!isset($this->_tableColumnsCtr[$tableName])) {
         $this->_tableColumnsCtr[$tableName] = 0;
     }
     if (!($guidRow || $tableName == 'enumerationsClosure' && isset($tableColumns['descendant']) && isset($this->_existingEnums[$tableColumns['descendant']]))) {
         $this->_tableColumnsCtr[$tableName]++;
         if (!$this->_withSql) {
             return '';
         }
         //trigger_error(print_r($tableColumns,true));
         $row = array();
         foreach ($this->_tables[$tableName] as $columnName => $col) {
             // making sure row columns are in order
             $row[$columnName] = isset($tableColumns[$columnName]) && is_string($tableColumns[$columnName]) ? $tableColumns[$columnName] : '';
         }
         if ($this->_tdFirstRow) {
             $this->_tdFirstRow = false;
         }
         fwrite($this->_fd, $this->_sqlInsert . "(" . $db->quote($row) . ');');
     }
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:94,代码来源:AlterTable.php


注:本文中的WebVista_Model_ORM::nextSequenceId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。