Hi,

There is a function special made for this 'fromArray'.  I didn't test
the following code, but it should work, I think.

function arrayToObject ($values)
{
  $object = new Object ();
  $object->fromArray ($values, BasePeer::TYPE_FIELDNAME);
  $object->save();

  return $object;
}

$your_objects = array_map ('arrayToObject', $your_values_array);


James


On Sep 11, 9:57 am, "Haidarah Husain" <[EMAIL PROTECTED]>
wrote:
> Is there any example how to insert data from an array?
>
> Say I have an array:
> Array
> (
>     [0] => Array
>         (
>             [kode] => FMIPA
>             [name] => Fakultas Matematika dan Ilmu Pengetahuan Alam
>         )
>
>     [1] => Array
>         (
>             [kode] => FSRD
>             [name] => Fakultas Teknologi Industri
>         )
> ...
> ...
> ...
>     [1000] => Array
>         (
>             [kode] => FSRD
>             [name] => Fakultas Seni Rupa dan Desain
>         )
> )
>
> And my schema:
>   fakultas:
>     _attributes: { phpName: Fakultas }
>     id: ~
>     kode: { type: VARCHAR, size: '50', required: true }
>     name: { type: VARCHAR, size: '50', required: false }
>
> --
> -husain-
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to