Created
December 16, 2017 10:37
-
-
Save martinshaw/663854363937914520c892b61acce72e to your computer and use it in GitHub Desktop.
Need to implement ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ 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