Back to UCMBase class

Method store

protected bool
store
(mixed $data, \Joomla\CMS\Table\TableInterface $table = null, mixed $primaryKey = null)
Store data to the appropriate table
Parameters
  • array $data Data to be stored
  • \Joomla\CMS\Table\TableInterface $table Table Object
  • string $primaryKey The primary key name
Returns
  • bool True on success
Since
  • 3.1
-
  • \Exception
Class: UCMBase
Project: Joomla

Method store - Source code

/**
 * Store data to the appropriate table
 *
 * @param   array           $data        Data to be stored
 * @param   TableInterface  $table       Table Object
 * @param   string          $primaryKey  The primary key name
 *
 * @return  boolean  True on success
 *
 * @since   3.1
 * @throws  \Exception
 */
protected function store($data, TableInterface $table = null, $primaryKey = null)
{
    if (!$table) {
        $table = Table::getInstance('Ucm');
    }
    $ucmId = $data['ucm_id'] ?? null;
    $primaryKey = $primaryKey ?: $ucmId;
    if (isset($primaryKey)) {
        $table->load($primaryKey);
    }
    try {
        $table->bind($data);
    } catch (\RuntimeException $e) {
        throw new \Exception($e->getMessage(), 500, $e);
    }
    try {
        $table->store();
    } catch (\RuntimeException $e) {
        throw new \Exception($e->getMessage(), 500, $e);
    }
    return true;
}