PHP Classes

File: DATA/SQLVarcharFactory.php

Recommend this page to a friend!
  Classes of Martin Alterisio   DATA   DATA/SQLVarcharFactory.php   Download  
File: DATA/SQLVarcharFactory.php
Role: Class source
Content type: text/plain
Description: A concrete factory for inboxing strings into varchar fields.
Class: DATA
Access data stored in MySQL tables like arrays
Author: By
Last change: + anonymous access
Date: 16 years ago
Size: 893 bytes
 

Contents

Class file image Download
<?php
/**
 * @package DATA
 */

/**
 * A concrete factory for inboxing strings into varchar fields.
 */
class DATA_SQLVarcharFactory extends DATA_SQLCharFactory {
   
/**
     * Inboxes a value.
     *
     * Throws {@link DATA_StringTooLarge}.
     *
     * @param mixed $value The value.
     * @return DATA_SQLVarchar Inboxed value.
     */
   
public function inbox($value) {
        if (
$value instanceof DATA_SQLVarchar) {
            if (
$this->nullable == $value->isNullable()
             &&
$value->getSize() == $this->size) {
                return clone
$value;
            }
        }
        if (
$value instanceof DATA_SQLType) {
           
$value = $value->outbox();
        }
        if (!
is_null($value)) {
           
$value = (string)$value;
        }
        return new
DATA_SQLVarchar($this->nullable, $this->size, $value);
    }
}
?>