[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Table/ -> TableInterface.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2014 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\Database\DatabaseDriver;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('JPATH_PLATFORM') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * Table class interface.
  20   *
  21   * @since  3.2
  22   */
  23  interface TableInterface
  24  {
  25      /**
  26       * Method to bind an associative array or object to the TableInterface instance.
  27       *
  28       * This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding.
  29       *
  30       * @param   mixed  $src     An associative array or object to bind to the TableInterface instance.
  31       * @param   mixed  $ignore  An optional array or space separated list of properties to ignore while binding.
  32       *
  33       * @return  boolean  True on success.
  34       *
  35       * @since   3.2
  36       * @throws  \UnexpectedValueException
  37       */
  38      public function bind($src, $ignore = array());
  39  
  40      /**
  41       * Method to perform sanity checks on the TableInterface instance properties to ensure they are safe to store in the database.
  42       *
  43       * Implementations of this interface should use this method to make sure the data they are storing in the database is safe and
  44       * as expected before storage.
  45       *
  46       * @return  boolean  True if the instance is sane and able to be stored in the database.
  47       *
  48       * @since   3.2
  49       */
  50      public function check();
  51  
  52      /**
  53       * Method to delete a record.
  54       *
  55       * @param   mixed  $pk  An optional primary key value to delete.  If not set the instance property value is used.
  56       *
  57       * @return  boolean  True on success.
  58       *
  59       * @since   3.2
  60       * @throws  \UnexpectedValueException
  61       */
  62      public function delete($pk = null);
  63  
  64      /**
  65       * Method to get the DatabaseDriver object.
  66       *
  67       * @return  DatabaseDriver  The internal database driver object.
  68       *
  69       * @since   3.2
  70       */
  71      public function getDbo();
  72  
  73      /**
  74       * Method to get the primary key field name for the table.
  75       *
  76       * @return  string  The name of the primary key for the table.
  77       *
  78       * @since   3.2
  79       */
  80      public function getKeyName();
  81  
  82      /**
  83       * Method to load a row from the database by primary key and bind the fields to the TableInterface instance properties.
  84       *
  85       * @param   mixed    $keys   An optional primary key value to load the row by, or an array of fields to match.  If not
  86       *                           set the instance property value is used.
  87       * @param   boolean  $reset  True to reset the default values before loading the new row.
  88       *
  89       * @return  boolean  True if successful. False if row not found.
  90       *
  91       * @since   3.2
  92       * @throws  \RuntimeException
  93       * @throws  \UnexpectedValueException
  94       */
  95      public function load($keys = null, $reset = true);
  96  
  97      /**
  98       * Method to reset class properties to the defaults set in the class definition.
  99       *
 100       * It will ignore the primary key as well as any private class properties.
 101       *
 102       * @return  void
 103       *
 104       * @since   3.2
 105       */
 106      public function reset();
 107  
 108      /**
 109       * Method to store a row in the database from the TableInterface instance properties.
 110       *
 111       * If a primary key value is set the row with that primary key value will be updated with the instance property values.
 112       * If no primary key value is set a new row will be inserted into the database with the properties from the TableInterface instance.
 113       *
 114       * @param   boolean  $updateNulls  True to update fields even if they are null.
 115       *
 116       * @return  boolean  True on success.
 117       *
 118       * @since   3.2
 119       */
 120      public function store($updateNulls = false);
 121  
 122      /**
 123       * Returns the identity (primary key) value of this record
 124       *
 125       * @return  mixed
 126       *
 127       * @since  4.0.0
 128       */
 129      public function getId();
 130  
 131      /**
 132       * Check if the record has a property (applying a column alias if it exists)
 133       *
 134       * @param   string  $key  key to be checked
 135       *
 136       * @return  boolean
 137       *
 138       * @since   4.0.0
 139       */
 140      public function hasField($key);
 141  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer