Actions

API16

JTableUser/bind

From Joomla! Documentation

< API16:JTableUser
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Method to bind the user, user groups, and any other necessary data.

[Edit Descripton]

Description:JTableUser/bind

Syntax

bind($array, $ignore= '')
Parameter Name Default Value Description
$array $array The data to bind.
$ignore $ignore An array or space separated list of fields to ignore.

Returns

boolean True on success, false on failure.

Defined in

libraries/joomla/database/table/user.php

Importing

jimport( 'joomla.database.table.user' );

Source Body

function bind($array, $ignore = '')
{
        if (key_exists('params', $array) && is_array($array['params'])) {
                $registry = new JRegistry();
                $registry->loadArray($array['params']);
                $array['params'] = (string)$registry;
        }
 
        // Attempt to bind the data.
        $return = parent::bind($array, $ignore);
 
        // Load the real group data based on the bound ids.
        if ($return && !empty($this->groups))
        {
                // Set the group ids.
                JArrayHelper::toInteger($this->groups);
                $this->groups = array_fill_keys(array_values($this->groups), null);
 
                // Get the titles for the user groups.
                $this->_db->setQuery(
                        'SELECT `id`, `title`' .
                        ' FROM `#__usergroups`' .
                        ' WHERE `id` = '.implode(' OR `id` = ', array_keys($this->groups))
                );
                $results = $this->_db->loadObjectList();
 
                // Check for a database error.
                if ($this->_db->getErrorNum()) {
                        $this->setError($this->_db->getErrorMsg());
                        return false;
                }
 
                // Set the titles for the user groups.
                for ($i = 0, $n = count($results); $i < $n; $i++) {
                        $this->groups[$results[$i]->id] = $results[$i]->title;
                }
        }
 
        return $return;
}

[Edit See Also] SeeAlso:JTableUser/bind

Examples

<CodeExamplesForm />