Doctrine 1.2.4
Doctrine_Expression_Mssql Class Reference

Inherits Doctrine_Expression_Driver.

Public Member Functions

 __call ($m, $a)
 
 acos ($value)
 
 add (array $args)
 
 avg ($column)
 
 between ($expression, $value1, $value2)
 
 coalesce ()
 
 concat ()
 
 cos ($value)
 
 count ($column)
 
 div (array $args)
 
 eq ($value1, $value2)
 
 getConnection ()
 
 getModuleName ()
 
 gt ($value1, $value2)
 
 gte ($value1, $value2)
 
 guid ()
 
 in ($column, $values)
 
 isNotNull ($expression)
 
 isNull ($expression)
 
 length ($column)
 
 locate ($str, $substr)
 
 lower ($str)
 
 lt ($value1, $value2)
 
 lte ($value1, $value2)
 
 ltrim ($str)
 
 max ($column)
 
 md5 ($column)
 
 min ($column)
 
 mod ($expression1, $expression2)
 
 mul (array $args)
 
 neq ($value1, $value2)
 
 not ($expression)
 
 now ($type= 'timestamp')
 
 now ()
 
 pi ()
 
 regexp ()
 
 round ($column, $decimals=0)
 
 rtrim ($str)
 
 sin ($value)
 
 soundex ($value)
 
 sub (array $args)
 
 substring ($value, $position, $length=null)
 
 sum ($column)
 
 trim ($str)
 
 upper ($str)
 

Detailed Description

Definition at line 33 of file Mssql.php.

Member Function Documentation

Doctrine_Expression_Driver::__call (   $m,
  $a 
)
inherited

__call

for all native RDBMS functions the function name itself is returned

Definition at line 639 of file Driver.php.

{
if ($this->conn->getAttribute(Doctrine_Core::ATTR_PORTABILITY) & Doctrine_Core::PORTABILITY_EXPR) {
throw new Doctrine_Expression_Exception('Unknown expression: ' . $m);
}
return $m . '(' . implode(', ', $a) . ')';
}
Doctrine_Expression_Driver::acos (   $value)
inherited

returns arcus cosine SQL string

Returns
string

Definition at line 585 of file Driver.php.

{
return 'ACOS(' . $value . ')';
}
Doctrine_Expression_Driver::add ( array  $args)
inherited

Returns the SQL to add values or expressions together.

add() accepts an arbitrary number of parameters. Each parameter must contain a value or an expression or an array with values or expressions.

Parameters
string|array(string)
Returns
string an expression

Definition at line 360 of file Driver.php.

{
return $this->basicMath('+', $args);
}
Doctrine_Expression_Driver::avg (   $column)
inherited

Returns the average value of a column

Parameters
string$columnthe column to use
Returns
string generated sql including an AVG aggregate function

Definition at line 62 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'AVG(' . $column . ')';
}
Doctrine_Expression_Driver::between (   $expression,
  $value1,
  $value2 
)
inherited

Returns SQL that checks if an expression evaluates to a value between two values.

The parameter $expression is checked if it is between $value1 and $value2.

Note: There is a slight difference in the way BETWEEN works on some databases. http://www.w3schools.com/sql/sql_between.asp. If you want complete database independence you should avoid using between().

Parameters
string$expressionthe value to compare to
string$value1the lower value to compare with
string$value2the higher value to compare with
Returns
string logical expression

Definition at line 562 of file Driver.php.

{
$expression = $this->getIdentifier($expression);
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $expression . ' BETWEEN ' .$value1 . ' AND ' . $value2;
}
Doctrine_Expression_Driver::coalesce ( )
inherited

coalesce

Returns
string

Definition at line 627 of file Driver.php.

{
$args = func_get_args();
return 'COALESCE(' . join(', ', (array) $args) . ')';
}
Doctrine_Expression_Mssql::concat ( )

Returns string to concatenate two or more string parameters

Parameters
string$arg1
string$arg2
string$values,...
Returns
string to concatenate two strings

Definition at line 77 of file Mssql.php.

{
$args = func_get_args();
return '(' . implode(' + ', $args) . ')';
}
Doctrine_Expression_Driver::cos (   $value)
inherited

cos

Parameters
string$value
Returns
void

Definition at line 617 of file Driver.php.

{
return 'COS(' . $value . ')';
}
Doctrine_Expression_Driver::count (   $column)
inherited

Returns the number of rows (without a NULL value) of a column

If a '*' is used instead of a column the number of selected rows is returned.

Parameters
string | integer$columnthe column to use
Returns
string generated sql including a COUNT aggregate function

Definition at line 77 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'COUNT(' . $column . ')';
}
Doctrine_Expression_Driver::div ( array  $args)
inherited

Returns the SQL to divide values or expressions by eachother.

divide() accepts an arbitrary number of parameters. Each parameter must contain a value or an expression or an array with values or expressions.

Parameters
string|array(string)
Returns
string an expression

Definition at line 405 of file Driver.php.

{
return $this->basicMath('/', $args);
}
Doctrine_Expression_Driver::eq (   $value1,
  $value2 
)
inherited

Returns the SQL to check if two values are equal.

Parameters
string$value1logical expression to compare
string$value2logical expression to compare with
Returns
string logical expression

Definition at line 417 of file Driver.php.

{
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $value1 . ' = ' . $value2;
}
Doctrine_Connection_Module::getConnection ( )
inherited

getConnection returns the connection object this module uses

Returns
Doctrine_Connection

Definition at line 68 of file Module.php.

{
return $this->conn;
}
Doctrine_Connection_Module::getModuleName ( )
inherited

getModuleName returns the name of this module

Returns
string the name of this module

Definition at line 79 of file Module.php.

{
return $this->moduleName;
}
Doctrine_Expression_Driver::gt (   $value1,
  $value2 
)
inherited

Returns the SQL to check if one value is greater than another value.

Parameters
string$value1logical expression to compare
string$value2logical expression to compare with
Returns
string logical expression

Definition at line 445 of file Driver.php.

{
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $value1 . ' > ' . $value2;
}
Doctrine_Expression_Driver::gte (   $value1,
  $value2 
)
inherited

Returns the SQL to check if one value is greater than or equal to another value.

Parameters
string$value1logical expression to compare
string$value2logical expression to compare with
Returns
string logical expression

Definition at line 460 of file Driver.php.

{
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $value1 . ' >= ' . $value2;
}
Doctrine_Expression_Mssql::guid ( )

Returns global unique identifier

Returns
string to get global unique identifier

Definition at line 88 of file Mssql.php.

{
return 'NEWID()';
}
Doctrine_Expression_Driver::in (   $column,
  $values 
)
inherited

Returns the SQL to check if a value is one in a set of given values..

in() accepts an arbitrary number of parameters. The first parameter must always specify the value that should be matched against. Successive must contain a logical expression or an array with logical expressions. These expressions will be matched against the first parameter.

Parameters
string$columnthe value that should be matched against
string|array(string)values that will be matched against $column
Returns
string logical expression

Definition at line 509 of file Driver.php.

{
if ( ! is_array($values)) {
$values = array($values);
}
$values = $this->getIdentifiers($values);
$column = $this->getIdentifier($column);
if (count($values) == 0) {
throw new Doctrine_Expression_Exception('Values array for IN operator should not be empty.');
}
return $column . ' IN (' . implode(', ', $values) . ')';
}
Doctrine_Expression_Driver::isNotNull (   $expression)
inherited

Returns SQL that checks if a expression is not null.

Parameters
string$expressionthe expression that should be compared to null
Returns
string logical expression

Definition at line 541 of file Driver.php.

{
$expression = $this->getIdentifier($expression);
return $expression . ' IS NOT NULL';
}
Doctrine_Expression_Driver::isNull (   $expression)
inherited

Returns SQL that checks if a expression is null.

Parameters
string$expressionthe expression that should be compared to null
Returns
string logical expression

Definition at line 529 of file Driver.php.

{
$expression = $this->getIdentifier($expression);
return $expression . ' IS NULL';
}
Doctrine_Expression_Mssql::length (   $column)

Returns the length of a text field

Parameters
string$column
Returns
string

Definition at line 100 of file Mssql.php.

{
return 'LEN (' . $column . ')';
}
Doctrine_Expression_Driver::locate (   $str,
  $substr 
)
inherited

locate returns the position of the first occurrence of substring $substr in string $str

Parameters
string$substrliteral string to find
string$strliteral string
Returns
integer

Definition at line 246 of file Driver.php.

{
return 'LOCATE(' . $str . ', ' . $substr . ')';
}
Doctrine_Expression_Driver::lower (   $str)
inherited

lower Returns the string $str with all characters changed to lowercase according to the current character set mapping.

Parameters
string$strliteral string or column name
Returns
string

Definition at line 233 of file Driver.php.

{
return 'LOWER(' . $str . ')';
}
Doctrine_Expression_Driver::lt (   $value1,
  $value2 
)
inherited

Returns the SQL to check if one value is less than another value.

Parameters
string$value1logical expression to compare
string$value2logical expression to compare with
Returns
string logical expression

Definition at line 474 of file Driver.php.

{
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $value1 . ' < ' . $value2;
}
Doctrine_Expression_Driver::lte (   $value1,
  $value2 
)
inherited

Returns the SQL to check if one value is less than or equal to another value.

Parameters
string$value1logical expression to compare
string$value2logical expression to compare with
Returns
string logical expression

Definition at line 489 of file Driver.php.

{
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $value1 . ' <= ' . $value2;
}
Doctrine_Expression_Driver::ltrim (   $str)
inherited

ltrim returns the string $str with leading space characters removed

Parameters
string$strliteral string or column name
Returns
string

Definition at line 207 of file Driver.php.

{
return 'LTRIM(' . $str . ')';
}
Doctrine_Expression_Driver::max (   $column)
inherited

Returns the highest value of a column

Parameters
string$columnthe column to use
Returns
string generated sql including a MAX aggregate function

Definition at line 89 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'MAX(' . $column . ')';
}
Doctrine_Expression_Driver::md5 (   $column)
inherited

Returns the md5 sum of a field.

Note: Not SQL92, but common functionality

Returns
string

Definition at line 128 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'MD5(' . $column . ')';
}
Doctrine_Expression_Driver::min (   $column)
inherited

Returns the lowest value of a column

Parameters
string$columnthe column to use
Returns
string

Definition at line 101 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'MIN(' . $column . ')';
}
Doctrine_Expression_Driver::mod (   $expression1,
  $expression2 
)
inherited

Returns the remainder of the division operation $expression1 / $expression2.

Parameters
string$expression1
string$expression2
Returns
string

Definition at line 169 of file Driver.php.

{
$expression1 = $this->getIdentifier($expression1);
$expression2 = $this->getIdentifier($expression2);
return 'MOD(' . $expression1 . ', ' . $expression2 . ')';
}
Doctrine_Expression_Driver::mul ( array  $args)
inherited

Returns the SQL to multiply values or expressions by eachother.

multiply() accepts an arbitrary number of parameters. Each parameter must contain a value or an expression or an array with values or expressions.

Parameters
string|array(string)
Returns
string an expression

Definition at line 390 of file Driver.php.

{
return $this->basicMath('*', $args);
}
Doctrine_Expression_Driver::neq (   $value1,
  $value2 
)
inherited

Returns the SQL to check if two values are unequal.

Parameters
string$value1logical expression to compare
string$value2logical expression to compare with
Returns
string logical expression

Definition at line 431 of file Driver.php.

{
$value1 = $this->getIdentifier($value1);
$value2 = $this->getIdentifier($value2);
return $value1 . ' <> ' . $value2;
}
Doctrine_Expression_Driver::not (   $expression)
inherited

Returns the SQL for a logical not.

Returns
string a logical expression

Definition at line 319 of file Driver.php.

{
$expression = $this->getIdentifier($expression);
return 'NOT(' . $expression . ')';
}
Doctrine_Expression_Mssql::now (   $type = 'timestamp')

Return string to call a variable with the current timestamp inside an SQL statement There are three special variables for current date and time:

  • CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
  • CURRENT_DATE (date, DATE type)
  • CURRENT_TIME (time, TIME type)
Returns
string to call a variable with the current timestamp public

Definition at line 45 of file Mssql.php.

{
switch ($type) {
case 'time':
case 'date':
case 'timestamp':
default:
return 'GETDATE()';
}
}
Doctrine_Expression_Driver::now ( )
inherited

Returns the current system date.

Returns
string

Definition at line 256 of file Driver.php.

{
return 'NOW()';
}
Doctrine_Expression_Driver::pi ( )
inherited

pi

Returns
void

Definition at line 606 of file Driver.php.

{
return 'PI()';
}
Doctrine_Expression_Driver::regexp ( )
inherited

regexp returns the regular expression operator

Returns
string

Definition at line 51 of file Driver.php.

{
throw new Doctrine_Expression_Exception('Regular expression operator is not supported by this database driver.');
}
Doctrine_Expression_Driver::round (   $column,
  $decimals = 0 
)
inherited

Rounds a numeric field to the number of decimals specified.

Parameters
string$expression1
string$expression2
Returns
string

Definition at line 154 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'ROUND(' . $column . ', ' . $decimals . ')';
}
Doctrine_Expression_Driver::rtrim (   $str)
inherited

rtrim returns the string $str with proceeding space characters removed

Parameters
string$strliteral string or column name
Returns
string

Definition at line 195 of file Driver.php.

{
return 'RTRIM(' . $str . ')';
}
Doctrine_Expression_Driver::sin (   $value)
inherited

sin

Parameters
string$value
Returns
void

Definition at line 596 of file Driver.php.

{
return 'SIN(' . $value . ')';
}
Doctrine_Expression_Driver::soundex (   $value)
inherited

soundex Returns a string to call a function to compute the soundex encoding of a string

The string "?000" is returned if the argument is NULL.

Parameters
string$value
Returns
string SQL soundex function with given parameter

Definition at line 271 of file Driver.php.

{
throw new Doctrine_Expression_Exception('SQL soundex function not supported by this driver.');
}
Doctrine_Expression_Driver::sub ( array  $args)
inherited

Returns the SQL to subtract values or expressions from eachother.

subtract() accepts an arbitrary number of parameters. Each parameter must contain a value or an expression or an array with values or expressions.

Parameters
string|array(string)
Returns
string an expression

Definition at line 375 of file Driver.php.

{
return $this->basicMath('-', $args );
}
Doctrine_Expression_Mssql::substring (   $value,
  $position,
  $length = null 
)

return string to call a function to get a substring inside an SQL statement

Returns
string to call a function to get a substring

Definition at line 61 of file Mssql.php.

{
if ( ! is_null($length)) {
return 'SUBSTRING(' . $value . ', ' . $position . ', ' . $length . ')';
}
return 'SUBSTRING(' . $value . ', ' . $position . ', LEN(' . $value . ') - ' . $position . ' + 1)';
}
Doctrine_Expression_Driver::sum (   $column)
inherited

Returns the total sum of a column

Parameters
string$columnthe column to use
Returns
string

Definition at line 113 of file Driver.php.

{
$column = $this->getIdentifier($column);
return 'SUM(' . $column . ')';
}
Doctrine_Expression_Driver::trim (   $str)
inherited

trim returns the string $str with leading and proceeding space characters removed

Parameters
string$strliteral string or column name
Returns
string

Definition at line 183 of file Driver.php.

{
return 'TRIM(' . $str . ')';
}
Doctrine_Expression_Driver::upper (   $str)
inherited

upper Returns the string $str with all characters changed to uppercase according to the current character set mapping.

Parameters
string$strliteral string or column name
Returns
string

Definition at line 220 of file Driver.php.

{
return 'UPPER(' . $str . ')';
}

The documentation for this class was generated from the following file: