lithium\data\source\Database::renderCommand PHP Method

renderCommand() public method

Returns a given type statement for the given data, rendered from Database::$_strings.
public renderCommand ( string $type, string $data = null, string $context = null ) : string
$type string One of `'create'`, `'read'`, `'update'`, `'delete'` or `'join'`.
$data string The data to replace in the string.
$context string
return string
    public function renderCommand($type, $data = null, $context = null)
    {
        if (is_object($type)) {
            $context = $type;
            $data = $context->export($this);
            $type = $context->type();
        }
        if (!isset($this->_strings[$type])) {
            throw new InvalidArgumentException("Invalid query type `{$type}`.");
        }
        $template = $this->_strings[$type];
        $data = array_filter($data);
        $placeholders = array();
        foreach ($data as $key => $value) {
            $placeholders[$key] = "{{$key}}";
        }
        $template = String::insert($template, $placeholders, array('clean' => true));
        return trim(String::insert($template, $data, array('before' => '{')));
    }