00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00021 class MyDialect extends Dialect
00022 {
00023 const IN_BOOLEAN_MODE = 1;
00024
00028 public static function me()
00029 {
00030 return Singleton::getInstance(__CLASS__);
00031 }
00032
00033 public static function quoteValue($value)
00034 {
00036
00037 if ($value instanceof Identifier && !$value->isFinalized())
00038 return "''";
00039
00040 if (Assert::checkInteger($value))
00041 return $value;
00042
00043 return "'" . mysql_real_escape_string($value) . "'";
00044 }
00045
00046 public static function quoteField($field)
00047 {
00048 if (strpos($field, '.') !== false)
00049 throw new WrongArgumentException();
00050 elseif (strpos($field, '::') !== false)
00051 throw new WrongArgumentException();
00052
00053 return "`{$field}`";
00054 }
00055
00056 public static function quoteTable($table)
00057 {
00058 return "`{$table}`";
00059 }
00060
00061 public static function dropTableMode($cascade = false)
00062 {
00063 return null;
00064 }
00065
00066 public static function timeZone($exist = false)
00067 {
00068 return null;
00069 }
00070
00071 public function hasTruncate()
00072 {
00073 return true;
00074 }
00075
00076 public function hasMultipleTruncate()
00077 {
00078 return false;
00079 }
00080
00081 public function preAutoincrement(DBColumn $column)
00082 {
00083 $column->setDefault(null);
00084
00085 return null;
00086 }
00087
00088 public function postAutoincrement(DBColumn $column)
00089 {
00090 return 'AUTO_INCREMENT';
00091 }
00092
00093 public function fullTextSearch($fields, $words, $logic)
00094 {
00095 return
00096 ' MATCH ('
00097 .implode(
00098 ', ',
00099 array_map(
00100 array($this, 'fieldToString'),
00101 $fields
00102 )
00103 )
00104 .') AGAINST ('
00105 .self::prepareFullText($words, $logic)
00106 .')';
00107 }
00108
00109 private static function prepareFullText($words, $logic)
00110 {
00111 Assert::isArray($words);
00112
00113 $retval = self::quoteValue(implode(' ', $words));
00114
00115 if (self::IN_BOOLEAN_MODE === $logic) {
00116 return addcslashes($retval, '+-<>()~*"').' '.'IN BOOLEAN MODE';
00117 } else {
00118 return $retval;
00119 }
00120 }
00121 }
00122 ?>