php - 为什么我的 SQL 脚本停止了?

标签 php mysql function size prestashop

我有一个关于 PHP/MYSQL 的问题。我有一个函数,它获取 MYSQL 表中的颜色列表并将它们呈现为多个 HTML 表。想法是,除非客户选择某个选项,否则大多数将被隐藏。当用户将鼠标放在一种颜色上时,它会加载更详细的图片。它工作正常,但是在一定数量的字符后脚本停止执行,这里是代码:

要求:

$sql = 'SELECT *, GROUP_CONCAT(description ORDER BY i.model_correspondance ASC) AS concat,     GROUP_CONCAT(model_correspondance ORDER BY i.model_correspondance ASC) AS modell, GROUP_CONCAT(element) AS elem, GROUP_CONCAT(coordinates ORDER BY i.model_correspondance ASC) AS coord FROM design_tool_items AS i WHERE i.model='.$shoe.' GROUP BY i.element, i.category, i.subelement ORDER BY i.id ASC';

以及其余的 PHP:

        if ($results = Db::getInstance()->ExecuteS($sql)) {
            foreach ($results as $row) {

                if($row['subelement']=='') {
                    if(isset($i)) $code .= '</div>';
                        $code .= '<div class="'.$display.' color_holder" rel="'.$row['style'].'" id="div'.$row['subelement'].'.'.$row['element'].'">';
                        $i=1;
                } else {
                    $code .= '</div>';
                    $code .= '<div class="no color_holder" rel="'.$row['style'].'" id="div'.$row['subelement'].'.'.$row['element'].'">';
                }

                $sentinel = $row['element'];
                $code .= '<div style="text-align:left;padding:10px">'.$row['category'].'</div>';
                $concat = explode(',', $row['concat']);
                $coordinate = explode(',', $row['coord']);
                $model_corres = explode(',', $row['modell']);

                foreach($concat as $item => $corres) {

                    if(($i==1)&&(array_search($sentinel, $array_elements)===false)) { 
                        $array_elements[] = $sentinel;
                        $select = 'selected';
                    } else $select = '';

                    $coord = explode('#', $coordinate[$item]);

                    $clean_array = array($row['category'], $corres);
                    foreach($clean_array as &$text) {
                        $text = str_replace(' ', '_', $text);
                        $text = strtolower($text);  
                    }

                    $code .= '<div style="width:60px;padding-left:10px;margin:auto;float:left;">';
                    $code .= '<div onmouseover="Tip(\'<div><img style=width:200px;height:200px; src='.$val.'folded_images/'.$clean_array[0].'/'.$clean_array[1].'.jpg alt=Image:'.$corres.' /><br>'.$corres.'</div>\')" onmouseout="UnTip()" rel="'.$row['style'].'" denom="'.$row['subelement'].'.'.$sentinel.$model_corres[$item].'" class="color '.$select.'" style="background-position:'.$coord[0].'px '.$coord[1].'px;"></div>';
                    $code .= '</div>';
                    if(is_int($i/3)) $code .= '<div style="clear:both;"></div>';
                    $i++;
                }
                $code .= '<div style="clear:both;"></div>';
            }
        }

        return $code;

在第 100 行,脚本在中间停止工作,只显示描述的前三个字符。如果我减少前面描述的长度,它会进一步工作,所以问题来自数组 $concat。

您是否认为存在大小限制(我知道 PHP 5.2 中的 128Mb 和之前的 8Mb 但是该网站运行 PHP 5.2.3,我认为我离 128Mb 还很远)?

不好意思,话题太长了,先谢谢大家关注了。

祝你有美好的一天!

最佳答案

因为使用了GROUP_CONCAT

可能有用的有用链接。 link

关于php - 为什么我的 SQL 脚本停止了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15561854/

相关文章:

c++ - 别名成员对象方法的最佳方法? "Passthrough methods"

arrays - 从 postgresql 函数返回 BIGINT[]

php - 错误号 : 1292 Truncated incorrect DOUBLE value in my SQL error

php - 在 CakePHP 中,您如何确定字段是否在编辑操作中被更改?

MySQL 计数列表在一定价格范围内

mysql - Mysql中解析json数据

php - 选择特定年龄范围内的所有用户

php - zend.multibyte 指令到底有什么影响?

php - 使用 PHP 创建文本文件?

c++ - (C++) 与结构和函数参数有关的简单问题