Builder class to have primaryKey and return primaryKey on insert |
`CodeIgniter\Database\MySQLi\Builder` class seems to have no option setting primaryKey on run (primaryKey already exists in DB). This is the use case when we use isolated instance of a table using `$db->table('another_table')` where there seem no primaryKey property present as per DB schema or cannot either assign manually. Actually it won't return last_insert_id if primaryKey is missing as per my multiple attempts.
Am I missing something or is it worth requesting as a feature? Attempts: 1. Tried setting primaryKey inside model and expecting some id to return after successful $tabl2->insert execution: $tabl2 = $this->db->table('table2'); $tabl2->primaryKey = 'term_id'; it does set primaryKey to the Builder object but doesn't seem to integrate it in property. 2. Tried getting insertId using $tabl2->insertID but its not defined after execution of the insert method. Sorry, If I am not relevant to the forum.
Query Builder does not have/know primaryKey. It just build SQL queries.
You are confusing Query Builder and Model. |
Welcome Guest, Not a member yet? Register Sign In |