set_to_array()

Creates an array indexed by variable names with values equal to the class values. Only included "database column" variables

If set_from_array_unsafe is used to add a variable "mother" to the class, it will not be included in the array.

function code:
<?php
    
function set_to_array()
    {
        
$array = array();
        foreach(
$this->_columns as $name=>$v)
        {
            if (
$v['type'] == 'date')
                @
$array[$name] = $this->{$name."_display"};
            else
                @
$array[$name] = $this->{$name};
        }
        if (@
is_array($this->_links))
            foreach(
$this->_links as $val)
                @
$array[$val] = $this->{$val};
        return 
$array;
    }
?>



Example:

example.php
<?php
include("lib.php");
load("person");

$p = new person($_GET['person_id']);
$array $p->set_to_array();
// if this is being used with set_$field_ie() functions, you could use: $_POST = $p->set_to_array();

?>
<br><br>
<form method=post action=example.php>
<table>
 <tr><td>Name:</td><td><input type=text value="<?=$array['name']?>" name=array[name]></td></tr>
 <tr><td>Address:</td><td><input type=text value="<?=$array['address']?>" name=array[address]></td></tr>
 <tr><td>City:</td><td><input type=text value="<?=$array['city']?>" name=array[city]></td></tr>
 <tr><td>State:</td><td><input type=text value="<?=$array['state']?>" name=array[state]></td></tr>
 <tr><td>Age:</td><td><input type=text value="<?=$array['age']?>" name=array[age]></td></tr>
 <tr><td>Birthdate:</td><td><input type=text value="<?=$array['birthdate']?>" name=array[birthdate]></td></tr>
</table>
<input type=submit value=Submit><br>
</form>