Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
apisub
Commits
743643e1
Unverified
Commit
743643e1
authored
Nov 07, 2018
by
Rémy Huet
💻
Browse files
Encapsulation and params types
parent
1fbeb0e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/db.php
View file @
743643e1
...
...
@@ -4,7 +4,7 @@ class DB {
private
$conn
;
function
__construct
()
{
public
function
__construct
()
{
include
'connexion.php'
;
try
{
$this
->
conn
=
new
PDO
(
'pgsql:host=localhost;port=5432;dbname=apisub'
,
$db_user
,
$db_pass
);
...
...
@@ -13,7 +13,7 @@ class DB {
}
}
function
subList
(
string
$utclogin
)
:
array
{
public
function
subList
(
string
$utclogin
)
:
array
{
$sql
=
'SELECT *
FROM vsubscription
WHERE utclogin=:utclogin'
;
...
...
@@ -26,7 +26,7 @@ class DB {
return
$res
;
}
function
apiList
(
string
$semester
,
int
$year
)
:
array
{
public
function
apiList
(
string
$semester
,
int
$year
)
:
array
{
$sql
=
'SELECT *
FROM vApi
WHERE semester=:semester AND year=:year'
;
...
...
@@ -40,7 +40,7 @@ class DB {
return
$res
;
}
function
subToApi
(
$utclogin
,
$api
)
:
bool
{
public
function
subToApi
(
string
$utclogin
,
int
$api
)
:
bool
{
$today
=
date
(
'Ymd'
);
$sql
=
'INSERT INTO subscribe(utclogin, api, subdate) VALUES (:utclogin, :api, :today)'
;
$st
=
$this
->
conn
->
prepare
(
$sql
);
...
...
@@ -53,7 +53,7 @@ class DB {
return
$res
;
}
function
unsubToApi
(
$utclogin
,
$api
)
:
bool
{
public
function
unsubToApi
(
string
$utclogin
,
int
$api
)
:
bool
{
$sql
=
'DELETE FROM subscribe WHERE utclogin=:utclogin AND api=:api'
;
$st
=
$this
->
conn
->
prepare
(
$sql
);
$res
=
$st
->
execute
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment