Example #1
0
	/**
	 * Replace table values
	 *
	 * @param  string $input Table value
	 * @return string
	 */
	public function replaceTableValues($input)
	{
		$old = $this->getOldReplaceValues();
		$new = $this->getNewReplaceValues();

		$oldValues = array();
		$newValues = array();

		// Replace strings
		for ($i = 0; $i < count($old); $i++) {
			if (!empty($old[$i]) && ($old[$i] != $new[$i]) && !in_array($old[$i], $oldValues)) {
				$oldValues[] = $old[$i];
				$newValues[] = $new[$i];
			}
		}

		// Replace table prefix
		$oldValues[] = $this->getOldTablePrefix();
		$newValues[] = $this->getNewTablePrefix();

		// Replace table values
		$input = str_replace($oldValues, $newValues, $input);

		// Verify serialization
		return MysqlUtility::pregReplace(
			$input,
			'/s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");/'
		);
	}