Back to Table class

Method appendPrimaryKeys

public void
appendPrimaryKeys
(mixed $query, mixed $pk = null)
Method to append the primary keys for this table to a query.
Parameters
  • \Joomla\Database\DatabaseQuery $query A query object to append.
  • mixed $pk Optional primary key parameter.
Returns
  • void
Since
  • 3.1.4
Class: Table
Project: Joomla

Method appendPrimaryKeys - Source code

/**
 * Method to append the primary keys for this table to a query.
 *
 * @param   DatabaseQuery  $query  A query object to append.
 * @param   mixed          $pk     Optional primary key parameter.
 *
 * @return  void
 *
 * @since   3.1.4
 */
public function appendPrimaryKeys($query, $pk = null)
{
    if (\is_null($pk)) {
        foreach ($this->_tbl_keys as $k) {
            $query->where($this->_db->quoteName($k) . ' = ' . $this->_db->quote($this->{$k}));
        }
    } else {
        if (\is_string($pk)) {
            $pk = array($this->_tbl_key => $pk);
        }
        $pk = (object) $pk;
        foreach ($this->_tbl_keys as $k) {
            $query->where($this->_db->quoteName($k) . ' = ' . $this->_db->quote($pk->{$k}));
        }
    }
}