Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 234

Přidáno uživatelem Tomáš Dulík před více než 15 roky(ů)

Pridana funkce get_member_by_phone

Zobrazit rozdíly:

freenetis/trunk/kohana/application/models/member.php
->join('enum_types', 'members.type=enum_types.id', NULL, "LEFT")
->join('users', 'users.member_id = members.id', NULL, "LEFT")
->where("members.id=$id AND users.id IS NOT NULL")->limit(1)->get();
}
}
/**
* @author Tomas Dulik
* @return unknown_type
*
*/
public function get_member_by_phone($phone) {
$q="SELECT * FROM members
WHERE id = (
SELECT member_id
FROM users
WHERE REPLACE( phone, ' ', '' ) LIKE '$phone'
LIMIT 1
) ";
/* Slower alternative:
$q='SELECT members.id FROM members JOIN users on members.id=users.member_id where REPLACE(phone," ", "") LIKE '%$phone%' LIMIT 1';
*/
$query=self::$db->query($q);
return $query->current();
}
/* array('id' => 5, 'title' => 'Demo')
public function get_one_user($)
{
return self::$db->from('members')->join('users', 'users.member_id = members.id')->where('login', 'kenod')->get();
}
//*/
}
?>

Také k dispozici: Unified diff