Zend DB Framework examine query for an update

前端 未结 4 1727
迷失自我
迷失自我 2020-12-23 10:33

So you can use something like this:

$query = $db->select();
$query->from(\'pages\', array(\'url\'));
echo $query->__toString();

to

4条回答
  •  猫巷女王i
    2020-12-23 11:12

    Use Zend_Db_Profiler to capture and report SQL statements:

    $db->getProfiler()->setEnabled(true);
    $db->update( ... );
    print $db->getProfiler()->getLastQueryProfile()->getQuery();
    print_r($db->getProfiler()->getLastQueryProfile()->getQueryParams());
    $db->getProfiler()->setEnabled(false);
    

    Remember to turn the profiler off if you don't need it! I talked to one fellow who thought he had a memory leak, but it was the profiler instantiating a few PHP objects for each of the millions of SQL queries he was running.

    PS: You should use quoteInto() in that query:

    $n = $db->update('pages', $data, $db->quoteInto("url = ?", $content));
    

提交回复
热议问题