I think maybe I’ve found another function that doesn’t function correctly with the DataStore component (see also “form.reset() doesn’t work w/ datastore” posted today 9 Feb on the ‘Form’ board). Please tell me if I’m wrong.
My server-side connector uses is_select_mode to branch an if-then, as described in the documentation. Like this:
if ($conn->is_select_mode()){ //read-only configuration
LogMaster::log("is_select_mode TRUE");
$conn->render_SQL("SELECT restaurants.Name
, restaurants.Area
, DATE_FORMAT(max(visits.Visit),'%m/%d/%y') AS LastVisit
, restaurants.id
, restaurants.Address
, restaurants.CrossStreet
, restaurants.City
, restaurants.Phone
, restaurants.Cuisine
, restaurants.Breakfast
, restaurants.PriceRange
, restaurants.Brunch
, restaurants.Quality
, restaurants.Favorite
, restaurants.MustVisit
, restaurants.Tourists
, restaurants.Closes
, restaurants.Delivery
, restaurants.Notes
FROM
restaurants
LEFT OUTER JOIN visits
ON restaurants.id = visits.`id-restaurants`
GROUP BY
restaurants.Name
, restaurants.Area
, restaurants.Address
, restaurants.CrossStreet
, restaurants.City
, restaurants.Phone
, restaurants.Cuisine
, restaurants.Breakfast
, restaurants.Brunch
, restaurants.PriceRange
, restaurants.Quality
, restaurants.Favorite
, restaurants.MustVisit
, restaurants.Tourists
, restaurants.Closes
, restaurants.Delivery
, restaurants.Notes
, visits.`id-restaurants`","id","Name,Area,Cuisine,PriceRange,Quality,LastVisit,Breakfast,Brunch,Favorite,MustVisit,Tourists,Delivery,Address,CrossStreet,City,Closes,Notes");
}
else { //write (update/insert/delete) configuration
LogMaster::log("is_select_mode FALSE");
$conn->render_table("restaurants","id","Name,Area,Cuisine,PriceRange,Quality,Breakfast,Brunch,Favorite,MustVisit,Tourists,Delivery,Address,CrossStreet,City,Closes,Notes");
}
But the log shows that is_select_mode branches ‘true’ REGARDLESS of whether the client side is trying to display (SELECT) or write (UPDATE).
====================================
Log started, 10/02/2012 01:02:35
====================================
is_select_mode TRUE
SELECT restaurants.Name
, restaurants.Area
, DATE_FORMAT(max(visits.Visit),'%m/%d/%y') AS LastVisit
, restaurants.id
, restaurants.Address
, restaurants.CrossStreet
, restaurants.City
, restaurants.Phone
, restaurants.Cuisine
, restaurants.Breakfast
, restaurants.PriceRange
, restaurants.Brunch
, restaurants.Quality
, restaurants.Favorite
, restaurants.MustVisit
, restaurants.Tourists
, restaurants.Closes
, restaurants.Delivery
, restaurants.Notes
FROM restaurants
LEFT OUTER JOIN visits
ON restaurants.id = visits.`id-restaurants`
GROUP BY
restaurants.Name
, restaurants.Area
, restaurants.Address
, restaurants.CrossStreet
, restaurants.City
, restaurants.Phone
, restaurants.Cuisine
, restaurants.Breakfast
, restaurants.Brunch
, restaurants.PriceRange
, restaurants.Quality
, restaurants.Favorite
, restaurants.MustVisit
, restaurants.Tourists
, restaurants.Closes
, restaurants.Delivery
, restaurants.Notes
, visits.`id-restaurants`
Done in 0.018007040023804s
====================================
Log started, 10/02/2012 01:02:36
====================================
is_select_mode TRUE
DataProcessor object initialized
29_id => 29
29_!nativeeditor_status => updated
29_Name => Arriba Arriba Arriba
29_Area =>
29_Cuisine => Mexican
29_PriceRange => Moderate
29_Quality => Good
29_LastVisit => 05/08/10
29_Breakfast => 0
29_Brunch => 0
29_Favorite => 1
29_MustVisit => 0
29_Tourists => 0
29_Delivery => 1
29_Address => 762 9th Ave
29_CrossStreet => 51st St
29_City => New York
29_Closes => M-Th 12m/Sat 1a/Sun 11p
29_Notes => Pickled jalapenos in omelettes
29_value => undefined
ids => 29
Row data [29]
id => 29
!nativeeditor_status => updated
Name => Arriba Arriba Arriba
Area =>
Cuisine => Mexican
PriceRange => Moderate
Quality => Good
LastVisit => 05/08/10
Breakfast => 0
Brunch => 0
Favorite => 1
MustVisit => 0
Tourists => 0
Delivery => 1
Address => 762 9th Ave
CrossStreet => 51st St
City => New York
Closes => M-Th 12m/Sat 1a/Sun 11p
Notes => Pickled jalapenos in omelettes
value => undefined
UPDATE restaurants
LEFT OUTER JOIN visits
ON restaurants.id = visits.`id-restaurants`
GROUP BY
restaurants.Name
, restaurants.Area
, restaurants.Address
, restaurants.CrossStreet
, restaurants.City
, restaurants.Phone
, restaurants.Cuisine
, restaurants.Breakfast
, restaurants.Brunch
, restaurants.PriceRange
, restaurants.Quality
, restaurants.Favorite
, restaurants.MustVisit
, restaurants.Tourists
, restaurants.Closes
, restaurants.Delivery
, restaurants.Notes
, visits.`id-restaurants` SET `Name`='Arriba Arriba Arriba',`Area`='',`Cuisine`='Mexican',`PriceRange`='Moderate',`Quality`='Good',`LastVisit`='05/08/10',`Breakfast`='0',`Brunch`='0',`Favorite`='1',`MustVisit`='0',`Tourists`='0',`Delivery`='1',`Address`='762 9th Ave',`CrossStreet`='51st St',`City`='New York',`Closes`='M-Th 12m/Sat 1a/Sun 11p',`Notes`='Pickled jalapenos in omelettes' WHERE `id`='29'
Edit operation finished
0 => action:error; sid:29; tid:29;
Done in 0.018033027648926s
Shouldn’t the connector run the “else” render_table code during an UPDATE? Or am I doing something wrong?
Anyway, I promised a workaround and here it is:
I wrote two different connectors, rest_data_read.php for the datastore object, and rest_data_write.php for the dataprocessor object. I don’t even know if this is ‘legal,’ or whether it will somehow disable the bind/sync among my components (I hope not, since “dpRestaurants.init(dsRestaurants)” connects the datastore and the dataprocessor… right?) But in any event, it seems to be working right so far.