XOOPS
2.6.0
Main Page
Related Pages
Classes
Files
Examples
File List
File Members
TableLoad.php
Go to the documentation of this file.
1
<?php
2
/*
3
You may not change or alter any portion of this comment or credits
4
of supporting developers from this source code or any supporting source code
5
which is considered copyrighted (c) material of the original comment or credit authors.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
namespace
Xmf\Database
;
13
14
use
Xoops\Core\Yaml
;
15
29
class
TableLoad
30
{
31
42
public
static
function
loadTableFromArray
($table, $data)
43
{
44
$db =
\Xoops::getInstance
()->db();
45
$count
= 0;
46
$db->beginTransaction();
47
foreach
($data as $row) {
48
$count
+= $db->insertPrefix($table, $row);
49
}
50
$db->commit();
51
return
$count
;
52
}
53
62
public
static
function
loadTableFromYamlFile
($table, $yamlFile)
63
{
64
$count
= 0;
65
66
$data =
Yaml::read
($yamlFile);
67
if
($data) {
68
$count
= self::loadTableFromArray($table, $data);
69
}
70
71
return
$count
;
72
}
73
81
public
static
function
truncateTable
($table)
82
{
83
$db =
\Xoops::getInstance
()->db();
84
$platform
= $db->getDatabasePlatform();
85
$sql
=
$platform
->getTruncateTableSQL($db->prefix($table));
86
87
return
$db->exec(
$sql
);
88
}
89
98
public
static
function
rowCount
($table,
$criteria
= null)
99
{
100
$db =
\Xoops::getInstance
()->db();
101
$qb = $db->createXoopsQueryBuilder();
102
$qb ->select(
'COUNT(*)'
)
103
->fromPrefix($table,
''
);
104
if
(isset(
$criteria
) && is_subclass_of(
$criteria
,
'Xoops\Core\Kernel\CriteriaElement'
)) {
105
$qb =
$criteria
->renderQb($qb,
''
);
106
}
107
$result
= $qb->execute();
108
$count
=
$result
->fetchColumn();
109
return
$count
;
110
}
111
}
$count
$count
Definition:
page_tablesfill.php:45
Xmf\Database\TableLoad\rowCount
static rowCount($table, $criteria=null)
Definition:
TableLoad.php:98
Xoops\getInstance
static getInstance()
Definition:
Xoops.php:160
$result
$result
Definition:
pda.php:33
Yaml
Xmf\Database
Definition:
TableLoad.php:12
$platform
if($_SERVER['REQUEST_METHOD']== 'POST') $platform
Definition:
page_dbsettings.php:43
Xmf\Database\TableLoad
Definition:
TableLoad.php:29
Xmf\Database\TableLoad\loadTableFromArray
static loadTableFromArray($table, $data)
Definition:
TableLoad.php:42
$sql
$sql
Definition:
pda.php:32
Xoops\Core\Yaml\read
static read($yamlFile)
Definition:
Yaml.php:87
$criteria
$criteria
Definition:
page_configsite.php:52
Xmf\Database\TableLoad\truncateTable
static truncateTable($table)
Definition:
TableLoad.php:81
Xmf\Database\TableLoad\loadTableFromYamlFile
static loadTableFromYamlFile($table, $yamlFile)
Definition:
TableLoad.php:62
usr64
htdocs
xoops_lib
Xmf
Database
TableLoad.php
Generated on Fri May 22 2015 03:07:04 for XOOPS by
1.8.9.1