codecat/Nin

query builder eats shit and dies on null values

Closed this issue · 0 comments

sylae commented

attempting to save() or insert() a model that has null values doesn't end well (on mysql at least)

nf error: Database query failed (Details: "Error was: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 - Query was: INSERT INTO users (idUser,username,displayName,avatar,banner) VALUES (12345,'xxx','xxx','xxx',);")

var_dump of model im attempting to save:

object(WormRP\Model\User)#40 (5) {
  ["_data":protected]=> array(5) {
    ["idUser"]=> int(12345)
    ["username"]=> string(9) "xxx"
    ["displayName"]=> string(9) "xxx"
    ["avatar"]=> string(32) "xxx"
    ["banner"]=> NULL
  }
  ["_changed":protected]=> array(5) {
    [0]=> string(6) "idUser"
    [1]=> string(8) "username"
    [2]=> string(11) "displayName"
    [3]=> string(6) "avatar"
    [4]=> string(6) "banner"
  }
  ["_loaded":protected]=> bool(true)
  ["_relationalrows":protected]=> array(0) { }
  ["_errors"]=> array(0) { }
}