$this->setTable() or $this->table not sticking |
Ok, so, I've got a dynamic database setup where tickets are put in the tables and the tables can be created on the fly (as well as columns) - so I'm setting up the database model to handle this based upon incoming IDs.
Model code: PHP Code: protected $table = 'TN'; PHP Code: $model2 = new Protoengine(); The output is: Code: TN: start The model sees the change from TN to ticketTypeData to PH (as it should) - however the query in the getTickets() function should be calling the PH table and not the ticketTypeData table. why?
When working with multiple tables you should always call.
PHP Code: $this->table->clear(); Before setting up a table again. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-19-2021, 11:21 AM)InsiteFX Wrote: When working with multiple tables you should always call. Tried it two ways: PHP Code: $this->table->clear(); resulted in: Code: Call to a member function clear() on string and: PHP Code: $this->clear(); resulted in: Code: BadMethodCallException I looked for the clear() function in the database system folder, didn't find it. I found a clear() function in the email and the table array parts of the system folder, but nothing under database. So, still looking for an answer to this if anyone has any ideas. I added: PHP Code: $this->from($this->table, true); After the setTable for the new table and it did the job. The setTable function *should* be doing this in the set table in the framework as I can't see a logical reason to not have the table change when a setTable function is called.
The clear method is part of the table library, you can find it there.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@Kaosweaver
I have the same problem, did you find any solution? Did not found any Database ‚clear‘ method - i guess thats not available. Worst case scenario is to query the results without any ‚magic‘ models. |
Welcome Guest, Not a member yet? Register Sign In |