I have a file that I wish to parse and add to the database.
The way I wish to do it is this:
The user uploads the file
File is parsed
The users are given the parsed data and selects what they want to keep
They submit
(More detailed explanation follows)
I have a film script file that I wish to parse and enter scenes and their respective characters and props. I have already managed to parse this file into an array using php.
What I want to do now is to
prompt the user with the various scenes and its contents
allow the user to fix / modify the data before submitting it into the database.
The thing is that the script file has more than one scene in it, so I am unsure how to handle the data-entry aspect of this problem.
Are there any "best practices" for these kinds of data entries?
(if I didn't explain something in enough detail, please tell me and I'll update the question).
I would simply parse the file and save it as it is to the database. Something like Script hasMany Scenes. Let them select their script and simply paginate the Scene records and let them delete them.
Is there an urgent need to not save them all after import? Another downside of your approach is that if the browser crashes or the user closes it he has to start over again because you just kept the data in memory but not persistant.
If you want to rely on your approach you'll have to work with the data coming back from the form and simply remove the key from the form data.
Like doing this in a foreach running over the data structure
if ($data['Scene][$key]['delete'] == 1) { unset($data['Scene'][$key]); }
Related
I am taking a database design class and for a project want to make a database of my mom's digital photos for her. I haven't dealt in application up to this point, only theory, but I have Access. Therefore, ideal answers don't suggest non-database solutions and don't assume I know much about actual database implementation. Solutions specific to Access could also be a plus. I hope that precursor saves some time and effort.
Theoretically, my mom wants to see all photos of pets from '05-'07 in raw format, and she enters an appropriate query. I suspect I can handle it up to there. However, at the moment, the best I can figure out to do is to return a column of either attachments or OLE objects. 5 clicks per photo is not ideal. I need a faster way to present the images. Opening them all in a grid of thumbnails or as a one-click-slide-show would seem the natural fit, but whatever works. How can I accomplish this?
Less important but worth consideration is the fact that, at some point, it would be great if this same type of system could be implemented on the internet for all of the family reunion photos she has taken, but I will take what I can get.
Use one form to get parameters for the query. then use another form(more processing) or report(if printing) to show the selected pictures. I will not cover passing parameters but here are some links.
https://www.fmsinc.com/microsoftaccess/forms/openargs/index.htm
https://learn.microsoft.com/en-us/office/vba/access/concepts/forms-design/apply-a-filter-when-opening-a-form-or-report
There is a complication, in Access pictures are usually stored in the attachment type. the attachment column can hold many pictures in each record. So if we have a table called Pictures with an attachment type column also called Pictures, then each individual picture is actually stored under Pictures.Pictures.FileData.
So to display the picture query we use a form/report with default view set to Continuous Forms (displays many records or in this case pictures on the same page) then in the details section of our Display form we place an attachment control and bind that control to our filtered Pictures.FileData.
Format and add functionality to taste.
In my web application, there are several classes whose instances need an image (i.e., photo). Each of these instances can have only one image. Currently, my implementation is that when user creates a new instance, I keep the name of the uploaded file as it is, and record it in the ImageUrl field of the associated table.
I feel like this is unnecessary. I can just rename the image with the unique url of the associated instance, and I can implement the programming logic accordingly. For example, if a user's id is 145, then I can record it with this name: profilephoto_145. Later, when I need to display the user's photo, all I need will be the id of the user. If user uploads a new file, I can just overwrite the existing file with the same name.
I wonder if this makes sense assuming each instance will have one associated image, and there will be no need to keep track of the previous files. What is the common approach for this? Should I keep the full path for each image and keep their original names, or should I implement this renaming files with ID?
I can just rename the image with the unique url of the associated
instance, and I can implement the programming logic accordingly. For
example, if a user's id is 145, then I can record it with this name:
profilephoto_145.
Yes, you can do that. The general search term for this kind of thing is "tight coupling" or "coupling and cohesion". The concept applies in lots of different areas of software development.
Your underlying idea is that you'll always store one profile photo per user, and you'll store it by concatenating "some kind of path" and "profilephoto_" and user's id. The main problem is that any change to that idea requires changing source code. And changing source code has ripple effects.
The common alternative is to store the image file's name in a database. In this case, most changes to that underlying idea would require only a database update.
Programmers who have been around a while cringe a little when people start using words like always and never. Because we know that, given enough time, statements that use always and never with respect to software are always never true.
I've got a Cake application with a reports query interface, where the admin user can filter the data by various inputs in a form and the results are then displayed on the screen. I am looking for the simplest way to add a button which allows the user to download the results of this same query as CSV.
I'm sure I can create one for myself if I have to, but is there already a way to regenerate any given form based on $this->data? That way, I can just add .csv to the form action and use RequestHandler to choose the right output format.
[here take a look at the following...
instead of finding the data from Db you can simply pass $this->data to it.
take a look at follo
Exporting data to CSV the CakePHP way
I guess you have to replicate the function on your controller, one for generating the results on screen and another same function intended for csv, but on the function for csv it must have parameters which are similar to the values of $this->data. Use javascript to redirect on the function for csv.
I want to build the database which gets the url from user in one cell and returns some texts to the other cells. The Url is from www.imdb.com. I saw it was possible on Google Spreadsheet. I am wondering if it's possible for MS Excel.
Like when I input a movie Url, it gets ratings,title, casts from IMDB page.
You can get pretty close using a IQY file to define the web query and the parameters a user should input. The only difference is that, rather than defining the movie id in a cell, your user will be prompted when they create or refresh a query.
To do this, you need to:
create a plain text iqy file. Call it "imdb-movie.iqy" or something.
Put this text in it:
WEB
1
http://www.imdb.com/title/["Movie ID"]/
Selection=3
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False
In the "Get External Data pane of the Excel Data ribbon click "Existing Connections" and find your IQY file. It will ask you where to put the data and prompt you for the movie id. By right clicking, you can see lots of settings about formatting and such.
The "selection=3" entry in the IQY file determines what table to pull the data in from. It sounds like you may want a number of them.
To make your own IQY file, you can choose the "get external data/from web" and select which table to use. Then choose "save" from the dialog and you have the file. You can paramaterize it with the ["parameter name","prompt"] syntax.
for example i've got a form with some input fields(every form and it's inputs with validation rules are stored in database).
Every input got it's own OnChange() which posts json (i.e. new value, input element name, ...) to controller for validation, if validation passes the new value must be saved somewhere until user clicks submit button, which will save all data to database table.
And here i'd like to ask, what this special place between ui and database can be ?
p.s.
also if user closes browser/form the next time he'll come back i need to ask him if he would like to start from an empty form or fill form with values he previously entered there.
Thank You !
Cookies or intermediary database table would work for this case.
for an intermediary database like that, you could use something like MongoDB, it is really easy to get it started, you just work with the classes you have, don't need to setup any schema, you just save the objects
http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial
If you are submitting the entire form at the end, why can't you just store the values at that time? Is this a multi-page form(s)? Why not allow the database records to be partially filled? You could always add a bit column to mark the record as complete or incomplete. This would be much simpler than duplicating your table structure.