saving data via __destruct |
[eluser]gino[/eluser]
Hi, i'm still learning CI and not yet an expert in PHP i was just wondering if it's possible to save data into the database in the magic __destruct function? example: Code: <?php i'm just not sure if this is a good thing todo! and if the code will always be excecuted?!! any experts please give me your thoughts. thnx in advance!
[eluser]umefarooq[/eluser]
if you want to update you table every time when object is getting destroy then it is ok, please check the following link http://php.net/manual/en/language.oop5.decon.php
[eluser]gino[/eluser]
thnx, i already read the docs on php.net, but i'm just still a litle confused on when the destructor is actually called. maybe a litle paranoid to! it's not possible that the CI->db object doesn't exist anymore?
[eluser]umefarooq[/eluser]
hi just try this simple class Code: <?
[eluser]Namaless[/eluser]
Use register_shutdown_function(array($this,"my_destruct_method")) ^_^
[eluser]gino[/eluser]
[quote author="Namaless" date="1260194298"]Use register_shutdown_function(array($this,"my_destruct_method")) ^_^[/quote] thnx for the reply! i'm currently looking into this method also @umefarooq thnx for the example, everything works as expected! appreciated :-) |
Welcome Guest, Not a member yet? Register Sign In |