1

我有这段代码:

<?php 
$dsn = 'mysql:host=localhost;dbname=dbase;charset=utf8';
$username = 'dbaseu';
$password = '123456f';

$db = new PDO($dsn,  $username, $password, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));

foreach($db->query('SELECT DISTINCT
oc_product.product_id AS unu,
GROUP_CONCAT(oc_category_description.name) AS doi,
oc_product.model AS trei,
oc_product.image AS patru,
oc_product.price AS cinci,
oc_product_description.name AS sase,
oc_product_description.description AS sapte,
GROUP_CONCAT(oc_product_image.image) AS opt
FROM
oc_product INNER JOIN oc_product_description ON oc_product.product_id = oc_product_description.product_id
INNER JOIN oc_product_image ON oc_product_description.product_id = oc_product_image.product_id
INNER JOIN oc_product_to_category ON oc_product_image.product_id = oc_product_to_category.product_id
INNER JOIN oc_category_description ON oc_product_to_category.category_id = oc_category_description.category_id
GROUP BY unu') as $row) //*** THIS IS LINE 44 ***
?>

<table id="mytable">
<thead><tr><th>ID</th><th>Category</th><th>Name</th><th>Poze</th></tr></thead>
<tbody>
<?php 
{
echo '<tr>';
echo '<td>'.$row['unu'].'</td><td>'.intoarce_unice($row['doi']).'</td><td>'.$row['sase'].'</td><td>'.intoarce_unice($row['opt']).'</td>';
echo '</tr>';
}
?>

和一个错误

致命错误:在 /var/.../htdocs/oc/flish/filter.php:44 中使用消息“SQLSTATE[01004]:字符串数据,右截断”未捕获异常“PDOException” 堆栈跟踪:#0 /var/。 ../htdocs/oc/flish/filter.php(44): unknown() #1 {main} 在第 44 行的 /var/.../htdocs/oc/flish/filter.php 中抛出

这里的问题到底是什么?该代码有效,但目前我只有大约 20 条记录,因此很容易检查。在 Linux 上安装标准 XAMPP 时,相同的代码不会引发错误。

4

0 回答 0