API15:JTable/bind
From Joomla! Documentation
Description
Binds a named array/hash to this object
Template:Description:JTable/bind
Syntax
bind($from, $ignore=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $from | mixed An associative array or object | |
| $ignore | array() | mixed An array or space separated list of fields not to bind |
Returns
boolean
Defined in
libraries/joomla/database/table.php
Importing
jimport( 'joomla.database.table' );
Source Body
function bind( $from, $ignore=array() )
{
$fromArray = is_array( $from );
$fromObject = is_object( $from );
if (!$fromArray && !$fromObject)
{
$this->setError( get_class( $this ).'::bind failed. Invalid from argument' );
return false;
}
if (!is_array( $ignore )) {
$ignore = explode( ' ', $ignore );
}
foreach ($this->getProperties() as $k => $v)
{
// internal attributes of an object are ignored
if (!in_array( $k, $ignore ))
{
if ($fromArray && isset( $from[$k] )) {
$this->$k = $from[$k];
} else if ($fromObject && isset( $from->$k )) {
$this->$k = $from->$k;
}
}
}
return true;
}
[Edit See Also] Template:SeeAlso:JTable/bind
Examples
<CodeExamplesForm />