@vincej Hey. What is your default database for your connection? Try use ; as your first line.
whereRaw just adds a raw where clause. In the example I showed you can inject a complete SQL statement or statements terminated by a semi-colon. ';'
You are going to have to navigate the mindless chatter of the
'Google-plex' sadly. I have your table built when I run your code with the use statement I get an error further on.
You need to set a default value for created_at in DB schema.
21:14:49 [USE - 0 rows, 0.003 secs] Command processed. No rows were affected
Code: 1046 SQL State: 3D000 --- No database selected
21:14:49 [LOCK - 0 rows, 0.003 secs] Command processed. No rows were affected
21:14:49 [SELECT - 1 rows, 0.002 secs] Result set fetched
21:14:49 [UPDATE - 5 rows, 0.011 secs] Command processed
21:14:49 [UPDATE - 4 rows, 0.003 secs] Command processed
21:14:49 [INSERT - 0 rows, 0.002 secs] [Code: 1364, SQL State: HY000] Field 'created_at' doesn't have a default value
Code: 1364 SQL State: HY000 --- Field 'created_at' doesn't have a default value
Code: 1364 SQL State: HY000 --- Field 'updated_at' doesn't have a default value
21:14:49 [UNLOCK - 0 rows, 0.001 secs] Command processed. No rows were affected
Code: 1364 SQL State: HY000 --- Field 'created_at' doesn't have a default value
Code: 1364 SQL State: HY000 --- Field 'updated_at' doesn't have a default value
... 7 statement(s) executed, 10 rows affected, exec/fetch time: 0.025/0.000 sec [6 successful, 3 SQL warnings, 1 errors]
use test;
LOCK TABLE nested_categories WRITE;
SELECT @myRight := rgt FROM nested_categories
WHERE name = "MATERIALS";
UPDATE nested_categories SET rgt = rgt + 2 WHERE rgt > @myRight;
UPDATE nested_categories SET lft = lft + 2 WHERE lft > @myRight;
INSERT INTO nested_categories(name, lft, rgt) VALUES("WINDOWS",@myRight+1,@myRight+2 );
UNLOCK TABLES
This is Not an optimal way of doing DB work. What mean is Eloquent translates down into it but you get more error control hopefully. But you can do this, but you have manage the database state. How are setting up the DB connection?
Note test is the default MySQL database where I created your table.