Ticket #108 (new enhancement)

Opened 8 months ago

Solar_Sql_Model_Record: getRelatedModel() and countPagesRelated()

Reported by: moraes Assigned to: pmjones
Priority: trivial Component: code
Keywords: Solar_Sql_Model_Record Cc:

Description

Antti mentioned this idea a while ago on IRC, and I agree it would be useful: Solar_Sql_Model_Record::getRelatedModel() would be a shortcut to get a related model from a record:

    /**
     *
     * Returns the model from a relationship.
     *
     * @param string $name The relationship name.
     *
     */
    public function getRelatedModel($name)
    {
        return $this->_model->getRelated($name)->getModel();
    }

A bit related to the above would be Solar_Sql_Model_Record::countPagesRelated(), a shortcut to count pages for related records:

    /**
     *
     * Counts the number of records in a related model for this record.
     *
     * @param string $name The relationship name.
     *
     * @param array $params Parameters for the related SELECT; honors keys for
     * 'where', 'having', 'group', and 'paging'.
     *
     * @return array An array with keys 'count' (the count of records) and
     * 'pages' (the number of pages of records).
     *
     */
    public function countPagesRelated($name, $params = null)
    {
        return $this->_model->countPagesRelated($this, $name, $params);
    }

Attachments


Add/Change #108 (Solar_Sql_Model_Record: getRelatedModel() and countPagesRelated())