Update.php
2.4 KB
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
110
111
112
113
114
115
116
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Table;
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Update table
* Stores updates temporarily
*
* @since 1.7.0
*/
class Update extends Table
{
/**
* Constructor
*
* @param \JDatabaseDriver $db Database driver object.
*
* @since 1.7.0
*/
public function __construct($db)
{
parent::__construct('#__updates', 'update_id', $db);
}
/**
* Overloaded check function
*
* @return boolean True if the object is ok
*
* @see Table::check()
* @since 1.7.0
*/
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;
}
if (!$this->update_id && !$this->data)
{
$this->data = '';
}
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 Table::bind()
* @since 1.7.0
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new Registry($array['params']);
$array['params'] = (string) $registry;
}
if (isset($array['control']) && is_array($array['control']))
{
$registry = new Registry($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 string Results of query
*
* @since 1.7.0
*/
public function find($options = array())
{
$where = array();
foreach ($options as $col => $val)
{
$where[] = $col . ' = ' . $this->_db->quote($val);
}
$query = $this->_db->getQuery(true)
->select($this->_db->quoteName($this->_tbl_key))
->from($this->_db->quoteName($this->_tbl))
->where(implode(' AND ', $where));
$this->_db->setQuery($query);
return $this->_db->loadResult();
}
}