Source

Community Cart / application / models / checkout_model.php

Full commit
<?php
class Checkout_model extends CI_Model {

	public function get_user_data($user_name)
	{
		if($user_name !== FALSE)
		{
			$this->db->where('user_name', $user_name);
		}
		$query = $this->db->get_where($this->config->item('user_table'));
		return $query->row();
	}

	public function insert_order($insert_array, $order_number)
	{
		$this->db->where('order_number',$order_number);
		if($this->db->update($this->config->item('orders_table'), $insert_array) !== FALSE)
		{
			return TRUE;
		}

		return FALSE;
	}

	public function insert_order_temp($insert_array)
	{
		$this->db->set($insert_array);
		if($this->db->insert($this->config->item('orders_temp_table')) !== FALSE)
		{
			return TRUE;
		}

		return FALSE;
	}

	public function match_ipn_order($order_number)
	{
		$this->db->where('order_number',$order_number);
		if($query = $this->db->get($this->config->item('orders_temp_table')))
		{
			foreach($query->result() as $row)
			{
				return $row;
			}
		}
		else
		{
			return FALSE;
		}
	}

	public function get_user_id($user_name)
	{
		$this->db->where('user_name',$user_name);
		if($query = $this->db->get($this->config->item('user_table')))
		{
			foreach($query->result() as $row)
			{
				return $row;
			}
		}
		else
		{
			return FALSE;
		}
	}

	public function make_new_row()
	{
		$make_row = array(
			'order_time' => time()
		);
		$this->db->set($make_row);
		if($this->db->insert($this->config->item('orders_table')) !== FALSE)
		{
			return $this->db->insert_id();
		}

		return FALSE;
	}

	public function delete_temp_row($order_number)
	{
		$this->db->where('order_number', $order_number);
		$this->db->delete($this->config->item('orders_temp_table')); 
	}

}
/* End of file checkout_model.php */
/* Location: /application/models/checkout_model.php */