Mark Steudel-3 wrote: > > Hi All, > > > > I was wondering if it was possible to get back the last run query > including > the values that get swapped in place of the ? > > > > E.g. if I did: > > $id = 4; > > > > $sql = "SELECT id FROM table WHERE id = ?"; > > > > $rows = $this->db->fetchAll( $sql, $id ); > > > > echo $this->db->lastQuery(); > > > > It would spit back SELECT id FROM table WHERE id = 4. > > > > I tried using the profiler, but it just gives me back the sql statement > before $id gets passed into it. > > > > Thanks, Mark > > > > >
I was interested in this same type of output from the profiler. Here's what I ended up doing. $profiler = $db->getProfiller(); $profiles = $pofiler->getQueryProfiles(); foreach ($profiles as $query) { $q = str_replace('?', '<span style="background-color: yellow">%s</span>', $query->getQuery()); $q = vsprintf($q, array_map(array($db, 'quote'), $query->getQueryParams())); print "$q\n"; } This gives me the actual queries with the replaced values highlighted. -- View this message in context: http://www.nabble.com/Zend_Db--%3E-last-query-with-values-tp17738679p17983910.html Sent from the Zend Framework mailing list archive at Nabble.com.