简体   繁体   English

CodeIgniter-解析器类和数据库问题

[英]CodeIgniter - Parser Class and DB Issue

Oddest bug. 最奇怪的错误。

I'm parsing a template and inserting same values pulled from a db. 我正在解析一个模板,并插入从数据库中提取的相同值。 I also have a model set up that logs some statistics each time the parsed page is viewed(all brought together in the same method). 我还建立了一个模型,该模型每次查看已解析的页面时都会记录一些统计信息(所有信息都以相同的方法组合在一起)。 Trouble I'm having is that the stat is logged three times in the db. 我遇到的问题是该统计信息在数据库中记录了3次。 Identical values on three different rows. 三个不同行上的值相同。

I am using some routing and pull an id and parameter2 value from the URL. 我正在使用一些路由,并从URL中提取id和parameter2值。

This has been bugging me all day and any ideas would be appreciated 这整天困扰着我,任何想法都将不胜感激

Is it getting called once or three times? 它被调用一次还是三遍? Try stepping through the code with an IDE or FireBug... 尝试使用IDE或FireBug单步执行代码...

So it seems that the parsing library runs through the template code for each piece of data it needs to replace. 因此,解析库似乎遍历了需要替换的每个数据的模板代码。

foreach ($data as $key => $val)
        {
            if (is_array($val))
            {
                $template = $this->_parse_pair($key, $val, $template);      
            }
            else
            {
                $template = $this->_parse_single($key, (string)$val, $template);
            }
        }

So I'm now trying to determine the best way to parse the data without a loop. 因此,我现在正在尝试确定无循环分析数据的最佳方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM