[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Table; 11 12 use Joomla\CMS\Language\Text; 13 use Joomla\Database\DatabaseDriver; 14 use Joomla\Database\ParameterType; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('JPATH_PLATFORM') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Viewlevels table class. 22 * 23 * @since 1.7.0 24 */ 25 class ViewLevel extends Table 26 { 27 /** 28 * Constructor 29 * 30 * @param DatabaseDriver $db Database driver object. 31 * 32 * @since 1.7.0 33 */ 34 public function __construct(DatabaseDriver $db) 35 { 36 parent::__construct('#__viewlevels', 'id', $db); 37 } 38 39 /** 40 * Method to bind the data. 41 * 42 * @param array $array The data to bind. 43 * @param mixed $ignore An array or space separated list of fields to ignore. 44 * 45 * @return boolean True on success, false on failure. 46 * 47 * @since 1.7.0 48 */ 49 public function bind($array, $ignore = '') 50 { 51 // Bind the rules as appropriate. 52 if (isset($array['rules'])) { 53 if (\is_array($array['rules'])) { 54 $array['rules'] = json_encode($array['rules']); 55 } 56 } 57 58 return parent::bind($array, $ignore); 59 } 60 61 /** 62 * Method to check the current record to save 63 * 64 * @return boolean True on success 65 * 66 * @since 1.7.0 67 */ 68 public function check() 69 { 70 try { 71 parent::check(); 72 } catch (\Exception $e) { 73 $this->setError($e->getMessage()); 74 75 return false; 76 } 77 78 // Validate the title. 79 if ((trim($this->title)) == '') { 80 $this->setError(Text::_('JLIB_DATABASE_ERROR_VIEWLEVEL')); 81 82 return false; 83 } 84 85 $id = (int) $this->id; 86 87 // Check for a duplicate title. 88 $db = $this->_db; 89 $query = $db->getQuery(true) 90 ->select('COUNT(' . $db->quoteName('title') . ')') 91 ->from($db->quoteName('#__viewlevels')) 92 ->where($db->quoteName('title') . ' = :title') 93 ->where($db->quoteName('id') . ' != :id') 94 ->bind(':title', $this->title) 95 ->bind(':id', $id, ParameterType::INTEGER); 96 $db->setQuery($query); 97 98 if ($db->loadResult() > 0) { 99 $this->setError(Text::sprintf('JLIB_DATABASE_ERROR_USERLEVEL_NAME_EXISTS', $this->title)); 100 101 return false; 102 } 103 104 return true; 105 } 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |