本文整理汇总了PHP中Doctrine\ORM\Query\SqlWalker::walkArithmeticPrimary方法的典型用法代码示例。如果您正苦于以下问题:PHP SqlWalker::walkArithmeticPrimary方法的具体用法?PHP SqlWalker::walkArithmeticPrimary怎么用?PHP SqlWalker::walkArithmeticPrimary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query\SqlWalker
的用法示例。
在下文中一共展示了SqlWalker::walkArithmeticPrimary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSql
/**
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker
*
* @return string
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
// use second parameter if parsed
if (null !== $this->fmt) {
return sprintf('TRUNC(%s, %s)', $sqlWalker->walkArithmeticPrimary($this->date), $sqlWalker->walkArithmeticPrimary($this->fmt));
}
return sprintf('TRUNC(%s)', $sqlWalker->walkArithmeticPrimary($this->date));
}
示例2: getSql
public function getSql(SqlWalker $sqlWalker)
{
$p = $sqlWalker->getConnection()->getDatabasePlatform();
$pi = $p->getPiExpression();
// %F * ASIN(SQRT(POWER(SIN((%s - %s) * PI()/360), 2) + COS(%s * PI()/180) * COS(%s * PI()/180) * POWER(SIN((%s - %s) * PI()/360), 2)))
$formula = "%F * ({$pi} / 2 - " . $p->getAcosExpression($p->getSqrtExpression('(' . $p->getSinExpression("(%s - %s) * {$pi} / 360") . ' * ' . $p->getSinExpression("(%s - %s) * {$pi} / 360") . ') + (' . $p->getCosExpression("%s * {$pi} / 180") . ' * ' . $p->getCosExpression("%s * {$pi} / 180") . ' * ' . $p->getSinExpression("(%s - %s) * {$pi} / 360") . ' * ' . $p->getSinExpression("(%s - %s) * {$pi} / 360") . ')')) . ')';
return sprintf($formula, Measure::EARTH_RADIUS_KM * 2.0, $sqlWalker->walkArithmeticPrimary($this->latOrigin), $sqlWalker->walkArithmeticPrimary($this->latPoint), $sqlWalker->walkArithmeticPrimary($this->latOrigin), $sqlWalker->walkArithmeticPrimary($this->latPoint), $sqlWalker->walkArithmeticPrimary($this->latOrigin), $sqlWalker->walkArithmeticPrimary($this->latPoint), $sqlWalker->walkArithmeticPrimary($this->lonOrigin), $sqlWalker->walkArithmeticPrimary($this->lonPoint), $sqlWalker->walkArithmeticPrimary($this->lonOrigin), $sqlWalker->walkArithmeticPrimary($this->lonPoint));
}
示例3: getSql
public function getSql(SqlWalker $sqlWalker)
{
$args = array_map(function ($value) use($sqlWalker) {
return $sqlWalker->walkArithmeticPrimary($value);
}, $this->values);
return 'GREATEST(' . implode(', ', $args) . ')';
}
示例4: getSql
public function getSql(SqlWalker $sqlWalker)
{
$args = array_map(function ($value) use($sqlWalker) {
$nodeSql = $sqlWalker->walkArithmeticPrimary($value);
return $this->notEmpty ? sprintf("NULLIF(%s, '')", $nodeSql) : $nodeSql;
}, $this->values);
return 'CONCAT_WS(' . implode(', ', $args) . ')';
}
示例5: getSql
/**
* @override
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
$sql = "WEEK(" . $sqlWalker->walkArithmeticPrimary($this->date);
if ($this->mode != null) {
$sql .= ", " . $sqlWalker->walkLiteral($this->mode);
}
$sql .= ")";
return $sql;
}
示例6: getSql
/**
* Get sql
*
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker
* @return string
*/
public function getSql(SqlWalker $sqlWalker)
{
/*
* Giving each argument only once and using %1$s, %2$s, ... doesn't work. Would result in:
* SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
*/
// formula adapted from http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL
// originally returns distance in miles: 3956 * 2 * ASIN(SQRT(POWER(SIN((orig.lat - dest.lat) * PI()/180 / 2), 2) + COS(orig.lat * PI()/180) * COS(dest.lat * PI()/180) * POWER(SIN((orig.lon - dest.lon) * PI()/180 / 2), 2)))
return sprintf('ASIN(SQRT(POWER(SIN((%s - %s) * PI()/360), 2) + COS(%s * PI()/180) * COS(%s * PI()/180) * POWER(SIN((%s - %s) * PI()/360), 2))) * (%s *2)', $sqlWalker->walkArithmeticPrimary($this->latitudeOrigin), $sqlWalker->walkArithmeticPrimary($this->latitudeDestination), $sqlWalker->walkArithmeticPrimary($this->latitudeOrigin), $sqlWalker->walkArithmeticPrimary($this->latitudeDestination), $sqlWalker->walkArithmeticPrimary($this->longitudeOrigin), $sqlWalker->walkArithmeticPrimary($this->longitudeDestination), $sqlWalker->walkArithmeticPrimary($this->radius));
}
示例7: getSql
/**
* {@inheritdoc}
*/
public function getSql(SqlWalker $sqlWalker)
{
/*
* formula adapted from http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL
* originally returns distance in miles: 3956 * 2 * ASIN(SQRT(POWER(SIN((orig.lat - dest.lat) * PI()/180 / 2), 2) + COS(orig.lat * PI()/180) * COS(dest.lat * PI()/180) * POWER(SIN((orig.lon - dest.lon) * PI()/180 / 2), 2)))
*/
return sprintf('12756 * ASIN(SQRT(POWER(SIN((%s::numeric - %s::numeric) * PI()/360), 2) + COS(%s::numeric * PI()/180) * COS(%s::numeric * PI()/180) * POWER(SIN((%s::numeric - %s::numeric) * PI()/360), 2)))', $sqlWalker->walkArithmeticPrimary($this->parameters['latOrigin']), $sqlWalker->walkArithmeticPrimary($this->parameters['latDestination']), $sqlWalker->walkArithmeticPrimary($this->parameters['latOrigin']), $sqlWalker->walkArithmeticPrimary($this->parameters['latDestination']), $sqlWalker->walkArithmeticPrimary($this->parameters['lngOrigin']), $sqlWalker->walkArithmeticPrimary($this->parameters['lngDestination']));
}
示例8: getSql
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
$separator = array_shift($this->values)->simpleArithmeticExpression->value;
// Create an array to hold the query elements.
$queryBuilder = array('(');
// Iterate over the captured expressions and add them to the query.
for ($i = 0; $i < count($this->values); $i++) {
if ($i > 0) {
$queryBuilder[] = " || '{$separator}' || ";
}
// Dispatch the walker on the current node.
$queryBuilder[] = sprintf("IFNULL(%s, '')", $sqlWalker->walkArithmeticPrimary($this->values[$i]));
}
// Close the query.
$queryBuilder[] = ')';
// Return the joined query.
return implode('', $queryBuilder);
}
示例9: getSql
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
// Create an array to hold the query elements.
$queryBuilder = array('CONCAT_WS(');
// Iterate over the captured expressions and add them to the query.
for ($i = 0; $i < count($this->values); $i++) {
if ($i > 0) {
$queryBuilder[] = ', ';
}
// Dispatch the walker on the current node.
$nodeSql = $sqlWalker->walkArithmeticPrimary($this->values[$i]);
if ($this->notEmpty) {
// Exclude empty strings from the concatenation.
$nodeSql = sprintf("NULLIF(%s, '')", $nodeSql);
}
$queryBuilder[] = $nodeSql;
}
// Close the query.
$queryBuilder[] = ')';
// Return the joined query.
return implode('', $queryBuilder);
}
示例10: getSql
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'HOUR(' . $sqlWalker->walkArithmeticPrimary($this->date) . ')';
}
示例11: getSql
public function getSql(SqlWalker $sqlWalker)
{
return sprintf('IF(%s, %s, %s)', $sqlWalker->walkConditionalExpression($this->expr[0]), $sqlWalker->walkArithmeticPrimary($this->expr[1]), $sqlWalker->walkArithmeticPrimary($this->expr[2]));
}
示例12: getSql
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return sprintf('EXTRACT(YEAR FROM %s)', $sqlWalker->walkArithmeticPrimary($this->date));
}
示例13: getSql
/**
* @param \Doctrine\ORM\Query\SqlWalker $sqlWalker
*
* @return string
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'SUBTIME(' . $sqlWalker->walkArithmeticPrimary($this->timeExpression) . ',
' . $sqlWalker->walkArithmeticPrimary($this->timeExpression2) . ')';
}
示例14: getSql
/**
* @param SqlWalker $sqlWalker
* @return string
*/
public function getSql(SqlWalker $sqlWalker)
{
return "MONTH(" . $sqlWalker->walkArithmeticPrimary($this->date) . ")";
}
示例15: getSql
public function getSql(SqlWalker $sqlWalker)
{
return sprintf('%s * ASIN(SQRT(POWER(SIN((%s - %s) * PI()/360), 2) + COS(%s * PI()/180) * COS(%s * PI()/180) * POWER(SIN((%s - %s) * PI()/360), 2)))', self::EARTH_DIAMETER, $sqlWalker->walkArithmeticPrimary($this->latitudeOrigin), $sqlWalker->walkArithmeticPrimary($this->latitudeDestination), $sqlWalker->walkArithmeticPrimary($this->latitudeOrigin), $sqlWalker->walkArithmeticPrimary($this->latitudeDestination), $sqlWalker->walkArithmeticPrimary($this->longitudeOrigin), $sqlWalker->walkArithmeticPrimary($this->longitudeDestination));
}