Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
81dc9e36
Commit
81dc9e36
authored
Jan 19, 2019
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port recent changes in qa-db.php to DbConnection
parent
f3a8e6c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
31 deletions
+32
-31
DbConnection.php
qa-src/Database/DbConnection.php
+32
-31
No files found.
qa-src/Database/DbConnection.php
View file @
81dc9e36
...
...
@@ -278,7 +278,7 @@ class DbConnection
// check for cached results
if
(
isset
(
$selectspec
[
'caching'
]))
{
$cacheDriver
=
\Q2A\Storage\CacheFactory
::
getCacheDriver
();
$cacheKey
=
'q
2a.q
uery:'
.
$selectspec
[
'caching'
][
'key'
];
$cacheKey
=
'query:'
.
$selectspec
[
'caching'
][
'key'
];
if
(
$cacheDriver
->
isEnabled
())
{
$queryData
=
$cacheDriver
->
get
(
$cacheKey
);
...
...
@@ -290,8 +290,9 @@ class DbConnection
$query
=
'SELECT '
;
foreach
(
$selectspec
[
'columns'
]
as
$columnas
=>
$columnfrom
)
{
$query
.=
$columnfrom
.
(
is_int
(
$columnas
)
?
''
:
(
' AS '
.
$columnas
))
.
', '
;
$query
.=
is_int
(
$columnas
)
?
"
$columnfrom
, "
:
"
$columnfrom
AS `
$columnas
`, "
;
}
$query
=
substr
(
$query
,
0
,
-
2
);
if
(
isset
(
$selectspec
[
'source'
])
&&
strlen
(
$selectspec
[
'source'
])
>
0
)
{
$query
.=
' FROM '
.
$selectspec
[
'source'
];
...
...
@@ -497,6 +498,35 @@ class DbConnection
}
/**
* Return the full name (with prefix) of a database table identifier.
* @param string $rawName
* @return string
*/
public
function
addTablePrefix
(
$rawName
)
{
$prefix
=
QA_MYSQL_TABLE_PREFIX
;
if
(
defined
(
'QA_MYSQL_USERS_PREFIX'
))
{
switch
(
strtolower
(
$rawName
))
{
case
'users'
:
case
'userlogins'
:
case
'userprofile'
:
case
'userfields'
:
case
'messages'
:
case
'cookies'
:
case
'blobs'
:
case
'cache'
:
case
'userlogins_ibfk_1'
:
// also special cases for constraint names
case
'userprofile_ibfk_1'
:
$prefix
=
QA_MYSQL_USERS_PREFIX
;
break
;
}
}
return
$prefix
.
$rawName
;
}
/**
* Substitute single '?' in a SQL query with multiple '?' for array parameters.
* @param string $query
* @param array $params
...
...
@@ -538,35 +568,6 @@ class DbConnection
}
/**
* Return the full name (with prefix) of a database table identifier.
* @param string $rawName
* @return string
*/
public
function
addTablePrefix
(
$rawName
)
{
$prefix
=
QA_MYSQL_TABLE_PREFIX
;
if
(
defined
(
'QA_MYSQL_USERS_PREFIX'
))
{
switch
(
strtolower
(
$rawName
))
{
case
'users'
:
case
'userlogins'
:
case
'userprofile'
:
case
'userfields'
:
case
'messages'
:
case
'cookies'
:
case
'blobs'
:
case
'cache'
:
case
'userlogins_ibfk_1'
:
// also special cases for constraint names
case
'userprofile_ibfk_1'
:
$prefix
=
QA_MYSQL_USERS_PREFIX
;
break
;
}
}
return
$prefix
.
$rawName
;
}
/**
* Return the value of the auto-increment column for the last inserted row.
* @return string
*/
...
...
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