<?php

class ConverterEncode implements IConverter
{

    private $encode;

    public function init($properties)
    {
        $this->encode = $properties['encode'];
    }

    public function convertFrom($value,$object)
    {
        global $MIOLO;
        $encoding = ($enc = $MIOLO->getConf('options.charset')) != '' ? $enc : 'ISO-8859-1';
        $v = $value == '' ? ':NULL' : iconv($encoding,$this->encode,trim((string)$value));
        return $v;
    }

    public function convertTo($value,$object)
    {
        global $MIOLO;
        $encoding = ($enc = $MIOLO->getConf('options.charset')) != '' ? $enc : 'ISO-8859-1';
        $v = iconv($this->encode,$encoding, trim((string)$value));
        return $v;
    }

    public function convertColumn($value,$object)
    {
        return $value;
    }

    public function convertWhere($value,$object)
    {
        return $value;
    }

}
?>