Hello,
I was trying to insert a row in a custom table via $modx->db->insert($f, $t), where $f=array(’name’ => $thename, ’age’ => $age) and $t = $modx->getFullTableName(’mytable’); and it was like explaining the relativity theory to Homer Simpson.
After a lot of refreshing and inspection of my code, and reading the api docs, and googling around, and even reading the modx error logs (in the report section); I decided to go to the source...
...yes the source code and the source of my problem...
I found out that the insert() function (at least when being passed and array) needs the ’keys’ backticked already and all the values get enclosed by the regular tick.
So I put the backticks in the $f array like (’`name`’ => $thename, ’`age`’ => $age), and I had a perfectly running query.
My suggestion to the devs would be to, at least, add the backticks to the field names inside the function or document the format expected for the fields variable in the api docs.
Sorry about the extent of this but I had to make it funnier than what the discovery was.
Thanks...
Diego