TParameterMap holds one or more parameter child elements that map object properties to placeholders in a SQL statement. A TParameterMap defines an ordered list of values that match up with the placeholders of a parameterized query statement. While the attributes specified by the map still need to be in the correct order, each parameter is named. You can populate the underlying class in any order, and the TParameterMap ensures each value is passed in the correct order. Parameter Maps can be provided as an external element and inline. The element accepts two attributes: id (required) and extends (optional).
Since: 3.1
Inheritance: extends Prado\TComponent
 /**
  * Extract inline parameter maps.
  * @param TSqlMapStatement statement object.
  * @param string sql text
  * @param SimpleXmlElement statement node.
  */
 protected function applyInlineParameterMap($statement, $sqlStatement, $node)
 {
     $scope['file'] = $this->_configFile;
     $scope['node'] = $node;
     $sqlStatement = preg_replace(self::ESCAPED_INLINE_SYMBOL_REGEXP, self::INLINE_PLACEHOLDER, $sqlStatement);
     if ($statement->parameterMap() === null) {
         // Build a Parametermap with the inline parameters.
         // if they exist. Then delete inline infos from sqltext.
         $parameterParser = new TInlineParameterMapParser();
         $sqlText = $parameterParser->parse($sqlStatement, $scope);
         if (count($sqlText['parameters']) > 0) {
             $map = new TParameterMap();
             $map->setID($statement->getID() . '-InLineParameterMap');
             $statement->setInlineParameterMap($map);
             foreach ($sqlText['parameters'] as $property) {
                 $map->addProperty($property);
             }
         }
         $sqlStatement = $sqlText['sql'];
     }
     $sqlStatement = preg_replace('/' . self::INLINE_PLACEHOLDER . '/', self::INLINE_SYMBOL, $sqlStatement);
     $this->prepareSql($statement, $sqlStatement, $node);
 }
Beispiel #2
0
 /**
  * @param TParameterMap add a new parameter map to this SQLMap.
  * @throws TSqlMapDuplicateException
  */
 public function addParameterMap(TParameterMap $parameter)
 {
     $key = $parameter->getID();
     if ($this->_parameterMaps->contains($key) == true) {
         throw new TSqlMapDuplicateException('sqlmap_already_contains_parameter_map', $key);
     }
     $this->_parameterMaps->add($key, $parameter);
 }