Get the appropriate query parameter place-holder for a value.

@param  mixed   $value
@return string
353266
public function parameter($value)
	{

        // Validate whether the requested field is the
        // node id, in that case id(n) doesn't work as
        // a placeholder so we transform it to the id replacement instead.

        // When coming from a WHERE statement we'll have to pluck out the column
        // from the collected attributes.

        if (is_bool($value)) {
            // For the boolean column this need to be un-quote unless orientdb will reject
            return $value ? 'true' : 'false';
        }
        elseif(is_array($value) && isset($value['binding']))
        {
            $value = $value['binding'];
        }
        elseif (is_array($value) && isset($value['column']))
        {
            $value = $value['column'];
        }
        elseif ($this->isExpression($value))
        {
            $value = $this->getValue($value);
        }

        $property = $this->getIdReplacement($value);

        if (strpos($property, '.') !== false) $property = explode('.', $property)[1];
        
        if(is_string($property) && is_array(json_decode($property, true)) && (json_last_error() == JSON_ERROR_NONE))
        {// Don't wrap json data
            return $property;
        }
        
        $property = str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $property);

        if(preg_match('~#(-)?[0-9]+:[0-9]+~', $property)) {//is (graph) id, don't wrap it or error would be thrown
            return $property;
        }

		return "'" . $property . "'";
	}
343337
protected function getDataTypeByValue($value)
    {
        if(null === $value)
        {
            return \PDO::PARAM_NULL;
        }
        if(is_bool($value))
        {
            return \PDO::PARAM_BOOL;
        }
        if(is_int($value))
        {
            return \PDO::PARAM_INT;
        }
        return \PDO::PARAM_STR;
    }
452809
protected function getQuoteValue($value): string
    {
        $key = uniqid();
        $this->builder->setParameter($key, $value);

        return ":{$key}";
    }
855428
public function parse_value($value) {
        global $COURSE, $DB;

        if (strpos($value, '$ToolProxyBinding.memberships.url') !== false) {
            if ($COURSE->id === SITEID) {
                $this->params['context_type'] = 'Group';
            } else {
                $this->params['context_type'] = 'CourseSection';
            }
            $this->params['context_id'] = $COURSE->id;

            $id = optional_param('id', 0, PARAM_INT); // Course Module ID.
            if (!empty($id)) {
                $cm = get_coursemodule_from_id('lti', $id, 0, false, IGNORE_MISSING);
                $lti = $DB->get_record('lti', array('id' => $cm->instance), 'typeid', IGNORE_MISSING);
                if ($lti && !empty($lti->typeid)) {
                    $this->params['tool_code'] = $lti->typeid;
                }
            }
            $value = str_replace('$ToolProxyBinding.memberships.url', parent::get_endpoint(), $value);
        }
        return $value;

    }
209721
public function getAvatarUrlAttribute(string $value = null)
    {
        if ($value && strpos($value, '://') === false) {
            return app(UrlGenerator::class)->to('forum')->path('assets/avatars/'.$value);
        }

        return $value;
    }
200651
public function parse_value($value) {
        if (strpos($value, '$ToolConsumerProfile.url') !== false) {
            $value = str_replace('$ToolConsumerProfile.url', $this->get_endpoint(), $value);
        }
        return $value;

    }
952185
public function visitPlaceholderValue(Value\PlaceholderValue $value)
    {
        if ($value->isClosedRecursion()) {
            $nullValue = new Value\NullValue;
            $value->innerValue()->setInnerValue($nullValue);

            return $nullValue;
        }

        while ($value instanceof Value\PlaceholderValue) {
            $value = $value->innerValue();
        }

        return $value;
    }
1310957
public function transform($value): ?string
    {
        /** TODO add sanity check is array of Location object? */
        if (!is_array($value) || empty($value)) {
            return null;
        }

        return implode(',', array_column($value, 'id'));
    }
1113923
public function getSqlType($value)
    {
        if ('boolean' === gettype($value)) {
            return $this->connection->getDatabasePlatform()->convertBooleans($value);
        } elseif (null === $value || 'null' === $value) {
            return 'NULL';
        }

        return $this->connection->quote($value);
    }
829390
public function evaluateFieldValue(string $value): string
    {
        // 1) Special case: * means any domain
        if ($value === '*') {
            return $value;
        }

        // 2) Check if value contains a protocol like http:// https:// etc...
        if (strpos($value, '://') !== false) {
            $tmp = $this->parseUrl($value);
            if (!empty($tmp)) {
                return $tmp;
            }
        }

        // 3) Check domain name
        // remove anything after the first "/"
        $checkValue = $value;
        if (strpos($value, '/') !== false) {
            $checkValue = substr($value, 0, strpos($value, '/'));
        }
        $validHostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/';
        if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) {
            if (!empty($matches)) {
                return $checkValue;
            }
        }

        // 4) IPv4 or IPv6
        $isIP = filter_var($value, FILTER_VALIDATE_IP) === $value;
        if ($isIP) {
            return $value;
        }

        return '';
    }
488491
protected function _query($value) 
    { 
        /**
         * Check for an adapter being defined. if not, fetch the default adapter.
         */ 
        if($this->_adapter === null) {
            $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
        }

        /**
         * Build select object
         */ 
        $select = new Zend_Db_Select($this->_adapter);
        $select->from($this->_table)
               ->columns($this->_field)
               ->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value); 
        if ($this->_exclude !== null) { 
            if (is_array($this->_exclude)) { 
                $select->where($this->_adapter->quoteIdentifier($this->_exclude['field']).' != ?', $this->_exclude['value']); 
            } else { 
                $select->where($this->_exclude); 
            } 
        } 
        $select->limit(1); 
                 
        /**
         * Run query
         */ 
        $result = $this->_adapter->fetchRow($select, array(), Zend_Db::FETCH_ASSOC); 
         
        return $result; 
    }
687808
public function getFilterValue($value)
    {
        if (($value !== 0 && $value !== '0' && empty($value)) || (is_string($value) && trim($value) === '')) {
            return false;
        } else {
            return $value;
        }
    }
1014207
protected function getImagesPerPageArg( $value = null )
	{
		$perPage = $this->getValue( 'images_per_page', $value );

		if( !is_numeric( $perPage ) && is_string( $perPage )) {
			$perPage = $this->postmeta->get( $perPage );
		}
		return !!intval( $perPage )
			? $perPage
			: -1;
	}
945116
protected function resolveValue($value)
    {
        if (is_array($value)) {
            foreach ($value as $index => $val) {
                $value[$index] = $this->resolveValue($val);
            }

            return $value;
        }

        if (is_string($value) && '@' == $value[0]) {
            return $this->offsetGet(substr($value, 1));
        }

        return $value;
    }
290352
protected function getQueryOperator($value)
    {
        $fb = new FilterBuilder();
        $operator = $fb->bitwiseAnd($this->getEnumAttribute(), $this->getFlagEnum()->getValue());
        $value = $this->options['invert'] ? !$value : $value;

        return $value ? $operator : $fb->bNot($operator);
    }
1366510
private function argValue($value) {
        if (is_bool($value)) {
            return (int)$value;
        } elseif ($value instanceof \DateTimeInterface) {
            return $value->format(self::MYSQL_DATE_FORMAT);
        } else {
            return $value;
        }
    }
882344
protected function formatValue($value)
    {
        $formatted_value = '<unknown parameter type>';

        if (is_object($value)) {
            $formatted_value = '<' . get_class($value) . ' object>';
        } elseif ($value === null) {
            $formatted_value = '<null>';
        } elseif (is_string($value)) {
            if (SwatString::validateUtf8($value)) {
                $formatted_value = "'" . $value . "'";
            } else {
                $formatted_value = '"' . SwatString::escapeBinary($value) . '"';
            }
        } elseif (is_int($value) || is_float($value)) {
            $formatted_value = strval($value);
        } elseif (is_bool($value)) {
            $formatted_value = $value ? 'true' : 'false';
        } elseif (is_resource($value)) {
            $formatted_value = '<resource>';
        } elseif (is_array($value)) {
            // check whether or not array is associative
            $keys = array_keys($value);
            $associative = false;
            $count = 0;
            foreach ($keys as $key) {
                if ($key !== $count) {
                    $associative = true;
                    break;
                }
                $count++;
            }

            $formatted_value = 'array(';

            $count = 0;
            foreach ($value as $key => $the_value) {
                if ($count > 0) {
                    $formatted_value .= ', ';
                }

                if ($associative) {
                    $formatted_value .= $this->formatValue($key);
                    $formatted_value .= ' => ';
                }
                $formatted_value .= $this->formatValue($the_value);
                $count++;
            }
            $formatted_value .= ')';
        }

        return $formatted_value;
    }