Newer
Older
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
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Entities Model
* @author dev@maarch.org
* @ingroup entities
*/
namespace Entities\Models;
require_once 'apps/maarch_entreprise/services/Table.php';
class EntitiesModelAbstract extends \Apps_Table_Service
{
public static function getByEmail(array $aArgs = [])
{
static::checkRequired($aArgs, ['email']);
static::checkString($aArgs, ['email']);
$aReturn = static::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['entities'],
'where' => ['email = ? and enabled = ?'],
'data' => [$aArgs['email'], 'Y'],
'limit' => 1,
]);
return $aReturn;
}
public static function getByUserId(array $aArgs = [])
{
static::checkRequired($aArgs, ['user_id']);
static::checkString($aArgs, ['user_id']);
$aReturn = static::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
'table' => ['users_entities'],
'where' => ['user_id = ? and primary_entity = ?'],
'data' => [$aArgs['user_id'], 'Y'],
'limit' => 1,
]);
return $aReturn;
}
}