Marc
Well-known member
OK, thanks to Ragtek/Kier/James I have now got to the point where I have got the mapping working with no problems, and after saving the personal details my datawriter updates my table with coordinates ONLY if the location field as changed, and a valid Geocoded location has been entered.
So now my question. My datawriter only currently works when a new item is added to the database, and if the user already exists in my table throws an error due to a duplicated primary key. This is expected as I only want people to enter onto the map once. Now Im guessing that the datawriter can check if it exists and update the data instead, however Im not sure how to go about this.
Any pointers?
So now my question. My datawriter only currently works when a new item is added to the database, and if the user already exists in my table throws an error due to a duplicated primary key. This is expected as I only want people to enter onto the map once. Now Im guessing that the datawriter can check if it exists and update the data instead, however Im not sure how to go about this.
Any pointers?
PHP:
<?php
class dcXenMapMe_DataWriter_NewMarker extends XenForo_DataWriter
{
/**
* Gets the fields that are defined for the table. See parent for explanation.
*
* @return array
*/
protected function _getFields()
{
return array(
'dc_MapMe_Markers' => array(
'member_id' => array('type' => self::TYPE_UINT, 'required' => true),
'lon' => array('type' => self::TYPE_FLOAT, 'required' => true),
'lat' => array('type' => self::TYPE_FLOAT, 'required' => true)
)
);
}
protected function _getExistingData($data)
{
//NOT SURE IF I NEED ANYTHING HERE
}
protected function _getUpdateCondition($tableName)
{
//GUESSING I NEED SOMETHING HERE, SO IT UPDATES RATHER THAN INSERTS IF MEMBER_ID PRESENT
}
}