# LiteDialect.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2005-2007 by Konstantin V. Arkhipov                     *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00019     final class LiteDialect extends Dialect
    00020     {
    00024         public static function me()
    00025         {
    00026             return Singleton::getInstance(__CLASS__);
    00027         }
    00028
    00029         public static function quoteValue($value)
    00030         {
    00032
    00033             if ($value instanceof Identifier && !$value->isFinalized())
    00034                 return 'null';
    00035
    00036             if (Assert::checkInteger($value))
    00037                 return $value;
    00038
    00039             return "'" .sqlite_escape_string($value)."'";
    00040         }
    00041
    00042         public static function dropTableMode($cascade = false)
    00043         {
    00044             return null;
    00045         }
    00046
    00047         public function quoteBinary($data)
    00048         {
    00049             return sqlite_udf_encode_binary($data);
    00050         }
    00051
    00052         public function unquoteBinary($data)
    00053         {
    00054             return sqlite_udf_decode_binary($data);
    00055         }
    00056
    00057         public function typeToString(DataType $type)
    00058         {
    00059             switch ($type->getId()) {
    00060                 case DataType::BIGINT:
    00061
    00062                     return 'INTEGER';
    00063
    00064                 case DataType::BINARY:
    00065
    00066                     return 'BLOB';
    00067             }
    00068
    00069             return parent::typeToString($type);
    00070         }
    00071
    00072         public function preAutoincrement(DBColumn $column)
    00073         {
    00074             self::checkColumn($column);
    00075
    00076             return null;
    00077         }
    00078
    00079         public function postAutoincrement(DBColumn $column)
    00080         {
    00081             self::checkColumn($column);
    00082
    00083             return null; // or even 'AUTOINCREMENT'?
    00084         }
    00085
    00086         public function hasTruncate()
    00087         {
    00088             return false;
    00089         }
    00090
    00091         public function hasMultipleTruncate()
    00092         {
    00093             return false;
    00094         }
    00095
    00096         public function hasReturning()
    00097         {
    00098             return false;
    00099         }
    00100
    00101         private static function checkColumn(DBColumn $column)
    00102         {
    00103             $type = $column->getType();
    00104
    00105             Assert::isTrue(
    00106                 (
    00107                     $type->getId() == DataType::BIGINT
    00108                     || $type->getId() == DataType::INTEGER
    00109                 )
    00110                 && $column->isPrimaryKey()
    00111             );
    00112         }
    00113     }
    00114 ?>