Solar_Sql_Adapter_Mysql::quote()

public string Solar_Sql_Adapter_Mysql::quote ( mixed $val )

Safely quotes a value for an SQL statement.

Inherited from Solar_Sql_Adapter.

Parameters

  • (mixed) $val: The value to quote.

Returns

  • (string) An SQL-safe quoted value (or a string of separated-and-quoted values).

Description

Safely quotes a value for an SQL statement.

If an array is passed as the value, the array values are quoted and then returned as a comma-separated string; this is useful for generating IN() lists.

<?php
$sql = Solar::factory('Solar_Sql');

$safe = $sql->quote('foo"bar"');
// $safe == "'foo\"bar\"'"

$safe = $sql->quote(array('one', 'two', 'three'));
// $safe == "'one', 'two', 'three'"


Local