我如何可以检索从SugarCRM的一个表中的所有记录? [英] How can i retrieve all the records from a table in SugarCRM?

查看:169
本文介绍了我如何可以检索从SugarCRM的一个表中的所有记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的糖Pro的6.1,想知道我怎么可以检索所有的产品,从产品表中其ID。我想有以下code

I am using Sugar Pro 6.1 and want to know that how can i retrieve all the products with their ids from the products table. I am trying with the following code

$sql = "SELECT id, name FROM products order by name"; 
$result = $GLOBALS["db"]->query($sql);
$products = $GLOBALS["db"]->fetchByAssoc($result);

但它总是只返回第一条记录。

but it always returns only the first record.

是否有可能抓住所有的产品与他们的ID来显示它们在一个HTML下拉列表中,我想,为什么我使用Ajax调用,并在一个单独的PHP文件我用下来的JavaScript文件多数民众赞成以显示该降上述code,返回的输出中的AJAX调用。

Is it possible to grab all the products with their ids to display them in a html dropdown, i want to display that drop down in a javascript file thats why i am using the ajax call and in a seperate php file i am using the above code that returns the ouput to the ajax call.

任何帮助将AP preciated!

Any help will be appreciated!

推荐答案

fetchByAssoc()只抓住一次一个记录。相反,你需要遍历直通调用fetchByAssoc()这样的...

fetchByAssoc() only grabs one record at a time. Instead, you need to iterate thru calling fetchByAssoc() like this...

$sql = "SELECT id, name FROM products order by name"; 
$result = $GLOBALS["db"]->query($sql);
while ( $product = $GLOBALS["db"]->fetchByAssoc($result) ) {
     $products[] = $product;
}

这篇关于我如何可以检索从SugarCRM的一个表中的所有记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆