2014-02-26 162 views
-1

我能够获取任何表我需要的信息问题这里是更新,插入和删除记录,不起作用。更新,插入,删除记录Joomla表

我看过的Joomla文档的,但即使做最简单的更新查询不工作...所以这里是我的代码:

UPDATE:

// I'm getting the data from an array 
if (!empty($_POST['data'])) { 
    $getData = json_decode($_POST['data'], true); 
} 
// after this line I have a foreach for the array 
// in the foreach I have a few IF's 
// ether if the result from IF is True or False 
// in both I have similar queries 
// So let say IF return true; 
// Lets prepare the Data using OBJECT's 

$object = new stdClass(); 
$object->product_id = $v['product_id']; 
$object->product_name = $v['product_name']; 
$object->product_price = $v['product_price']; 
$object->product_number = $v['product_number']; 

$result = JFactory::getDbo()->updateObject('#__tienda_product', $object, 'product_number'); 
// that should Update my tables but it doesn't ... now my table has about 21 columns 
// but I only need to update 4 columns base on the column product_number 

您可能注意到了$ V ['product_id']其中$ v来自foreach,foreach和第一个查询工作正常,我在转移到Update部分之前做了几个echo,以确保我以一种格式获取正确的数据应该是...任何方式...更新部分不工作...所以我认为这可能是因为我的桌子我什么时候使用常规instalati中的一张桌子上的Joomla ...但它仍然是相同的更新没有结果......

是否有任何人知道如何“更新”使用Joomla CMS作为框架表?...
记住我想使用updateObject()方法...

为什么我不使用Joomla Framework而不是CMS的库?
嗯,我可以给你几个例子,比如说:
一个商人想要一个简单的基本报告,他不在乎管理他有人要做的那个网站,他也得到一份销售报告,但他现在还不相信机组人员,他希望能够看到和比较结果,而且他需要和独立,而不需要所有joomla拥有的那些奇特的工具,为此他需要一个可以提供这种报告的独立应用程序...好吧,我可能走得很远,但想法是让基本的,简单的,易于阅读的报告和更新,这就是为什么我开始这个项目。

同样,我已经去了joomla并阅读文档,但他们的例子后,它只是不工作...现在,即使他们不需要更新,我必须删除所有的列?或者我错过了执行的查询,在joomla没有提及任何执行时只使用常规查询时使用$ object()SQL ...想法是使用$ object()...
谢谢花时间。

回答

1

您已将updateobject定义为变量,但未调用它。尝试改变这一点:

$result = JFactory::getDbo()->updateObject('#__tienda_product', $object, 'product_number'); 

这样:

JFactory::getDbo()->updateObject('#__tienda_product', $object, 'product_number'); 

此外,在一个侧面说明,你不应该使用$_POST,而是应该使用JInput

+0

是没有做的事情.. 。是的,我也想到了,我在$ print_r()中使用$ result。 ...我只是删除它,但没有做任何事情,结果是一样的...谢谢。 – Tanker

+1

这张桌子的主要关键是什么? 'product_id'或'product_number'?你有没有尝试过使用'var_dump(...);'来查看是否有实际存在的结果? – Lodder

+0

主要ID是product_id,但由于我们正在比较两个不同的数据库集,一个是本地的,另一个是活的,所以本地没有相同的ID,唯一相同的是产品编号或SKU,如果你想这样做,所以当他们发送请求时,我不使用product_id进行比较或查找有问题的产品,我使用的是product_number,因为这两个数据库中的信息相同。 – Tanker

相关问题