baser/models/datasources/dbo/dbo_postgres_ex.php
/**
 * Returns a quoted and escaped string of $data for use in an SQL statement.
 *
 * @param string $data String to be prepared for use in an SQL statement
 * @param string $column The column into which this data will be inserted
 * @param boolean $read Value to be used in READ or WRITE context
 * @return string Quoted and escaped
 * @todo Add logic that formats/escapes data based on column type
 * @access public
 */
Returns a quoted and escaped string of $data for use in an SQL statement.
Returns a quoted and escaped string of $data for use in an SQL statement .
function value($data, $column = null, $read = true) {
		$parent = $this->__value($data, $column);
		if ($parent != null) {
			return $parent;
		}
		if ($data === null) {
			return 'NULL';
		}
		if (empty($column)) {
			$column = $this->introspectType($data);
		}
		switch($column) {
			case 'binary':
				$data = pg_escape_bytea($data);
			break;
			case 'boolean':
				if ($data === true || $data === 't' || $data === 'true') {
					return 'TRUE';
				} elseif ($data === false || $data === 'f' || $data === 'false') {
					return 'FALSE';
				}
				return (!empty($data) ? 'TRUE' : 'FALSE');
			break;
			case 'float':
				if (is_float($data)) {
					$data = sprintf('%F', $data);
				}
			case 'inet':
			case 'integer':
			case 'date':
			case 'datetime':
			case 'timestamp':
			case 'time':
				if ($data === '0000-00-00 00:00:00') {
					return "'".date('Y-m-d H:i:s', 0)."'";
				}
				if ($data === '') {
					return $read ? 'NULL' : 'DEFAULT';
				}
			default:
				$data = pg_escape_string($data);
			break;
		}
		return "'" . $data . "'";
	}
function value ( $ data , $ column = null , $ read = true ) { $ parent = $ this -> __value ( $ data , $ column ) ; if ( $ parent != null ) { return $ parent ; } if ( $ data === null ) { return 'NULL' ; } if ( empty ( $ column ) ) { $ column = $ this -> introspectType ( $ data ) ; } switch ( $ column ) { case 'binary' : $ data = pg_escape_bytea ( $ data ) ; break ; case 'boolean' : if ( $ data === true || $ data === 't' || $ data === 'true' ) { return 'TRUE' ; } elseif ( $ data === false || $ data === 'f' || $ data === 'false' ) { return 'FALSE' ; } return ( ! empty ( $ data ) ? 'TRUE' : 'FALSE' ) ; break ; case 'float' : if ( is_float ( $ data ) ) { $ data = sprintf ( '%F' , $ data ) ; } case 'inet' : case 'integer' : case 'date' : case 'datetime' : case 'timestamp' : case 'time' : if ( $ data === '0000-00-00 00:00:00' ) { return " ' " . date ( 'Y-m-d H:i:s' , 0 ) . " ' " ; } if ( $ data === '' ) { return $ read ? 'NULL' : 'DEFAULT' ; } default : $ data = pg_escape_string ( $ data ) ; break ; } return " ' " . $ data . " ' " ; }
Returns a quoted and escaped string of $data for use in an SQL statement.
Returns a quoted and escaped string of $data for use in an SQL statement .
// >>> CUSTOMIZE MODIFY 2011/03/23 ryuring //$parent = parent::value($data, $column); // --- // <<< // >>> CUSTOMIZE ADD 2010/03/23 ryuring // postgresql の場合、0000-00-00 00:00:00 を指定すると範囲外エラーとなる為 // <<<