$datos = explode(';',$linea);
$product_ean = trim($datos[0]);
$product_price = trim($datos[1]);
$name_es = trim($datos[2]);
$short_description_es = trim($datos[3]);
echo $product_ean,'<br>';
echo $product_price,'<br>';
echo $name_es ,'<br>';
echo $short_description_es,'<br>';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$columns = array('product_id' ,'product_ean', 'product_price', 'name_es-ES', 'short_description_es-ES');
$values = array(NULL, $product_ean, $product_price, $name_es, $short_description_es);
$query
->insert($db->quoteName('vrg_jshopping_products'))
->columns($db->quoteName($columns))
->values(implode(',', $values));
$db->setQuery($query);
$db->execute();
显示错误页面时出错:应用程序实例化 错误:SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以便在#600; 600附近使用正确的语法,articulo nuevo 1,Articulo de test 1)&#39;在第3行
SQL = INSERT INTO vrg_jshopping_products
(product_id
,product_ean
,product_price
,name_es-ES
,short_description_es-ES
)VALUES(,600,1000, articulo nuevo 1,Articulo de test 1)
答案 0 :(得分:0)
您收到sql错误,因为您没有引用您的值。您可以使用下面的代码。
$columns = array('product_id' ,'product_ean', 'product_price', 'name_es-ES', 'short_description_es-ES');
$values = array(NULL, $product_ean, $product_price, $name_es, $short_description_es);
// Prepare the insert query.
$query
->insert($db->quoteName($table))
->columns($db->quoteName($columns))
->values(implode(',', $db->quote($values)));