QuickBooks/Driver/Sql/Pgsql.php
protected function _generateFieldSchema($name, $def)
	{
		switch ($def[0])
		{
            case QUICKBOOKS_DRIVER_SQL_INTEGER:
				$sql = '"' . $name . '" INTEGER ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= ' DEFAULT ' . (int) $def[2];
					}
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_DECIMAL:
				$sql = '"' . $name . '" DECIMAL ';
		
				if (!empty($def[1]))
				{
					$tmp = explode(',', $def[1]);
					if (count($tmp) == 2)
					{
						$sql .= '(' . (int) $tmp[0] . ',' . (int) $tmp[1] . ') ';
					}
				}
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' NULL ';
					}
					else
					{
						if (isset($tmp) and count($tmp) == 2)
						{
							$sql .= ' DEFAULT ' . sprintf('%01.'. (int) $tmp[1] . 'f', (float) $def[2]);
						}
						else
						{
							$sql .= ' DEFAULT ' . sprintf('%01.2f', (float) $def[2]);
						}
					}
				}
				
				if (isset($tmp))
				{
					unset($tmp);
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_FLOAT:
				$sql = '"' . $name . '" FLOAT ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' NULL ';
					}
					else
					{
						$sql .= ' DEFAULT ' . sprintf('%01.2f', (float) $def[2]);
					}
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_BOOLEAN:
				$sql = '"' . $name . '" BOOLEAN ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else if ($def[2])
					{
						$sql .= ' DEFAULT TRUE ';
					}
					else
					{
						$sql .= ' DEFAULT FALSE ';
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_SERIAL:
				$sql = '"' . $name . '" SERIAL NOT NULL '; // AUTO_INCREMENT 
				
				return $sql;
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP:
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_INSERT_OR_UPDATE:
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_UPDATE:
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_INSERT:
			case QUICKBOOKS_DRIVER_SQL_DATETIME:
				
				$sql = '"' . $name . '" timestamp without time zone ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= ' DEFAULT ' . $def[2] . ' NOT NULL ';
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				

			/*case QUICKBOOKS_DRIVER_SQL_BOOLEAN:
				$sql = $name . ' tinyint(1) ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else if ($def[2])
					{
						$sql .= ' DEFAULT 1 ';
					}
					else
					{
						$sql .= ' DEFAULT 0 ';
					}
				}
				
				return $sql;*/				
            case QUICKBOOKS_DRIVER_SQL_VARCHAR:
				$sql = '"' . $name . '" VARCHAR';
				
				/*if ($name == 'ListID')
				{
					print('LIST ID:');
					print_r($def);
				}*/
				
				if (!empty($def[1]))
				{
					$sql .= '(' . (int) $def[1] . ') ';
				}
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else if ($def[2] === false)
					{
						$sql .= ' NOT NULL ';
					}
					else
					{
						$sql .= " NOT NULL DEFAULT '" . $def[2] . "' ";
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_CHAR:
				$sql = '"' . $name . '" CHAR';
				
				if (!empty($def[1]))
				{
					$sql .= '(' . (int) $def[1] . ') ';
				}
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= " NOT NULL DEFAULT '" . $def[2] . "' ";
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
			default:
			case QUICKBOOKS_DRIVER_SQL_TEXT:
				$sql = '"' . $name . '" TEXT ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= " NOT NULL DEFAULT '" . $def[2] . "' ";
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
		}
        return $sql;
	}
protected function _generateFieldSchema($name, $def)
	{
		switch ($def[0])
		{
            case QUICKBOOKS_DRIVER_SQL_INTEGER:
				$sql = '"' . $name . '" INTEGER ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= ' DEFAULT ' . (int) $def[2];
					}
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_DECIMAL:
				$sql = '"' . $name . '" DECIMAL ';
		
				if (!empty($def[1]))
				{
					$tmp = explode(',', $def[1]);
					if (count($tmp) == 2)
					{
						$sql .= '(' . (int) $tmp[0] . ',' . (int) $tmp[1] . ') ';
					}
				}
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' NULL ';
					}
					else
					{
						if (isset($tmp) and count($tmp) == 2)
						{
							$sql .= ' DEFAULT ' . sprintf('%01.'. (int) $tmp[1] . 'f', (float) $def[2]);
						}
						else
						{
							$sql .= ' DEFAULT ' . sprintf('%01.2f', (float) $def[2]);
						}
					}
				}
				
				if (isset($tmp))
				{
					unset($tmp);
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_FLOAT:
				$sql = '"' . $name . '" FLOAT ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' NULL ';
					}
					else
					{
						$sql .= ' DEFAULT ' . sprintf('%01.2f', (float) $def[2]);
					}
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_BOOLEAN:
				$sql = '"' . $name . '" BOOLEAN ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else if ($def[2])
					{
						$sql .= ' DEFAULT TRUE ';
					}
					else
					{
						$sql .= ' DEFAULT FALSE ';
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_SERIAL:
				$sql = '"' . $name . '" SERIAL NOT NULL '; // AUTO_INCREMENT 
				
				return $sql;
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP:
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_INSERT_OR_UPDATE:
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_UPDATE:
			case QUICKBOOKS_DRIVER_SQL_TIMESTAMP_ON_INSERT:
			case QUICKBOOKS_DRIVER_SQL_DATETIME:
				
				$sql = '"' . $name . '" timestamp without time zone ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= ' DEFAULT ' . $def[2] . ' NOT NULL ';
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				

			/*case QUICKBOOKS_DRIVER_SQL_BOOLEAN:
				$sql = $name . ' tinyint(1) ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else if ($def[2])
					{
						$sql .= ' DEFAULT 1 ';
					}
					else
					{
						$sql .= ' DEFAULT 0 ';
					}
				}
				
				return $sql;*/				
            case QUICKBOOKS_DRIVER_SQL_VARCHAR:
				$sql = '"' . $name . '" VARCHAR';
				
				/*if ($name == 'ListID')
				{
					print('LIST ID:');
					print_r($def);
				}*/
				
				if (!empty($def[1]))
				{
					$sql .= '(' . (int) $def[1] . ') ';
				}
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else if ($def[2] === false)
					{
						$sql .= ' NOT NULL ';
					}
					else
					{
						$sql .= " NOT NULL DEFAULT '" . $def[2] . "' ";
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
			case QUICKBOOKS_DRIVER_SQL_CHAR:
				$sql = '"' . $name . '" CHAR';
				
				if (!empty($def[1]))
				{
					$sql .= '(' . (int) $def[1] . ') ';
				}
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= " NOT NULL DEFAULT '" . $def[2] . "' ";
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
			default:
			case QUICKBOOKS_DRIVER_SQL_TEXT:
				$sql = '"' . $name . '" TEXT ';
				
				if (isset($def[2]))
				{
					if (strtolower($def[2]) == 'null')
					{
						$sql .= ' DEFAULT NULL ';
					}
					else
					{
						$sql .= " NOT NULL DEFAULT '" . $def[2] . "' ";
					}
				}
				else
				{
					$sql .= ' NOT NULL ';
				}
				
				break;
		}
        return $sql;
	}
Override for the default SQL generation functions, PostgreSQL-specific field generation function

@param string $name
@param array $def
@return string