Source

myswap / 1 / code / App / Lib / Model / SwapModel.class.php

Full commit
<?php
class SwapModel extends Model{
	protected $fields = array(
	"swap_id", 
	"user_id", 
	"alias", 
	"content", 
	"_pk"=>"swap_id",
	"_autoinc"=>true
	);

	private function _c($s){
		$mysql = new SaeMysql();
		return $mysql->escape($s);
	}
	public function getSwaps($user_id)
	{
	// $user_id=$UserModel["user_id"];
	return  $this->query("select * from __TABLE__ WHERE user_id='$user_id' ORDER BY swap_id DESC");
	}
	public function getById($swap_id)
	{
	$username=$this->_c($username);
	return  $this->query("select * from __TABLE__ WHERE swap_id='$swap_id' ");
	}
    public function getByAlias($UserModel,$alias)
    {
	$alias=$this->_c($alias);
	$user_id=$UserModel["user_id"];
	$sql="select * from __TABLE__  WHERE   user_id ='$user_id' AND  alias=  '$alias' ";
	return  $this->query($sql);
	}
	public function have_alias_with_user($user_id,$alias)
	{
	$alias=$this->_c($alias);
	$alias=strtolower($alias);
	return  $this->query("select * from __TABLE__ where alias='$alias' AND user_id='$user_id'");
	}
}
?>