How to store multidimensional array data and update it by key - laravel-5

I am developing a store and update function for multidimensional array.
There is a hidden id coming from a form which needs to be unique as the forms are cloned.
How can i store that data from the form with a hidden value ?
I have already tried a for loop and a for-each loop but I was unable to store the unique hidden value which is coming null from the form
All data should be saved with unique hidden data and updated by these unique key.

Related

How to create a validation rule which restricts data entry from specific table

I am creating a data entry form and report on MS Access and I would like to create validation rules for some input text boxes that restricts data based on the data contained in another table.
For example: For the subdivision input field, data that can be entered must be equal to one of the items which is contained in the Subdivision table which contains a list of subdivisions such as:
Los Angeles Sub
San Bernardino Sub
Riverside Sub
Etc
How would I go about doing this?
If your form data is directly bound to the table that holds it, then you would use the Before Update event of each text box to perform any validation you wish using VBA. If your form is not bound directly to the table you can either use the On Lost Focus event to validate each text box individually or whatever process you use to push the data to the table and validate the entire form input.

In what file are values received from edit.php?

I'm creating a custom field called provinces where I have built a multi-select field. This field receives a JSON keyless object [3,4,5] from the database which I then apply to the input in getInput() in province.php. I have managed to this on the output, but I need to write any values selected back to the database.
Where can I get the values that are then passed back if the user selects other options (in the back-end form edit.php) in the multi-select?
In other words, where is the $_POST array received before either it is redirected back to the form (Save) or to the list page (Save & Close)?
Please correct me if I'm wrong.
Thanks in advance.
In the model for your form view, look for the function prepareTable. This is a good place to prepare/sanitize the data prior to saving.
If you want to process the data further after it is saved, you can use the function postSaveHook in your form controller.
Or you can of course also do something during save in the tables store function.

Magento loses session data

I use the following to set some data:
Mage::getSingleton('core/session')->setData('amprevnext_collection_ids', array_values($ids));
it contains an array of ids,
when trying to retrieve the data
Mage::getSingleton('core/session')->getData('amprevnext_collection_ids')
it does not return any value, I tested by trying to change the core to customer,
I also used a $_SESSION, which in return was empty as well..

entity framework returning only one value but the list size is correct

Entity framework returning only one value but the list size is correct
I have a table that does not have primary id and I need to get or select all the values in it.
What I see is when I do the selection with linq the number of objects is correct but it is the first row over and over.
I am simply doing something like this
List<MyValueType> valuesInDB = myDb.MyValueTypes.ToList();
Problem is I may get thousands of rows (which is correct) but the rows all have the same exact data.
I am using VS 2010 and used the wizard to create my EF object.
The problem is that entity framework is not able to work with entity without a key. So if your table doesn't specify a key, entity framework will infer its own. The key created by EF is composed of all non-nullable non-binary columns.
So if you for example have single non-nullable column in your entity which have only very small set of values (like enum) you will be able to load only single entity "per value". The reason is an inner implementation of the context and the state manager which uses Identity map pattern. When data record is retrieved from database, EF will first check an entity key and tries to find an object with the same key in its internal storage. If an object is found it will use that object instead of data record retrieved (despite of different data). If an object with the key is not found a new object is materialized and added to internal storage.
That is the purpose of Identity map - object with given key should be created only once by each context. Identity map is core pattern in ORM.
I wrote about Identity map also in this question.
I would suggest searching for the word "Warning" in your EDM's designer.cs file. It might tell you if Entity Framework is having any issues with your table.
I really can't comment much in the absence of the table design. I tried replicating your problem but wasn't able to do so. Here is what I did:
Created a table with no primary key but it had a unique key on an ID column. Entity Framework was able to infer a primary key and when I fetched the data, I not only got the correct number of rows but also the corrects data in those rows.
Created a table with no primary key and no unique key. Also there was no column called ID. Entity Framework excluded this table in the EDM that was generated. Consequently I wasn't able to query this table at all.This was displayed as a warning in the EDM designer file.
It would be better if you can share the create script for your table.

how to get the keys of a collection in VB6.0

I am debugging a VB 6.0 application which deals a lot in collections. In one such scenario the application is fetching the object from a collection using text entered in a textbox as a key.
Now I want to know what key needs to be entered in the textbox for me to fetch the required object in the collection.
I think what you're asking is that given a collection of objects, and an object that you know is in that collection, how do you determine the object's key in the collection. The answer is that this value is not stored anywhere, it is only specified when you add the element to the collection. So general practice is that when you add the element, you make the collection key some property or combination of properties on the object, so that you can calculate what the key would be given the object.

Resources