3

Grabbing complete table records in sugarcrm using beans. i just want to fetch complete records without any condition.

what is the equivalent of following query in sugarcrm?

select * from accounts;

How can we grab records using beans only?

Amitesh Kumar
  • 3,051
  • 1
  • 26
  • 42
divya
  • 91
  • 3

2 Answers2

0

Try to use sugar query.

<?php
$query = new SugarQuery();
$query->from(BeanFactory::getBean('Accounts'));
$contacts = $query->join('contacts')->joinName();
$query->select(array("$contacts.full_name"));   
$query->where()->equals('industry','Media');
$results = $query->execute();

Below Link will help you more.

Link 1 to read

Link 2 to read

Amitesh Kumar
  • 3,051
  • 1
  • 26
  • 42
0
$account = BeanFactory::getBean('Accounts');
$results = $account->get_full_list();

here is the method, in data/SugarBean.php, showing various parameters you may pass to this method (including a $where condition). Note that SugarCRM will not show you deleted records, though this method indicates that if you have set the SESSSION variable 'show_deleted' you will override this.

/**
* Returns a full (ie non-paged) list of the current object type.
*
* @param string $order_by the order by SQL parameter. defaults to ""
* @param string $where where clause. defaults to ""
* @param boolean $check_dates. defaults to false
* @param int $show_deleted show deleted records. defaults to 0
*/
function get_full_list($order_by = "", $where = "", $check_dates=false, $show_deleted = 0)
{
    $GLOBALS['log']->debug("get_full_list:  order_by = '$order_by' and where = '$where'");
    if(isset($_SESSION['show_deleted']))
    {
        $show_deleted = 1;
    }
    $query = $this->create_new_list_query($order_by, $where,array(),array(), $show_deleted);
    return $this->process_full_list_query($query, $check_dates);
}
fbas
  • 1,676
  • 3
  • 16
  • 26
  • it is worth noting that get_full_list() may be memory intensive (obviously depends on the number of records in the system). there is a paginated version of this routine: get_list(). – fbas Mar 30 '16 at 14:42