public function buildFieldValue($field_descriptor, $value)
    {
        if ($value === null) {
            $retval = 'NULL';
        } elseif ($value === false) {
            $retval = 'false';
        } elseif ($value === true) {
            $retval = 'true';
        } else {
            if (!is_array($value)) {
                $value = array($value);
            }
            switch ($field_descriptor['data_type']) {
                case 'int':
                    $retval = $this->nb_connector->buildSentence('%d', $value);
                    break;
                case 'float':
                case 'double':
                    $retval = $this->nb_connector->buildSentence('%F', $value);
                    break;
                case 'varchar':
                case 'text':
                case 'longtext':
                case 'enum':
                case 'set':
                case 'tinytext':
                    $retval = $this->nb_connector->buildSentence("'%s'", $value);
                    break;
                case 'date':
                case 'datetime':
                    if ($field_descriptor['name'] !== $this->storage_descriptor['name'] . '_creation_datetime') {
                        if ($value === null) {
                            $retval = 'null';
                        } else {
                            $retval = $this->nb_connector->buildSentence("'%s'", $value);
                        }
                    } else {
                        $retval = false;
                    }
                    break;
                default:
                    error_log($field_descriptor['data_type']);
                    throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED);
            }
        }

        return $retval;
    }
public function buildFieldValue($field_descriptor, $value)
    {
        if ($value === null) {
            $retval = 'NULL';
        } elseif ($value === false) {
            $retval = 'false';
        } elseif ($value === true) {
            $retval = 'true';
        } else {
            if (!is_array($value)) {
                $value = array($value);
            }
            switch ($field_descriptor['data_type']) {
                case 'int':
                    $retval = $this->nb_connector->buildSentence('%d', $value);
                    break;
                case 'float':
                case 'double':
                    $retval = $this->nb_connector->buildSentence('%F', $value);
                    break;
                case 'varchar':
                case 'text':
                case 'longtext':
                case 'enum':
                case 'set':
                case 'tinytext':
                    $retval = $this->nb_connector->buildSentence("'%s'", $value);
                    break;
                case 'date':
                case 'datetime':
                    if ($field_descriptor['name'] !== $this->storage_descriptor['name'] . '_creation_datetime') {
                        if ($value === null) {
                            $retval = 'null';
                        } else {
                            $retval = $this->nb_connector->buildSentence("'%s'", $value);
                        }
                    } else {
                        $retval = false;
                    }
                    break;
                default:
                    error_log($field_descriptor['data_type']);
                    throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED);
            }
        }

        return $retval;
    }
public function buildFieldValue ( $ field_descriptor , $ value ) { if ( $ value === null ) { $ retval = 'NULL' ; } elseif ( $ value === false ) { $ retval = 'false' ; } elseif ( $ value === true ) { $ retval = 'true' ; } else { if ( ! is_array ( $ value ) ) { $ value = array ( $ value ) ; } switch ( $ field_descriptor [ 'data_type' ] ) { case 'int' : $ retval = $ this -> nb_connector -> buildSentence ( '%d' , $ value ) ; break ; case 'float' : case 'double' : $ retval = $ this -> nb_connector -> buildSentence ( '%F' , $ value ) ; break ; case 'varchar' : case 'text' : case 'longtext' : case 'enum' : case 'set' : case 'tinytext' : $ retval = $ this -> nb_connector -> buildSentence ( "'%s'" , $ value ) ; break ; case 'date' : case 'datetime' : if ( $ field_descriptor [ 'name' ] !== $ this -> storage_descriptor [ 'name' ] . '_creation_datetime' ) { if ( $ value === null ) { $ retval = 'null' ; } else { $ retval = $ this -> nb_connector -> buildSentence ( "'%s'" , $ value ) ; } } else { $ retval = false ; } break ; default : error_log ( $ field_descriptor [ 'data_type' ] ) ; throw new ENabuCoreException ( ENabuCoreException :: ERROR_FEATURE_NOT_IMPLEMENTED ) ; } } return $ retval ; }
Builds a well formed string for a field value containing their value represented in MySQL SQL syntax.
This method prevents SQL Injection.
@param array $field_descriptor Field descriptor to build the field value string.
@param mixed $value Value to be converted into a valid MySQL value representation.
@return string Returns the well formed string or false if no valid data_type found in field descriptor.
Builds a well formed string for a field value containing their value represented in MySQL SQL syntax . This method prevents SQL Injection .