Changeset 764
- Timestamp:
- Mar 12, 2022 11:19:03 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Version.inc.php
r637 r764 202 202 * @param string $record_val The value of the key column for the record. 203 203 * @param string $title The title of this record. Only used for human presentation. 204 * @param array $merge Array of values to merge with the current record values (use this to force 'key' to be an empty string in a saved version, e.g., ['key' => '']). 204 205 * 205 206 * @return int The id for the version (mysql last insert id). 206 207 */ 207 public function create($record_table, $record_key, $record_val, $title='', $notes='' )208 public function create($record_table, $record_key, $record_val, $title='', $notes='', Array $merge=[]) 208 209 { 209 210 $app =& App::getInstance(); … … 213 214 214 215 // Get current record. 215 if (!$record = $this->getCurrent($record_table, $record_key, $record_val )) {216 if (!$record = $this->getCurrent($record_table, $record_key, $record_val, $merge)) { 216 217 $app->logMsg(sprintf('Could not create %s version, record not found: %s, %s, %s.', $title, $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__); 217 218 return false; … … 560 561 * Get the current record data from the original table. 561 562 * 562 * @param string $version_id The id of the version to restore. 563 * 564 * @return mixed Array of data saved in version, or false if none. 565 */ 566 public function getCurrent($record_table, $record_key, $record_val) 563 * @param string $record_table The table containing the record. 564 * @param string $record_key The key column for the record. 565 * @param string $record_val The value of the key column for the record. 566 * @param array $merge Array of values to merge with the current record values (use this to redact certain values, e.g., ['key' => '']). 567 * 568 * @return mixed Array of data from the current database record. 569 */ 570 public function getCurrent($record_table, $record_key, $record_val, Array $merge=[]) 567 571 { 568 572 $db =& DB::getInstance(); … … 581 585 "); 582 586 if ($record = mysql_fetch_assoc($qid)) { 583 return $record;587 return array_merge($record, $merge); 584 588 } else { 585 589 return false;
Note: See TracChangeset
for help on using the changeset viewer.