Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion htdocs/class/libraries/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Libraries for XOOPS 2.5.8",
"require": {
"php": ">=5.3.7",
"xoops/xmf": "1.0.0-RC",
"xoops/xmf": "1.0.0-RC2",
"ircmaxell/password-compat": "^1.0.4"
}
}
14 changes: 7 additions & 7 deletions htdocs/class/libraries/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 36 additions & 36 deletions htdocs/class/libraries/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,42 +101,6 @@
"php"
]
},
{
"name": "xoops/xmf",
"version": "v1.0.0-RC",
"version_normalized": "1.0.0.0-RC",
"source": {
"type": "git",
"url": "https://github.com/XOOPS/xmf.git",
"reference": "6385801c3740a9f14954e50c7bb427717728646e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/XOOPS/xmf/zipball/6385801c3740a9f14954e50c7bb427717728646e",
"reference": "6385801c3740a9f14954e50c7bb427717728646e",
"shasum": ""
},
"require": {
"firebase/php-jwt": "^3.0.0",
"ircmaxell/random-lib": "^1.1.0",
"php": ">=5.3.7",
"raveren/kint": "1.0.10",
"symfony/yaml": "2.4.*"
},
"time": "2016-02-29 22:26:31",
"type": "project",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Xmf\\": "src/Xmf"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
],
"description": "XMF - XOOPS Module Framework"
},
{
"name": "ircmaxell/password-compat",
"version": "v1.0.4",
Expand Down Expand Up @@ -324,5 +288,41 @@
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt"
},
{
"name": "xoops/xmf",
"version": "v1.0.0-RC2",
"version_normalized": "1.0.0.0-RC2",
"source": {
"type": "git",
"url": "https://github.com/XOOPS/xmf.git",
"reference": "197a1b51b9f39f97a7e1c316756d0af329696ee1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/XOOPS/xmf/zipball/197a1b51b9f39f97a7e1c316756d0af329696ee1",
"reference": "197a1b51b9f39f97a7e1c316756d0af329696ee1",
"shasum": ""
},
"require": {
"firebase/php-jwt": "^3.0.0",
"ircmaxell/random-lib": "^1.1.0",
"php": ">=5.3.7",
"raveren/kint": "1.0.10",
"symfony/yaml": "2.4.*"
},
"time": "2016-03-07 22:41:14",
"type": "project",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Xmf\\": "src/Xmf"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
],
"description": "XMF - XOOPS Module Framework"
}
]
4 changes: 4 additions & 0 deletions htdocs/class/libraries/vendor/xoops/xmf/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
xmf ChangeLog
=============

04-Mar-2016 V1.0.0 RC1
-------------------------
- Preparation for release in XOOPS 2.5.8

09-Feb-2016
-----------
- Convert to library instead of module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ public static function truncateTable($table)
}

/**
* rowCount - get count of rows in a table
* countRows - get count of rows in a table
*
* @param string $table name of table to count
* @param \CriteriaElement $criteria optional criteria
*
* @return int number of rows
*/
public static function rowCount($table, $criteria = null)
public static function countRows($table, $criteria = null)
{
/** @var \XoopsDatabase */
$db = \XoopsDatabaseFactory::getDatabaseConnection();
Expand All @@ -137,6 +137,65 @@ public static function rowCount($table, $criteria = null)
$row = $db->fetchArray($result);
$count = $row['count'];
$db->freeRecordSet($result);
return $count;
return (int)$count;
}

/**
* extractRows - get rows, all or a subset, from a table as an array
*
* @param string $table name of table to count
* @param \CriteriaElement $criteria optional criteria
* @param string[] $skipColumns do not include columns in this list
*
* @return array of table rows
*/
public static function extractRows($table, $criteria = null, $skipColumns = array())
{
/** @var \XoopsDatabase */
$db = \XoopsDatabaseFactory::getDatabaseConnection();

$prefixedTable = $db->prefix($table);
$sql = 'SELECT * FROM ' . $prefixedTable . ' ';
if (isset($criteria) && is_subclass_of($criteria, '\CriteriaElement')) {
$sql .= $criteria->renderWhere();
}
$rows = array();
$result = $db->query($sql);
if ($result) {
while ($row = $db->fetchArray($result)) {
$rows[] = $row;
}
}

$db->freeRecordSet($result);

if (!empty($skipColumns)) {
foreach ($rows as $index => $row) {
foreach ($skipColumns as $column) {
unset($rows[$index][$column]);
}
}
}

return $rows;
}

/**
* Save table data to a YAML file
*
* @param string $table name of table to load without prefix
* @param string $yamlFile name of file containing data dump in YAML format
* @param \CriteriaElement $criteria optional criteria
* @param string[] $skipColumns do not include columns in this list
*
* @return bool true on success, false on error
*/
public static function saveTableToYamlFile($table, $yamlFile, $criteria = null, $skipColumns = array())
{
$rows = static::extractRows($table, $criteria, $skipColumns);

$count = Yaml::save($rows, $yamlFile);

return (false !== $count);
}
}
Loading