Rivendellaudio/lib/rdescape_string.h
Wayne Merricks d222ed9ca0 Added QDate/Time variant is valid checks for SQL use
With MySQL v5.7+ you have to specifically set either a valid date or NULL
otherwise you get SQL errors.  In previous versions setting a date to "" implied
NULL, this is no longer the case which causes nice SQL errors all over the
place.

This new RDCheckDateTime is an overloaded function that calls the respective
isValid method of QDate/Time/DateTime and either returns the requested formatted
string or returns NULL as a string.

This can then be used as part of an INSERT/UPDATE without breaking the stricter
NULL interpretation of MySQL v5.7+.
2016-06-03 23:45:31 +01:00

35 lines
1.2 KiB
C

// rdescape_string.h
//
// Escape non-valid characters in a string.
//
// (C) Copyright 2002-2005,2016 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <qstring.h>
#include <qdatetime.h>
#ifndef RDESCAPE_STRING_H
#define RDESCAPE_STRING_H
QString RDCheckDateTime(const QTime &time, const QString &format);
QString RDCheckDateTime(const QDateTime &datetime, const QString &format);
QString RDCheckDateTime(const QDate &date, const QString &format);
QString RDEscapeString(const QString &str);
#endif // RDESCAPE_STRING_H