for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ORM\Dbal;
trait Escaping
{
/** @var string */
protected $quotingCharacter = '"';
protected $identifierDivider = '.';
protected $booleanTrue = '1';
protected $booleanFalse = '0';
/**
* Extract content from parenthesis in $type
*
* @param string $type
* @return string
*/
protected function extractParenthesis($type)
if (preg_match('/\((.+)\)/', $type, $match)) {
return $match[1];
}
return null;
* Escape a string for query
* @param string $value
protected function escapeString($value)
return $this->entityManager->getConnection()->quote($value);
* Escape an integer for query
* @param int $value
protected function escapeInteger($value)
return (string) $value;
* Escape a double for Query
* @param double $value
protected function escapeDouble($value)
* Escape NULL for query
protected function escapeNULL()
return 'NULL';
* Escape a boolean for query
* @param bool $value
protected function escapeBoolean($value)
return ($value) ? $this->booleanTrue : $this->booleanFalse;
* Escape a date time object for query
* @param \DateTime $value
* @return mixed
protected function escapeDateTime(\DateTime $value)
$value->setTimezone(new \DateTimeZone('UTC'));
return $this->escapeString($value->format('Y-m-d\TH:i:s.u\Z'));