Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
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
PSDI Army
yii2
Commits
51d6db7d
Commit
51d6db7d
authored
Mar 04, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2607 from mitalcoi/db_message_source
enchansment of db message source
parents
ef12934b
1a14ed21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
MessageController.php
framework/console/controllers/MessageController.php
+21
-6
No files found.
framework/console/controllers/MessageController.php
View file @
51d6db7d
...
...
@@ -134,11 +134,14 @@ class MessageController extends Controller
throw
new
Exception
(
'The "db" option must refer to a valid database application component.'
);
}
$sourceMessageTable
=
isset
(
$config
[
'sourceMessageTable'
])
?
$config
[
'sourceMessageTable'
]
:
'{{%source_message}}'
;
$messageTable
=
isset
(
$config
[
'messageTable'
])
?
$config
[
'messageTable'
]
:
'{{%message}}'
;
$this
->
saveMessagesToDb
(
$messages
,
$db
,
$sourceMessageTable
,
$config
[
'removeUnused'
]
$messageTable
,
$config
[
'removeUnused'
],
$config
[
'languages'
]
);
}
}
...
...
@@ -149,9 +152,11 @@ class MessageController extends Controller
* @param array $messages
* @param \yii\db\Connection $db
* @param string $sourceMessageTable
* @param string $messageTable
* @param boolean $removeUnused
* @param array $languages
*/
protected
function
saveMessagesToDb
(
$messages
,
$db
,
$sourceMessageTable
,
$
removeUnused
)
protected
function
saveMessagesToDb
(
$messages
,
$db
,
$sourceMessageTable
,
$
messageTable
,
$removeUnused
,
$languages
)
{
$q
=
new
\yii\db\Query
;
$current
=
[];
...
...
@@ -195,7 +200,12 @@ class MessageController extends Controller
$savedFlag
=
true
;
$db
->
createCommand
()
->
insert
(
$sourceMessageTable
,
[
'category'
=>
$category
,
'message'
=>
$m
])
->
execute
();
->
insert
(
$sourceMessageTable
,
[
'category'
=>
$category
,
'message'
=>
$m
])
->
execute
();
$lastId
=
$db
->
getLastInsertID
();
foreach
(
$languages
as
$language
)
{
$db
->
createCommand
()
->
insert
(
$messageTable
,
[
'id'
=>
$lastId
,
'language'
=>
$language
])
->
execute
();
}
}
}
...
...
@@ -207,15 +217,20 @@ class MessageController extends Controller
}
else
{
if
(
$removeUnused
)
{
$db
->
createCommand
()
->
delete
(
$sourceMessageTable
,
[
'in'
,
'id'
,
$obsolete
])
->
execute
();
echo
"deleted.
\n
"
;
->
delete
(
$sourceMessageTable
,
[
'in'
,
'id'
,
$obsolete
])
->
execute
();
echo
"deleted.
\n
"
;
}
else
{
$last_id
=
$db
->
getLastInsertID
();
$db
->
createCommand
()
->
update
(
->
update
(
$sourceMessageTable
,
[
'message'
=>
new
\yii\db\Expression
(
"CONCAT('@@',message,'@@')"
)],
[
'in'
,
'id'
,
$obsolete
]
)
->
execute
();
foreach
(
$languages
as
$language
)
{
$db
->
createCommand
()
->
insert
(
$messageTable
,
[
'id'
=>
$last_id
,
'language'
=>
$language
])
->
execute
();
}
echo
"updated.
\n
"
;
}
}
...
...
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