Skip to content

Instantly share code, notes, and snippets.

@martinshaw
Created December 16, 2017 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinshaw/663854363937914520c892b61acce72e to your computer and use it in GitHub Desktop.
Save martinshaw/663854363937914520c892b61acce72e to your computer and use it in GitHub Desktop.
Need to implement ID
+ Message inherits \MySQL\DAO\Model {
String tables = "messages";
String msgContents = null;
String msgOrigin = null;
String msgRecipient = null;
Boolean isFirstSave = true;
public f constructor <
String _msgContents,
String _msgOrigin,
String _msgRecipient
> {
@msgContents = _msgContents;
@msgOrigin = _msgOrigin;
@msgRecipient = _msgRecipient;
}
public f save <> {
si @isFirstSave is true {
\var _out = super.query(String.format("INSERT INTO %0 (contents, origin, recipient) VALUES (%1, %2, %3)", {
@table,
@msgContents,
@msgOrigin,
@msgRecipient
}));
} else {
\var _out = super.query(String.format("UPDATE %0 SET contents='%1', origin='%2', recipient='%3')", {
@table,
@msgContents,
@msgOrigin,
@msgRecipient
}));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment