Пехлеви Платформа DB исследует запрос на обновление

Я попробовал следующий, но не сработал;

    <span style="display: none;" id="doneimg">
        <img alt="done" title="The process has been complated successfully..." src="@Url.Content("~/Content/App_Icons/icos/tick_icon.gif")" />
    </span>

    <script type="text/javascript">
        //$(document).ready(function () {
            $("#doneimg").bind("load", function () { $(this).fadeIn('slow'); });
        //});
    </script>

но следующий работал просто отлично;

<script type="text/javascript">
        $(document).ready(function () {
            $('#doneimg').fadeIn("normal");
        });
</script>

            <span style="display: none;" id="doneimg">
                <img alt="done" title="The process has been complated successfully..." src="@Url.Content("~/Content/App_Icons/icos/tick_icon.gif")" />
            </span>
19
задан Bill Karwin 17 June 2009 в 21:45
поделиться

3 ответа

Используйте Zend_Db_Profiler для захвата и отправки отчетов SQL:

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

Не забудьте выключить профилировщик, если он вам не нужен! Я разговаривал с одним парнем, который думал, что у него утечка памяти, но это был профилировщик, создавший несколько объектов PHP для каждого из миллионов выполняемых им SQL-запросов.

PS: Вам следует использовать quoteInto () в этом запросе:

$n = $db->update('pages', $data, $db->quoteInto("url = ?", $content));
31
ответ дан 30 November 2019 в 03:53
поделиться

Нет, не напрямую, так как Zend Framework создает и выполняет SQL внутри метода адаптера Zend_Db_Adapter_Abstract :: update:

/**
 * Updates table rows with specified data based on a WHERE clause.
 *
 * @param  mixed        $table The table to update.
 * @param  array        $bind  Column-value pairs.
 * @param  mixed        $where UPDATE WHERE clause(s).
 * @return int          The number of affected rows.
 */
public function update($table, array $bind, $where = '')
{
    /**
     * Build "col = ?" pairs for the statement,
     * except for Zend_Db_Expr which is treated literally.
     */
    $set = array();
    foreach ($bind as $col => $val) {
        if ($val instanceof Zend_Db_Expr) {
            $val = $val->__toString();
            unset($bind[$col]);
        } else {
            $val = '?';
        }
        $set[] = $this->quoteIdentifier($col, true) . ' = ' . $val;
    }

    $where = $this->_whereExpr($where);

    /**
     * Build the UPDATE statement
     */
    $sql = "UPDATE "
         . $this->quoteIdentifier($table, true)
         . ' SET ' . implode(', ', $set)
         . (($where) ? " WHERE $where" : '');

    /**
     * Execute the statement and return the number of affected rows
     */
    $stmt = $this->query($sql, array_values($bind));
    $result = $stmt->rowCount();
    return $result;
}

Вы можете временно вставить var_dump и выйти из этого метода для проверки sql, чтобы убедиться, что он правильный:

/**
 * Build the UPDATE statement
 */
 $sql = "UPDATE "
         . $this->quoteIdentifier($table, true)
         . ' SET ' . implode(', ', $set)
         . (($where) ? " WHERE $where" : '');
 var_dump($sql); exit;
2
ответ дан 30 November 2019 в 03:53
поделиться

Я думаю, что другой способ - это регистрировать фактический SQL-запрос, а не изменять код библиотеки ZF, путем объединения данных профилировщика.

$db->getProfiler()->setEnabled(true);

$db->update( ... );

$query = $db->getProfiler()->getLastQueryProfile()->getQuery();

$queryParams = $db->getProfiler()->getLastQueryProfile()->getQueryParams();

$logger->log('SQL: ' . $db->quoteInto($query, $queryParams), Zend_Log::DEBUG);

$db->getProfiler()->setEnabled(false);
0
ответ дан 30 November 2019 в 03:53
поделиться
Другие вопросы по тегам:

Похожие вопросы: