Skip to content

Examples

Murtnowski edited this page Dec 17, 2011 · 18 revisions

Controller
public function controllerfunction()
{
	$this->load->database();
			
	$this->load->model("m_MyModel");
			
	$mySQLResults = $this->m_MyModel->getSomething(); //Get the list of recent trades to display
			
	$json = $this->_jsonify($mySQLResults["Result"], $mySQLResults["iTotalRecords"], $mySQLResults["iTotalDisplayRecords"]);
			
	echo $json;	
}

Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	class m_MyModel extends CI_Model 
	{
		var $MyQuery = "SELECT SUBSTRING_INDEX(FIM, '.', 1), Buy_Sell, Client, Destination, IF(Destination = 'UBS','UBS', Service), SUM(Volume_Done), (SUM(Fill_Price * Volume_Done)/ Sum(Volume_Done)), DATE(Entered_DateTime), Status, NULL FROM tblFidessaImport GROUP BY Buy_Sell, SUBSTRING_INDEX(FIM, '.', 1), SUBSTRING_INDEX(FIM, '.', -1), ISIN_CODE, Client, Dealt_Currency, Destination, Mic, IF(Destination = 'UBS','UBS',Service), DATE(Entered_DateTime) HAVING SUM(Volume_Done) > 0";
		
		function __construct()
		{
			parent::__construct();
		}
		
		public function getSomething()
		{
			$this->load->library('DatatablesHelper');
			
			return $this->datatableshelper->query($this->MyQuery);
		}
	}
?>

Clone this wiki locally
You can’t perform that action at this time.