forked from joomla/joomla-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
109 lines (101 loc) · 2.32 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die();
jimport('joomla.database.table');
/**
* Update table
* Stores updates temporarily
*
* @package Joomla.Platform
* @subpackage Table
* @since 11.1
*/
class JTableUpdate extends JTable
{
/**
* Contructor
*
* @param database &$db A database connector object
*
* @return JTableUpdate
*
* @since 11.1
*/
function __construct(&$db)
{
parent::__construct('#__updates', 'update_id', $db);
}
/**
* Overloaded check function
*
* @return boolean True if the object is ok
*
* @see JTable:bind
* @since 11.1
*/
public function check()
{
// check for valid name
if (trim($this->name) == '' || trim($this->element) == '')
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION'));
return false;
}
return true;
}
/**
* Overloaded bind function
*
* @param array $array Named array
* @param mixed $ignore An optional array or space separated list of properties
* to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error
*
* @see JTable:bind
* @since 11.1
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new JRegistry;
$registry->loadArray($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['control']) && is_array($array['control']))
{
$registry = new JRegistry;
$registry->loadArray($array['control']);
$array['control'] = (string) $registry;
}
return parent::bind($array, $ignore);
}
/**
* Method to create and execute a SELECT WHERE query.
*
* @param array $options Array of options
*
* @return JDatabase object
*
* @since 11.1
*/
function find($options = Array())
{
$dbo = JFactory::getDBO();
$where = Array();
foreach ($options as $col => $val)
{
$where[] = $col . ' = ' . $dbo->Quote($val);
}
$query = 'SELECT update_id FROM #__updates WHERE ' . implode(' AND ', $where);
$dbo->setQuery($query);
return $dbo->loadResult();
}
}