Unfortunately, the quoteInto() method was removed with the introduction of the new Zend\Db in ZF 2.0. And there is no equivalent that has exactly the same behavior.
In ZF2, there is a quoteValue() method. This method takes a single value as a parameter and then quotes the value, so you can safely put it in an SQL query as a value.
However, you can use quoteValue() to replicate the behavior of the ZF1 quoteInto() method. You can simply take the code of the quoteInto() method from ZF1 and apply the quoteValue() method from the platform object in ZF2 to it:
// modified quoteInto() function for ZF2 function quoteInto($text, $value, $platform, $count = null) { if ($count === null) { return str_replace('?', $platform->quoteValue($value), $text); } else { while ($count > 0) { if (strpos($text, '?') !== false) { $text = substr_replace($text, $platform->quoteValue($value), strpos($text, '?'), 1); } --$count; } return $text; } }
There are some differences. ZF1 has the $type parameter, but because of the way ZF2 works with these things, the type parameter doesn't make much sense. And there is a $platform parameter, because this method has a platform dependency for the quoteValue() method.
kokx
source share