Replacing deprecated Database::count_rows() function.

1.9.x
Julio Montoya 11 years ago
parent b70c43e7d6
commit 0aa1d10473
  1. 1
      main/inc/lib/database.lib.php
  2. 25
      main/inc/lib/plugin.class.php

@ -342,6 +342,7 @@ class Database {
* Counts the number of rows in a table
* @param string $table The table of which the rows should be counted
* @return int The number of rows in the given table.
* @deprecated
*/
public static function count_rows($table) {
$obj = self::fetch_object(self::query("SELECT COUNT(*) AS n FROM $table")); //

@ -521,16 +521,20 @@ class Plugin
/**
* Delete a tab to chamilo's platform
* @param string $key
*
* @return int
*/
public function deleteTab($key)
{
$sql = "SELECT *
FROM settings_current
WHERE variable = 'show_tabs'
AND subkey <> '$key'";
$resp = $result = Database::query($sql);
$customTabsNum = Database::count_rows($result);
$sql = "SELECT * FROM settings_current
WHERE
variable = 'show_tabs' AND
subkey <> '$key'";
$result = Database::query($sql);
$tabs = Database::store_result($result);
$customTabsNum = count($tabs);
//$customTabsNum = Database::count_rows($result);
$resp = false;
if (!empty($key)) {
$whereCondition = array(
'variable = ? AND subkey = ?' => array('show_tabs', $key)
@ -541,7 +545,7 @@ class Plugin
//re enumerate them
if ($customTabsNum > 0) {
$i = 1;
while ($row = Database::fetch_assoc($result)) {
foreach ($tabs as $row) {
$attributes = array(
'subkey' => 'custom_tab_' . $i
);
@ -557,7 +561,8 @@ class Plugin
/**
* Update the tabs attributes
* @param string $key
* @param array $attributes
* @param array $attributes
*
* @return boolean
*/
public function updateTab($key, $attributes)
@ -566,12 +571,14 @@ class Plugin
'variable = ? AND subkey = ?' => array('show_tabs', $key)
);
$resp = Database::update('settings_current', $attributes, $whereCondition);
return $resp;
}
/**
* Add additional plugin Settings
* @param array $settings
*
* @return bool
*/
public function addExtraSettings($settings)

Loading…
Cancel
Save