-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProfile.php
More file actions
63 lines (57 loc) · 1.84 KB
/
Profile.php
File metadata and controls
63 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* Created by PhpStorm.
* User: davidamackenzie
* Date: 6/29/19
* Time: 3:21 PM
*/
class Profile extends DBObject
{
static $tableName = 'profiles';
static $columns = [
'id'=>['name'=>'id','primary_key'=>true],
'account_id'=>['name'=>'account_id', 'foreign_key'=>true, 'foreign_table' => Account::class],
'preferred_name'=>['name'=>'preferred_name'],
'birthday'=>['name'=>'birthday'],
'picture_file'=>['name'=>'picture_file'],
'nyc'=>['name'=>'nyc'],
'contact'=>['name'=>'contact'],
'bioline'=>['name'=>'bioline'],
'bio1'=>['name'=>'bio1'],
'bio2'=>['name'=>'bio2'],
'bio3'=>['name'=>'bio3']
];
static function getColumns() {
return self::$columns;
}
static function getTableName() {
return self::$tableName;
}
static function newProfie($account) {
$account_id = $account->getValue('id');
$values = [Profile::getColumns()['account_id']['name']=>$account_id];
$obj = new Profile($values,false);
return $obj;
}
static function getProfileByAccount($account) {
$db = DBConnectionFactory::Instance();
$values = [Profile::getColumns()['account_id']['name'] => $account->getValue('id')];
$results = $db->select(Profile::getTableName(),$values);
//error_log(json_encode($results));
if (count($results)>0) {
$profileObj = new Profile($results[0]);
return $profileObj;
}
return false;
}
static function getMatches() {
$db = DBConnectionFactory::Instance();
$matches = [];
$results = $db->select(Profile::getTableName());
foreach ($results as $row) {
$profileObj = new Profile($row);
$matches[] = $profileObj;
}
return $matches;
}
}