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
typo3
qfq
Commits
b85fa0ac
Commit
b85fa0ac
authored
Oct 10, 2017
by
Carsten Rose
Browse files
Database.php: Code Cleanup
parent
bbc80136
Changes
3
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/Constants.php
View file @
b85fa0ac
...
@@ -524,11 +524,6 @@ const VAR_FILE_DESTINATION = 'fileDestination';
...
@@ -524,11 +524,6 @@ const VAR_FILE_DESTINATION = 'fileDestination';
const
VAR_SLAVE_ID
=
ACTION_KEYWORD_SLAVE_ID
;
const
VAR_SLAVE_ID
=
ACTION_KEYWORD_SLAVE_ID
;
const
VAR_FILENAME
=
'filename'
;
// Original filename of an uploaded file.
const
VAR_FILENAME
=
'filename'
;
// Original filename of an uploaded file.
// PHP class DB can operate in these modes
const
MODE_DB_REGULAR
=
'regular'
;
const
MODE_DB_NO_LOG
=
'noLog'
;
// PHP class Typeahead
// PHP class Typeahead
const
TYPEAHEAD_API_QUERY
=
'query'
;
// Name of parameter in API call of typeahead.php?query=...&s=... - See also FE_TYPE_AHEAD_SQL
const
TYPEAHEAD_API_QUERY
=
'query'
;
// Name of parameter in API call of typeahead.php?query=...&s=... - See also FE_TYPE_AHEAD_SQL
const
TYPEAHEAD_API_PREFETCH
=
'prefetch'
;
// Name of parameter in API call of typeahead.php?prefetch=...&s=... - See also FE_TYPE_AHEAD_SQL
const
TYPEAHEAD_API_PREFETCH
=
'prefetch'
;
// Name of parameter in API call of typeahead.php?prefetch=...&s=... - See also FE_TYPE_AHEAD_SQL
...
...
extension/qfq/qfq/database/Database.php
View file @
b85fa0ac
...
@@ -63,23 +63,13 @@ class Database {
...
@@ -63,23 +63,13 @@ class Database {
* @throws CodeException
* @throws CodeException
* @throws UserFormException
* @throws UserFormException
*/
*/
public
function
__construct
(
$mode
=
MODE_DB_REGULAR
)
{
public
function
__construct
()
{
$dbInit
=
''
;
$dbInit
=
''
;
switch
(
$mode
)
{
$this
->
store
=
Store
::
getInstance
();
case
MODE_DB_REGULAR
:
$config
=
$this
->
store
->
getStore
(
STORE_SYSTEM
);
$this
->
store
=
Store
::
getInstance
();
$this
->
sqlLog
=
$this
->
store
->
getVar
(
SYSTEM_SQL_LOG
,
STORE_SYSTEM
);
$config
=
$this
->
store
->
getStore
(
STORE_SYSTEM
);
$dbInit
=
$this
->
store
->
getVar
(
SYSTEM_DB_INIT
,
STORE_SYSTEM
);
$this
->
sqlLog
=
$this
->
store
->
getVar
(
SYSTEM_SQL_LOG
,
STORE_SYSTEM
);
$dbInit
=
$this
->
store
->
getVar
(
SYSTEM_DB_INIT
,
STORE_SYSTEM
);
break
;
case
MODE_DB_NO_LOG
:
$configClass
=
new
Config
();
$config
=
$configClass
->
readConfig
();
break
;
default
:
throw
new
\
qfq\CodeException
(
'Unknown mode: '
.
$mode
,
ERROR_UNKNOWN_MODE
);
}
if
(
$this
->
mysqli
===
null
)
{
if
(
$this
->
mysqli
===
null
)
{
$this
->
mysqli
=
$this
->
dbConnect
(
$config
);
$this
->
mysqli
=
$this
->
dbConnect
(
$config
);
...
@@ -91,7 +81,6 @@ class Database {
...
@@ -91,7 +81,6 @@ class Database {
}
}
}
}
/**
/**
* Open mysqli database connection if not already done.
* Open mysqli database connection if not already done.
*
*
...
...
extension/qfq/tests/phpunit/AbstractDatabaseTest.php
View file @
b85fa0ac
...
@@ -77,14 +77,14 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
...
@@ -77,14 +77,14 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
$this
->
db
=
new
qfq\Database
();
$this
->
db
=
new
qfq\Database
();
}
}
/// Establish additional mysqli access
$dbserver
=
$this
->
store
->
getVar
(
SYSTEM_DB_SERVER
,
STORE_SYSTEM
);
$dbuser
=
$this
->
store
->
getVar
(
SYSTEM_DB_USER
,
STORE_SYSTEM
);
$db
=
$this
->
store
->
getVar
(
SYSTEM_DB_NAME
,
STORE_SYSTEM
);
$dbpw
=
$this
->
store
->
getVar
(
SYSTEM_DB_PASSWORD
,
STORE_SYSTEM
);
if
(
self
::
$mysqli
===
null
)
{
if
(
self
::
$mysqli
===
null
)
{
/// Establish additional mysqli access
$dbserver
=
$this
->
store
->
getVar
(
SYSTEM_DB_SERVER
,
STORE_SYSTEM
);
$dbuser
=
$this
->
store
->
getVar
(
SYSTEM_DB_USER
,
STORE_SYSTEM
);
$db
=
$this
->
store
->
getVar
(
SYSTEM_DB_NAME
,
STORE_SYSTEM
);
$dbpw
=
$this
->
store
->
getVar
(
SYSTEM_DB_PASSWORD
,
STORE_SYSTEM
);
self
::
$mysqli
=
new
\
mysqli
(
$dbserver
,
$dbuser
,
$dbpw
,
$db
);
self
::
$mysqli
=
new
\
mysqli
(
$dbserver
,
$dbuser
,
$dbpw
,
$db
);
if
(
self
::
$mysqli
->
connect_errno
)
{
if
(
self
::
$mysqli
->
connect_errno
)
{
...
...
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