sugarquery

$query = "select km.contacts_cx_tco_orders_1contacts_ida as sd from contacts_cx_tco_orders_1_c ct join cx_tco_orders c on c.id = km.contacts_cx_tco_orders_1cnx_tco_orders_idb where c.id = '".$active."' and c.deleted=0 and km.deleted=0";

How can i write in SugarQuery?

Parents
  • The SQL provided above is not valid, there is not a table known 'km'  and what is c.id = ".$active."?

    Without access to your instance. We can only guess at the exact query syntax but it would be similar to

    $query = new SugarQuery();
    $query->from(BeanFactory::newBean('CX_TCO_Orders");
    $query->join('contacts_cx_tco_orders_1_c', ['alias' => 'ct']);
    $query->select('ct.contacts_cx_tco_orders_1contacts_ida');
    $query->where()->equals('id', $active);

Reply
  • The SQL provided above is not valid, there is not a table known 'km'  and what is c.id = ".$active."?

    Without access to your instance. We can only guess at the exact query syntax but it would be similar to

    $query = new SugarQuery();
    $query->from(BeanFactory::newBean('CX_TCO_Orders");
    $query->join('contacts_cx_tco_orders_1_c', ['alias' => 'ct']);
    $query->select('ct.contacts_cx_tco_orders_1contacts_ida');
    $query->where()->equals('id', $active);

Children