Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
agenda-libre
agenda-libre-php
Commits
12512a6f
Commit
12512a6f
authored
Nov 27, 2018
by
Loïc DAYOT
Committed by
Ploc
Apr 10, 2019
Browse files
chore: code adaptation to mysqli
Due to warnings in recent php version, migrate from mysql to mysqli extension.
parent
44ace62f
Changes
1
Hide whitespace changes
Inline
Side-by-side
www/inc/class.bd.inc.php
View file @
12512a6f
...
...
@@ -30,34 +30,32 @@
class
db
{
function
db
()
var
$db_link
;
function
__construct
()
{
global
$db_host
;
global
$db_user
;
global
$db_pass
;
global
$db_name
;
if
(
@
mysql_connect
(
$db_host
,
$db_user
,
$db_pass
)
==
FALSE
)
$this
->
db_link
=
@
new
mysqli
(
$db_host
,
$db_user
,
$db_pass
,
$db_name
);
if
(
$this
->
db_link
->
connect_errno
)
{
echo
"Probleme de connexion à la base de données sur
$db_host
.
\n
"
;
return
0
;
echo
"Erreur de connexion ("
.
$this
->
db_link
->
connect_errno
.
") "
.
$this
->
db_link
->
connect_error
;
die
();
}
if
(
@
mysql_select_db
(
$db_name
)
==
FALSE
)
{
echo
"Problème de selection de la base de données
$db_name
sur
$db_host
.
\n
"
;
return
0
;
}
mysql_query
(
"set names 'utf8'"
);
$this
->
query
(
"set names 'utf8'"
);
}
function
query
(
$query
)
{
if
(
(
$result
=
@
mysql_
query
(
$query
))
==
FALSE
)
if
(
(
$result
=
$this
->
db_link
->
query
(
$query
))
==
FALSE
)
{
echo
"Probleme dans la syntaxe de
$query
: "
.
mysql_
error
()
.
"
\n
"
;
return
0
;
echo
"Probleme dans la syntaxe de
$query
: "
.
$this
->
db_link
->
error
.
"
\n
"
;
return
0
;
}
return
$result
;
...
...
@@ -65,37 +63,37 @@ class db
function
insertid
()
{
return
mysql_
insert_id
()
;
return
$this
->
db_link
->
insert_id
;
}
function
fetchObject
(
$result
)
{
return
mysql_
fetch_object
(
$result
);
return
$result
->
fetch_object
();
}
function
fetchArray
(
$result
)
{
return
mysql_
fetch_array
(
$result
);
return
$result
->
fetch_array
();
}
function
fetchRow
(
$result
)
{
return
mysql_
fetch_row
(
$result
);
return
$result
->
fetch_row
();
}
function
freeResult
(
$result
)
{
return
mysql_
free_result
(
$result
);
return
$result
->
free_result
();
}
function
numRows
(
$result
)
{
return
mysql_num_rows
(
$result
)
;
return
$result
->
num_rows
;
}
function
getOne
(
$result
)
{
$row
=
$this
->
fetchArray
(
$result
);
return
$row
[
0
];
$row
=
$this
->
fetchArray
(
$result
);
return
$row
[
0
];
}
/**
...
...
@@ -111,7 +109,7 @@ class db
$value
=
stripslashes
(
$value
);
if
(
!
is_numeric
(
$value
))
$value
=
"'"
.
mysql_
real_escape_string
(
$value
)
.
"'"
;
$value
=
"'"
.
$this
->
db_link
->
real_escape_string
(
$value
)
.
"'"
;
return
$value
;
}
...
...
Write
Preview
Supports
Markdown
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