--- DataObject.php.orig Thu Oct 2 12:00:11 2003 +++ DataObject.php Thu Oct 2 15:10:03 2003 @@ -721,7 +721,11 @@ } if ($v & DB_DATAOBJECT_STR) { - $rightq .= $__DB->quote($this->$k) . " "; + $rightq .= $__DB->quote($this->$k); + if (is_array($this->_cast) && array_key_exists($k, $this->_cast)) { + $rightq .= '::'.$this->_cast[$k]; + } + $rightq .= " "; continue; } if (is_numeric($this->$k)) { @@ -833,7 +837,11 @@ } if ($v & DB_DATAOBJECT_STR) { - $settings .= $k .' = '. $__DB->quote($this->$k) . ' '; + $settings .= $k .' = '. $__DB->quote($this->$k); + if (is_array($this->_cast) && array_key_exists($k, $this->_cast)) { + $settings .= '::'.$this->_cast[$k]; + } + $settings .= ' '; continue; } if (is_numeric($this->$k)) { @@ -1069,6 +1077,21 @@ return substr($__DB->quote($string),1,-1); } + /** + * Add a cast type for PostgreSQL + * + * The field $field will get '::{$type}' appended to it on insert/update + * + * @param string $field The field to cast + * @param string $type The type to cast $field as + * @access public + * @return void + */ + function addCast($field, $type) + { + $this->_cast[$field] = $type; + } + /* ==================================================== */ /* Major Private Vars */ /* ==================================================== */ @@ -1153,6 +1176,14 @@ * @var integer */ var $_DB_resultid; // database result object + + /** + * PostgreSQL casts + * + * @access private + * @var array + */ + var $_cast; /* =========================================================== */