Welcome Guest, Not a member yet? Register   Sign In
CI and flushing output question
#1

[eluser]btray77[/eluser]
I've been trying to do something very simple and I cannot get it to work. I want to flush the output while i've got a process working. I'm going though hundreds of database records and file, and want to display a "*" when I finish each one.

I've looked into :
ob_end_flush();
ob_start();
ob_flush();
flush();

Below is a sample function I made to display the working, progress...

can someone give me working sample of how to display output without getting stuck in the buffer?

Code:
function working( $char = null)
{
    static $counter = 0;
    
    if ($counter > 120) {
        $counter = 0;
        echo '<br/>';
    }
    if (! $char) $char = '*';
    echo $char;
    $counter++;
}

I was guessing something like below, but it doesn't work:

Code:
function go ()
{
    for ($i = 1; $i <= 10; $i++) {
        working('*');
        ob_flush
        flush();
    sleep(10);
}    

go();
#2

[eluser]skunkbad[/eluser]
your ob_flush is lacking ()
#3

[eluser]btray77[/eluser]
Thanks I had given up on that...

I'll try it again now.

-Brad
#4

[eluser]skunkbad[/eluser]
also, working() is not a php function. You might just use echo.
#5

[eluser]btray77[/eluser]
Look above working was a function I gave source to above....

Working was what was to send the output out so that people were not staring at a blank screen for 3 minutes wondering if this is working or not..

-Brad
#6

[eluser]John_Betong[/eluser]
[quote author="btray77" date="1254288189"]Look above working was a function I gave source to above....

Working was what was to send the output out so that people were not staring at a blank screen for 3 minutes wondering if this is working or not..

-Brad[/quote]
&nbsp;
If and only if, maybe you are using the code in a function then the working function requires to be called as follows:
Code:
$this->working('?');
&nbsp;
&nbsp;
Also in your function working(...) you can supply a $char default of '*' and this will make the following line redundant:
Code:
if (! $char) $char = '*';
&nbsp;
&nbsp;
Also if function working is in the same controller and is not being called from anywhere else then it is beneficial to prefix it with an underscore denoting that the function is within the same controller.
&nbsp;
&nbsp;
&nbsp;
edit: added also and another also.
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB