All pastes #757258 Raw Edit

points model

public php v1 · immutable
·published 2007-11-01 03:25 UTC
rendered paste body
<?phpclass Mage_Points_Model_Points{	$write = Mage::getSingleton('core/resource')->getConnection('core_write');	public function getCustomerPoints($cust_id)	{		$sql = "SELECT points FROM points WHERE cust_id = $cust_id";		$currentPoints = $write->fetchOne($sql);		return $currentPoints;	}	public function saveCustomerPoints($cust_id, $points)	{		$write->insert('points', array('cust_id'=>$cust_id, 'points'=>$points));	}		public function updateCustomerPoints($cust_id, $points)	{		$currentPoints = getCustomerPoints($cust_id);		$write->update('points', array('points'=>$currentPoints+$points), 'cust_id='.(int)$cust_id);	}	}