Back to Table class

Method getPrimaryKey

public array
getPrimaryKey
(array $keys = array())
Get the primary key values for this table using passed in values as a default.
Parameters
  • array $keys Optional primary key values to use.
Returns
  • array An array of primary key names and values.
Since
  • 3.1.4
Class: Table
Project: Joomla

Method getPrimaryKey - Source code

/**
 * Get the primary key values for this table using passed in values as a default.
 *
 * @param   array  $keys  Optional primary key values to use.
 *
 * @return  array  An array of primary key names and values.
 *
 * @since   3.1.4
 */
public function getPrimaryKey(array $keys = array())
{
    foreach ($this->_tbl_keys as $key) {
        if (!isset($keys[$key])) {
            if (!empty($this->{$key})) {
                $keys[$key] = $this->{$key};
            }
        }
    }
    return $keys;
}