예제 #1
0
 /**
  * Convert some data to a SQL value.
  * 
  * @param DBColumn $col the column.
  * @param mixed $value the data to convert.
  * @throws SQLException if an exception occurred.
  */
 public function sqlOf($col, $value)
 {
     if ($value === null) {
         return 'NULL';
     }
     switch ($col->getType()) {
         case DBColumn::VARCHAR:
             $precision = $col->getPrecision();
             if ($precision && strlen($value) > $precision) {
                 // The length is exceeded
             }
             return $this->sqlstr($value);
         case DBColumn::INTEGER:
             return intval($value);
         case DBColumn::DATE:
             return $this->sqldate($value);
             break;
         case DBColumn::DATETIME:
             return $this->sqldatetime($value);
             break;
         case DBColumn::NUMERIC:
             return is_numeric($value) ? $value : 'NULL';
         case DBColumn::BOOLEAN:
             return $this->sqlstr($value === NULL ? null : ($value ? 'Y' : 'N'));
         case DBColumn::GROUP:
             return $this->sqlstr(implode(',', $value));
         default:
             throw new SQLException("Unknown SQL TYPE: " . $this->columnType);
     }
 }