Cake\Database\ValueBinder::placeholder PHP Method

placeholder() public method

Creates a unique placeholder name if the token provided does not start with ":" otherwise, it will return the same string and internally increment the number of placeholders generated by this object.
public placeholder ( string $token ) : string
$token string string from which the placeholder will be derived from, if it starts with a colon, then the same string is returned
return string to be used as a placeholder in a query expression
    public function placeholder($token)
    {
        $number = $this->_bindingsCount++;
        if ($token[0] !== ':' || $token !== '?') {
            $token = sprintf(':c%s', $number);
        }
        return $token;
    }

Usage Example

Beispiel #1
0
 /**
  * Registers a value in the placeholder generator and returns the generated
  * placeholder
  *
  * @param \Cake\Database\ValueBinder $generator The value binder
  * @param mixed $value The value to bind
  * @param string $type The type to use
  * @return string generated placeholder
  */
 protected function _bindValue($generator, $value, $type)
 {
     $placeholder = $generator->placeholder('tuple');
     $generator->bind($placeholder, $value, $type);
     return $placeholder;
 }
All Usage Examples Of Cake\Database\ValueBinder::placeholder