Jump to content

How to assign result of $this->_select query to a variable


oowwaa

Recommended Posts

Hello, i have a $this->_select  statement in my AdminOrdersController.php override, which add a column "Address tester"

$this->_select .= ', 
address.`address1` as saddress,
a.id_order as id_trackingField,
a.id_order as id_manageBtns,
a.id_order as id_addressField,
CONCAT(
address.`firstname`," ", address.`lastname`, "\n", 
address.`address1`, \' \', 
address.`address2`, \' \', 
address.`postcode`," ", address.`city`, \' \', 
country_lang.`name`,\' \'
) as sAddressFull
';
$this->fields_list['sAddressFull'] = array(
'title' => $this->l('Address tester')
);

It adds the correct address data in the "Address tester" column, however i need this data (sAddressFull) to be assigned to a variable instead, how to achieve this?

        $sql = new DbQuery();
        $sql->from('order');
		$sql->_select .= ', 
		address.`address1` as saddress,
		CONCAT(
		address.`firstname`," ", address.`lastname`, "\n", 
		address.`address1`, \' \', 
		address.`address2`, \' \', 
		address.`postcode`," ", address.`city`, \' \', 
		country_lang.`name`,\' \'
		) as sAddressFull
		';

        $customVal = Db::getInstance()->getValue($sql);         
        //$customVal =  Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);

        $this->context->smarty->assign('fullAddress',print_r ($customVal));

All my other attempts failed as well.

Edited by oowwaa (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...