• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I load view before model or model inside view

#1
[eluser]sudesh[/eluser]
Hi all,

I have design issue here, my model would take long time to process, i want to load view with model or before it, so user can know at which stage the model is.

Basically model does a kinda batch process.

Or can anybody provide a different approach where i can achieve above, i m new to MVC and CI.

The above scenario is just a concept, can i achieve it in CI. I m new to CI so if it is already posted(i searched but could not find it in forum) please redirect me to it.

#2
[eluser]Sumon[/eluser]
sudesh,
is it possible in any other ways rather then CI? lets say my model is busy with reading huge data(say 20 Trillion rows) from a table and then apply some logic. Now my question is how long the model will take how we know that in advance.

On the other hand, say for a file what we do is determine file size in advance using JS(i am not 100% sure though). Later file uploading starts and counting how much file size is uploaded. Finally calculate a real time ratio (say 40%) using AJAX.

Ops...!!! same approach may be applied for first scenario. It might be like, a database table size might store in metadata ( i am not sure how we to read metadata). If it is then it's possible in the real time to calculate in percentage how much data reading is complete by model. Surely here is also AJAX.

#3
[eluser]Bramme[/eluser]
Seems kinda tricky to me.

Could you explain the batch process a bit more? Will you be resizing images, reading a db? I think it could be possibole with AJAX indeed, but not too sure...

#4
[eluser]sudesh[/eluser]
Thanks Sumon, Bramme for replying,

Ajax is not a solution, we tried it but the problem increased, we are basically crawling few web pages - in batch.

I have noticed regularly , if we echo something in loop say 10000 times, the server doesn't wait till the 10000th loop to give the browser response, i believe its true, by the time it reaches 10000th echo it had already sent 999th echo to browser(i don't know the technical terms).

I want use this feature or whatever you may call for showing the user where the process has reached.

Sounds much simpler hopefully,

thanks again all for prompt reply.
Sudesh

#5
[eluser]xwero[/eluser]
Does the batch process need to happen every time the controller is called? Can't it be done in the background with a cron job?

Surfers are not patient people even if you display useful information. They want it all and they want it now.

#6
[eluser]drewbee[/eluser]
I wouldn't ever run something like this launched from a web page. Maybe to kick it off, but not for its execution. I wrote a PHP spider a while ago, and would use PHP's exec() function to run the spider in the background. It ends up becoming a single process that will run indefinitely (until finished). I even had the script updating a row in a table to report its status so that the user who launched the process could see how it was doing.

#7
[eluser]Sumon[/eluser]
[quote author="drewbee" date="1221504619"]use PHP's exec() function to run the spider in the background. It ends up becoming a single process that will run indefinitely (until finished). I even had the script updating a row in a table to report its status so that the user who launched the process could see how it was doing.[/quote]

drewbee, really nice idea. and i think this is the best one.

sudesh, how is the idea. i feel, excellent. run your process in the backend using exec() function and use database (update db table is easy one) to store instant update. and finally latest update can be view by fetch db table.

#8
[eluser]sudesh[/eluser]
Sorry All for delayed response,

I did some RnD on exec and i found it seems to run on system rather than any php code, well i m not good at it, shell scripting well i think that goes out of scope for all here.

i think i will have to try something out of book, if i find it i will post it here.

Thanks all,


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.