#5983: DboSource->showQuery() only outputs on error
----------------------------------------+-----------------------------------
    Reporter:  zackenbarsch             |          Type:  Bug      
      Status:  new                      |      Priority:  Medium   
   Milestone:  1.2.x.x                  |     Component:  Core Libs
     Version:  1.2 Final                |      Severity:  Normal   
    Keywords:  dbosource, query, error  |   Php_version:  PHP 5    
Cake_version:  1.2.0.7962               |  
----------------------------------------+-----------------------------------
 When $error is false it should output the query, rows affected, num rows
 and time, but it outputs nothing. Here's some code for testing in
 dbo_source.test.php/testLog(): [[BR]]

 {{{
 #!php
 $this->testDb->error = false;
 ob_start();
 $this->testDb->showQuery('Some Query');
 $contents = ob_get_clean();
 $this->assertPattern('/Some Query/s', $contents);
 $this->assertPattern('/Aff:/s', $contents);
 $this->assertPattern('/Num:/s', $contents);
 $this->assertPattern('/Took:/s', $contents);

 $this->testDb->error = true;
 ob_start();
 $this->testDb->showQuery('Another Query');
 $contents = ob_get_clean();
 $this->assertPattern('/Another Query/s', $contents);
 $this->assertNoPattern('/Aff:/s', $contents);
 $this->assertNoPattern('/Num:/s', $contents);
 $this->assertNoPattern('/Took:/s', $contents);
 }}}

 The problem is the dbo_source.php in the showQuery method there's the
 following code:

 {{{
 #!php
 if ($error && Configure::read() > 0) {
         $out = null;
         if ($error) {
                 trigger_error("<span style = \"color:Red;text-
 align:left\"><b>SQL Error:</b> {$this->error}</span>", E_USER_WARNING);
         } else {
                 $out = ("<small>[Aff:{$this->affected}
 Num:{$this->numRows} Took:{$this->took}ms]</small>");
         }
         pr(sprintf("<p style = \"text-align:left\"><b>Query:</b> %s
 %s</p>", $sql, $out));
 }
 }}}

 As you can see the else part can never be reached since $error will always
 be true. I guess it should check for '''OR''' instead of '''AND'''.
 [[BR]][[BR]]
 Regards[[BR]]
 Frank

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5983>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to