[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/libraries/joomla/database/database/ -> sqlsrvquery.php (source)

   1  <?php
   2  /**
   3   * @package     Joomla.Platform
   4   * @subpackage  Database
   5   *
   6   * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   7   * @license     GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  defined('JPATH_PLATFORM') or die;
  11  
  12  /**
  13   * Query Building Class.
  14   *
  15   * @package     Joomla.Platform
  16   * @subpackage  Database
  17   * @since       11.1
  18   */
  19  class JDatabaseQuerySQLSrv extends JDatabaseQuery
  20  {
  21      /**
  22       * The character(s) used to quote SQL statement names such as table names or field names,
  23       * etc.  The child classes should define this as necessary.  If a single character string the
  24       * same character is used for both sides of the quoted name, else the first character will be
  25       * used for the opening quote and the second for the closing quote.
  26       *
  27       * @var    string
  28       *
  29       * @since  11.1
  30       */
  31      protected $name_quotes = '`';
  32  
  33      /**
  34       * The null or zero representation of a timestamp for the database driver.  This should be
  35       * defined in child classes to hold the appropriate value for the engine.
  36       *
  37       * @var    string
  38       *
  39       * @since  11.1
  40       */
  41      protected $null_date = '1900-01-01 00:00:00';
  42  
  43      /**
  44       * Magic function to convert the query to a string.
  45       *
  46       * @return  string    The completed query.
  47       *
  48       * @since   11.1
  49       */
  50  	public function __toString()
  51      {
  52          $query = '';
  53  
  54          switch ($this->type)
  55          {
  56              case 'insert':
  57                  $query .= (string) $this->insert;
  58  
  59                  // Set method
  60                  if ($this->set)
  61                  {
  62                      $query .= (string) $this->set;
  63                  }
  64                  // Columns-Values method
  65                  elseif ($this->values)
  66                  {
  67                      if ($this->columns)
  68                      {
  69                          $query .= (string) $this->columns;
  70                      }
  71  
  72                      $elements = $this->insert->getElements();
  73                      $tableName = array_shift($elements);
  74  
  75                      $query .= 'VALUES ';
  76                      $query .= (string) $this->values;
  77  
  78                      if ($this->autoIncrementField)
  79                      {
  80                          $query = 'SET IDENTITY_INSERT ' . $tableName . ' ON;' . $query . 'SET IDENTITY_INSERT ' . $tableName . ' OFF;';
  81                      }
  82  
  83                      if ($this->where)
  84                      {
  85                          $query .= (string) $this->where;
  86                      }
  87  
  88                  }
  89  
  90                  break;
  91  
  92              default:
  93                  $query = parent::__toString();
  94                  break;
  95          }
  96  
  97          return $query;
  98      }
  99  
 100      /**
 101       * Casts a value to a char.
 102       *
 103       * Ensure that the value is properly quoted before passing to the method.
 104       *
 105       * @param   string  $value  The value to cast as a char.
 106       *
 107       * @return  string  Returns the cast value.
 108       *
 109       * @since   11.1
 110       */
 111  	public function castAsChar($value)
 112      {
 113          return 'CAST(' . $value . ' as NVARCHAR(10))';
 114      }
 115  
 116      /**
 117       * Gets the function to determine the length of a character string.
 118       *
 119       * @param   string  $field  A value.
 120       *
 121       * @return  string  The required char length call.
 122       *
 123       * @since 11.1
 124       */
 125  	public function charLength($field)
 126      {
 127          return 'DATALENGTH(' . $field . ') IS NOT NULL';
 128      }
 129  
 130      /**
 131       * Concatenates an array of column names or values.
 132       *
 133       * @param   array   $values     An array of values to concatenate.
 134       * @param   string  $separator  As separator to place between each value.
 135       *
 136       * @return  string  The concatenated values.
 137       *
 138       * @since   11.1
 139       */
 140  	public function concatenate($values, $separator = null)
 141      {
 142          if ($separator)
 143          {
 144              return '(' . implode('+' . $this->quote($separator) . '+', $values) . ')';
 145          }
 146          else
 147          {
 148              return '(' . implode('+', $values) . ')';
 149          }
 150      }
 151  
 152      /**
 153       * Gets the current date and time.
 154       *
 155       * @return  string
 156       *
 157       * @since   11.1
 158       */
 159  	public function currentTimestamp()
 160      {
 161          return 'GETDATE()';
 162      }
 163  
 164      /**
 165       * Get the length of a string in bytes.
 166       *
 167       * @param   string  $value  The string to measure.
 168       *
 169       * @return  integer
 170       *
 171       * @since   11.1
 172       */
 173  	public function length($value)
 174      {
 175          return 'LEN(' . $value . ')';
 176      }
 177  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1