The insert() method of Zend_Db_Table returns the new primary key for the row.
The lastInsertId() method only exists of Zend_Db_Adapter classes, not the Table 
class.

On 27/02/2009 12:30 PM, Bob O wrote:
FYI..all 3 tables have auto_incrementing id fields that are PK's
and when all parts pertaining my problem

i am able to submit all of the other information correctly..



Bob O wrote:
Im having a heck of a time with this one..I have searched high and low,
and what has seemed to be a remedy isnt working for me..

any help would be great

I have 1 form and 3 tables that i submit to with 1 post.
These tables are joined by ids

here is my code

     public function createAdvertiser($values, $resellerId)
     {
       $now = time();
       $niceName = FonRoots_Utilities::toNiceString($values['advertName']);

       $personData = array('id' =>  null,
                           'username' =>  $values['username'],
                           'status' =>  $values['status'],
                           'role' =>  $values['role'],
                           'first_name' =>  $values['first_name'],
                           'last_name' =>  $values['last_name'],
                           'email' =>  $values['person_email'],
                           'title' =>  $values['job_title'],
                           'address' =>  $values['personAddress1'],
                           'address2' =>  $values['personAddress2'],
                           'city' =>  $values['personCity'],
                           'state' =>  $values['personState'],
                           'country' =>  $values['personCountry'],
                           'postal_code' =>  $values['personPostalCode'],
                           'area_code' =>  $values['personAreaCode'],
                           'phone' =>  $values['personPhone'],
                           'cell_area_code' =>
$values['personCellAreaCode'],
                           'cell_phone' =>  $values['personCellPhone'],
                           'date_created' =>  $now
                       );
       $dbAdvertiserPerson = new Person();
       $dbAdvertiserPerson->insert($personData);

<-- My code breaks here..The Person is added
       $contactPersonId = $dbAdvertiserPerson->lastInsertId();<-- I dont
think this is working?


       $locationData = array('id' =>  null,
                             'address' =>  $values['locationAddress1'],
                             'address2' =>  $values['locationAddress2'],
                             'city' =>  $values['locationCity'],
                             'state' =>  $values['locationState'],
                             'country' =>  $values['locationCountry'],
                             'postal_code' =>
$values['locationPostalCode'],
                             'area_code' =>  $values['locationAreaCode'],
                             'phone' =>  $values['locationPhone'],
                             'hours_of_operation' =>
$values['hoursOfOperation'],
                             'date_created' =>  $now
                       );

       $dbAdvertiserLocation = new Location();
       $dbAdvertiserLocation->insert($locationData);
       $locationId = $dbAdvertiserLocation->lastInsertId();

       $advertiserData = array('id' =>  null,
                               'advertiser' =>  $values['advertName'],
                               'nice_name' =>  $niceName,
                               'contact_person_id' =>  $contactPersonId,<--
Trying to return an id here
                               'location_id' =>  $locationId,<-- Trying to
return and here
                               'reseller_id' =>  $resellerId,
                               'date_created' =>  $now,
                               'short_description' =>
$values['shortDescription'],
                               'long_description' =>
$values['longDescription'],
                               'url' =>  $values['advertiserURL'],
                               'logo_url' =>  $values['logo'],
                               'date_created' =>  $now
                       );

                   $dbAdvertiser = new Advertiser();
                   $dbAdvertiser->insert($advertiserData);
     }




-----
Bob Hanson
Web Developer
SLC, UT

Reply via email to