bind textbox with core framework - core-data

i already searched for an answer but without finding one to my specific problem.
i am using core data to save profiles and display them in a table. since core data is already set up, i wanted to use it also for storing application settings.
i've set up the model, set up an array controller to retrive the data, but now, i have no clue on how to connect this array controller to a single textbox.
i try to explain: theoretically my model could have more entries, just like the profile model has. but it has just one with some settings, as if a database would have only a single data row. is there a way i can specify that i want the data contained in the very first row? dont know if my question is clear, its not so easy to explain. please if it was not clear let me knwo and i will try to explain it again.
thanks
igor

Don't put application settings in Core Data. Any time you find yourself thinking that you want just one instance (row) for an entity, you're doing it wrong.
Cocoa Touch provides a class called NSUserDefaults specifically for the purpose of saving app settings. Look into that, it's almost certainly what you want.

Related

Creating a file that contains the set of inputs in pyqt

I have created a widget with a text bix, a combo box, a checkbox and some pushbottons. I wish to make a record of the set of input given everytime in a file. how do I do that ? Pls suggest.
The easiest and not that bad way imho is by reading the values and serializing them using json. You have to set/get the values individually for each input (with different calls). It's a breeze in fact. Personally, I have made my own 'serializing' function so I keep references to all objects in a list and that function loops the list serializing everything.
Depending on your needs and the complexity of your project you may need something different. Why don't you share some more details?
Best Regards.

yii objects and object fields

I'm not sure how to put this right.
I need to use yii to create an application which needs to use objects and fields.
Let's say that in my app I want to have those three objects: Computers, Servers, IPs. Each of these three objects will have it's own attributes:
Computer: CPU, Motherboard, Video adapter, IP (related to the object IP), Aquisition Date
Servers: Name, IP (related to object IP), etc...
IP: IP Address.
As you can see I also need a way to link my objects between them.
Every kind of attribute (object field) must be treated in it's own way, after it's own type. For example, we have a field called CPU which can be in a list of values. We have Aquisition Date and it must be treated like a date.
Well, the problem is that I need an extension to help me in creating those object types and setting their attributes. I don't know how to search for something appropriate.
Implementing this functionalities will take me a lot of time which I don't have right now. If there are no extensions, do you have any solution to implement one? I have some ideas for creating classes for every user field, classes which will implement an interface that render the methods properly for insert, update, etc.
Thank you!
You don't need any extension if you use Yii. You'd rather yake some time to read the tutorials. My advice is to begin with Larry Ullman's Learning Yii Series and then to go to the Definitive Guide
Once you have set your database and build your tables, you will only have to activate the Gii component of Yii framework and to use it's automated code generators to build your basic models, views and controllers.
The only thing you've left will be customization, of course. Yii + Gii save you all the repetitive work. But... read the docs.
[EDIT] after the OP comment below.
Is it an EAV model that you are looking for ? There is an unofficial Yii extension dealing with that : EAV Behavior. I have no idea whether it's good or not, as I definitely avoid to work with EAV databases. Let us know your opinion if you try to use it.

How do I set default values of fields added to existing entities?

I'm adding 4 new checkboxes to an entity and its form. There are already instances of this entity created in production. I need to have these checkboxes defaulted to checked on these existing entity instances. I set the default value of the field but apparently this only gets used when a new instance of the entity is created. Is there an easy way to set these on all the existing instances?
I could use a one-off workflow, but I don't know how many instances of this entity there are and due to auditing requirements I can't access the production environment.
You could create execute some JavaScript on the load of the form. Of course, this wouldn't update all of the values in the database, but it would update it before a user is able to view it. Do you need all the values in the database defaulted, or will java script work?
Edit
Your best options are either an update multiple ( you can increase the number of records an advanced find returns to 250 records per page) and continue to update all records manually, or perform a batch update. See this related SO question.
There's another way, too. You could write a console application that connects to your server (not that hard if you've done it before and don't have to make it general). Then, you simply execute an update on the service fetching all the existing entities and updating them after the change is made.
As #Daryl says, there's probably a way to do that from the GUI too, but real programmers do it the hard way. :)
Of course I'm kidding. I just love to type code, hehe. Never the less - once you start coding, you have full freedom to affect the data any way you need, forever.
You can do this by exporting the records and change the value for the field and then re-import back it.

Can I use MODEL-FIRST in EF5 withOUT losing the data in DB?

I am wondering about the model-first approach. I wish to design a new database using the model designer in VS2012. The new features of the model designer such as coloring and splitting up model sections are wonderful. Hopefully there will be purpose for using the model designer beyond initially creating a new database.
I would like to perform the following steps...
using the model designer, visually design and push the model to create the initial database and a table
add data to the table
make a change to the table in the model designer (e.g. add a field)
push the changes to the database (i.e. update the database)
NOT LOSE MY DATA FROM STEP 2. Also, just to clear any confusion... did I mention that I DON'T WISH TO LOSE THE DATA?
Please, please tell me this obvious need (i.e. the need to evolve the the tables and their fields without losing data, starting from scratch) has not been overlooked in iteration FIVE of EF.
This page on EF (http://msdn.microsoft.com/en-us/data/ee712907.aspx) makes things sound that the developer has equal choices between coding first and modeling first. To me, the intro video on the page creates a similar impression.
It would be nice if there were a simple menu option or better yet just a way to establish "automatic pushes to DB" upon changes to the model. That way whenever changes are made and the SAVE button is clicked, a dialog could appear "Update database?".
I see that using code-first there is a migrations option. I cannot seem to find the same for model-first. And I don't understand why this wouldn't be possible... after all the code that I would have written in code-first does indeed exist - it was created by the model-first code generation.
I'm keeping my fingers crossed in hopes someone will have a simple solution, perhaps something I've just overlooked and all this rambling/venting is in vain. :-)
You really have to use code-first if you want to modify your database when the model changes. Even then it's not some magical automated process but you'll have to script the changes.
With model first your best option is to generate a new database each time and create a change script (DDL) by using a tool like Redgate's SQL Compare or a Visual Studio Sql Server Database Project.
I'd like to add that it is virtually impossible to synchronize a database automatically with a model. Some changes require manual intervention, e.g. removing a field and adding another field cannot be distinguished from renaming/retyping a field. Some changed can easily be done in a model, but would require a table rebuild script in Sql Server (e.g. changing field order), or a combination of modified content and structure (e.g. making a field not null, adding a foreign key).
At the moment the only thing to do is:
Copy your database file... (backup)
Allow EF to recreate the database according to model
Per table copy-paste your records from backup to your new db.
This is not that easy as you need to copy paste in a specific order because of relations and it will only be good for minor changes such as adding columns and new tables or removing scalar columns or removing tables.
But I am certain that this is the begining of a correct approach to deal with the problem which later on can be automated by writing a more generic migration app between two databases which share same table names and relations.
Deeper problems begin when the relations are not the same / table names changed / column names changed.

Access MDB database. Linux: how to get a very odd pattern from the DB?

I'm in a VERY difficult problem.
I have a Microsoft Access Data Base, but it was made in the most chaotic way possible. The DB has like 150+ tables, Only uses like 50% of the tables. The relations are almost random. But, somehow, it delivers some information.
I need to get a particular component of the DB, but is so tangled that I can not manage to get into the table that creates that value. I revised every table, one by one, and found nothing.
I used mdbtools for Linux to try to inspect with more details the DB. But unfortunately has not been developed in years, and it closes every time. Maybe because the DB is "big" ? -700 mg-
I'm wondering: is there a way to see all the relations the arrives to the particular value I'm looking? Or to decompile the DB? I have no idea in which language it was made. I'm suspecting that it was made in Visual, just because is rather crappy.
Well, waiting for some help.
I would suggest using (still) MS Access for this. But, if relationships look messy on the diagram, you can query one of the system tables (MSysRelationships) directly to get ALL the relationships you need (e.g. for particular table etc.):
To unhide system tables in early versions of Access (97-2003), follow the instructions here:
For Access 2007, do the following:

Resources