$hfieldDefn = OGR_Fld_Create("Total earning", OFTReal);
OGR_FD_AddFieldDefn($hFeatureDefn, $hfieldDefn);
$hfieldDefn = OGR_Fld_Create("Street", OFTString);
OGR_FD_AddFieldDefn($hFeatureDefn, $hfieldDefn);
$hfieldDefn = OGR_Fld_Create("Age", OFTIntegerList);
OGR_FD_AddFieldDefn($hFeatureDefn, $hfieldDefn);
$hfieldDefn = OGR_Fld_Create("Individual earning", OFTRealList);
OGR_FD_AddFieldDefn($hFeatureDefn, $hfieldDefn);
$hfieldDefn = OGR_Fld_Create("First-Last Names", OFTStringList);
OGR_FD_AddFieldDefn($hFeatureDefn, $hfieldDefn);
/*Creating a new feature with the previous definition */
$hFeature = OGR_F_Create($hFeatureDefn);
/*Testing if the field is created. */
$numFields = OGR_F_GetFieldCount($hFeature);
printf("nombre de field = %d\n", $numFields);
$fieldIndex = OGR_F_GetFieldIndex($hFeature, "First-Last Names");
printf("field index = %d\n", $fieldIndex);
$fieldIndex = 0;
$eErr = OGRSetGetInteger($hFeature, $fieldIndex, $intValue);
$fieldIndex = 1;
$eErr = OGRSetGetDouble($hFeature, $fieldIndex, $doubleValue);
$fieldIndex = 2;
$eErr = OGRSetGetString($hFeature, $fieldIndex, $stringValue);
$fieldIndex = 3;
$eErr = OGRSetGetIntegerList($hFeature, $fieldIndex, $numInteger, $intListValue);
$fieldIndex = 4;
$eErr = OGRSetGetDoubleList($hFeature, $fieldIndex, $numDouble, $doubleListValue);
$fieldIndex = 5;
$eErr = OGRSetGetStringList($hFeature, $fieldIndex, $stringListValue);
OGR_F_Destroy($hFeature);
if ($eErr != OGRERR_NONE) {
 function add_layer_to_db($dst_layer_name)
 {
     OGRRegisterAll();
     $success = false;
     // create layer record so that all
     // these geometries can be linked to
     // one layer
     $layer_id = $this->create_layer_record($this->submission_id, $dst_layer_name);
     if ($layer_id != -1) {
         // loop through source layer, copy
         // each feature to the destination
         // layer
         OGR_L_ResetReading($this->ogr_src_layer);
         $dst_feature_defn = OGR_L_GetLayerDefn($this->ogr_dst_layer);
         while (($src_feature = OGR_L_GetNextFeature($this->ogr_src_layer)) != NULL) {
             // create a blank feature
             // based on the destination
             // feature definition
             $dst_feature = OGR_F_Create($dst_feature_defn);
             // now copy the feature object
             // from the source to the destination.
             // the last value, bForgiving must be set to
             // true because our source and destination
             // schemas dont match. if bForgiving is
             // false, OGR_F_SetFrom quits when it
             // finds a feature that doesnt match both
             // schemas.
             if (OGR_F_SetFrom($dst_feature, $src_feature, TRUE) != OGRERR_NONE) {
                 echo "could not set destination feature from source feature";
                 return false;
             }
             // set the layer_id (fk) of the feature
             // to the layer id created earlier in
             // this method
             $layerid_f_index = OGR_F_GetFieldIndex($dst_feature, "layer_id");
             OGR_F_SetFieldInteger($dst_feature, $layerid_f_index, $layer_id);
             // ------------------------------------------
             // begin locked section
             // ------------------------------------------
             // since the feature creation does not automatically
             // query the ID of the feature from the db, we
             // need to query it ourselves. to prevent any
             // interleaving of threads that are executing this
             // method, we add a semaphore lock before the
             // feature is created and release the lock once
             // the ID of the feature has been queried.
             // see php docs for sem_get(), sem_acquire()
             // and sem_release
             // note the second arg to sem_get must be "1"
             // so that only one process at a time can
             // acquire the semaphore
             $sem_num = sem_get(5001, 1);
             // block until semaphore is available
             sem_acquire($sem_num);
             // destination feature successfully set.
             // now "create" the dst feature within the
             // destination layer.
             if (OGR_L_CreateFeature($this->ogr_dst_layer, $dst_feature) != OGRERR_NONE) {
                 echo "could not create feature in destination layer ";
                 return false;
             }
             // now that the feature has been
             // created within the db, we need to
             // get its ID so that we can use it
             // as a FK when inserting the attributes
             // of the feature.
             $pk_col_name = "";
             /* unused. see comments in get_max_id() */
             $feature_id = $this->get_max_id($this->dst_layer_name, $pk_col_name);
             // release the semaphore
             sem_release($sem_num);
             // ------------------------------------------
             // end locked section
             // ------------------------------------------
             if ($feature_id == -1) {
                 echo "could not obtain new ID for feature ";
                 return false;
             }
             // if the value of the ID was successfully
             // obtained, attempt to create
             // records for the attributes in the attribute
             // table
             if (!$this->add_attributes_to_db($src_feature, $feature_id, $this->pk_col_name)) {
                 echo "could not insert attributes for feature ID " . $feature_id;
                 return false;
             }
             OGR_F_Destroy($src_feature);
             OGR_F_Destroy($dst_feature);
         }
     }
     return true;
 }
 $dst_feature = OGR_F_Create($dst_feature_defn);
 // now copy the feature from the source
 // layer to the dest. layer
 // the last value, bForgiving must be set to
 // true because our source and destination
 // schemas dont match
 if (OGR_F_SetFrom($dst_feature, $feature, TRUE) != OGRERR_NONE) {
     echo "could not set destination feature from source feature";
     exit;
 }
 // otherwise the feature was set
 // from the source feature.
 // set the layer_id (fk) of the feature
 // to the layer id created at the time
 // of submission.
 $layerid_f_index = OGR_F_GetFieldIndex($dst_feature, "layer_id");
 OGR_F_SetFieldInteger($dst_feature, $layerid_f_index, -1);
 // now "create" this feature within the
 // destination layer. the method should
 // be called "add" rather than "create"
 if (OGR_L_CreateFeature($dst_layer, $dst_feature) != OGRERR_NONE) {
     echo "could not create feature in destination layer ";
     exit;
 }
 //$geometry = OGR_F_GetGeometryRef($feature);
 //$txt_buffer = "";
 //$res = OGR_G_ExportToWkt($geometry, $txt_buffer);
 //$res = OGR_G_GetGeometryName($geometry);
 //OGR_G_ExportToWkb($geometry, $txt_buffer);
 //OGR_G_ExportToWkb
 //$len = OGR_G_WkbSize($geometry);