Update exsisting record in list error

ivan

New Member
is theare a error

trying to compare and find not exising key value ?


foreach (get_object_vars($object) as $k => $v)
{
if (is_array($v) or is_object($v) or $k[0] == '_')
{
// Internal or NA field
continue;
}
// dump($k,'$k'); dump($keyName,'$keyName');
if ($k == $keyName)
{
// PK not to be updated
$where = $keyName . '=' . $db->quote($v);
continue;
}
 
[What are you trying to do where?[/quote]

trying to update existing records in a list.
using the webservice plugin for list
when i try to update already loaded data its return
'' at line 1 SQL=UPDATE `regions` SET `Country`='4',`Name`='<All>',`externalkey`='6' WHERE
it seems the passed values do not have match to populate the where clause.
therae must be WHERE id = 53

the start point of the problem is:
$listModel->storeRow($row, $pk);
 
Which code are you referring to?
What are your webservice plugin settings? (screenshots)
 
You can't map your inbound data to the PK (primary key) on your list.

To map (relate) local to remote data, you have to use the "FK", and map whatever is considered the Primary Key for the remote data, to the element you designated as the FK field on your list.

In other words, the one-to-one relationship between local and remote is local.fk => remote.pk, NOT remote.fk => local.pk.

Here's my test list for a webservice, which fetches some LastFM Audio Scrobbler data, and maps the remote 'id' (PK) on to my lastfm_id FK. As you can see, when I run it first time, it fills in the lastfm_id on my list, then when I run it again, it doesn't add new rows, as it matches the Last FM's 'id' against my lastfm_id FK, and updates the existing rows instead of adding new one.

http://screencast.com/t/D9Tuxn4Bb

-- hugh
 
yes i did the same but seem in the $row dont add the id from the local table
i added the data to the table but at the time to update i receave the error

'' at line 1 SQL=UPDATE `regions` SET `Country`='4',`Name`='<All>',`externalkey`='6' WHERE
in the row contains all the data from the XML but not the local id
the problem is when trying to update and store

$listModel->storeRow($row, $pk);
 
heare is the fix

if (array_key_exists($row[$fk], $ids) && $row[$fk] != '')
{
$idin='id';
$pk = $ids[$row[$fk]]->id;
array_push($row,$idin);
$row['id'] = $ids[$row[$fk]]->id;

}

but you cant change the values of the remoteID stored at localyID becouse the ne row will be added
 
yes it is defined but at the time of the update its pass the $pk = $ids[$row[$fk]]->id; but in the array do not have the id column and at the time to search for the match to determine the where clause it not find it.
and i added $idin='id'; array_push($row,$idin); . $ids[] contains the values of the Primary key and the FK .
when the model get the values for the update expect the pk to be in the row array .
 
it is ok naw with the fix you added.
when you create the list it contain a date like a default element , hoe to polpulate it when updating and know the update date


it is posible to make some changens on the button starting the sync and modify it to dropdown ?
not to add a button for the diferent "filter" parameters but using dropdown from the table loded firs. for example after to load a Counties in a List add a List for Regions with FK the id from the Countries and populate it passing the filters using the Dropdown.
an option the button to be a selectable with diferent parameters from the previos table ?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top