I have a new type project. Please help if you can. I have a user management project in which i have many tables lets say user table.
table user
fields user_id , user_f_name , user_l_name, user_username.. etc. this table is encrypted in real like
RM_999(this is name of encrypted table)
RM_0999, RM_1999 , RM_2999 , RM_3999...
I the same manner all tables and columns are encrypted for sake of security.
But i have yii project written in simple names like user_username (As it was already made project which i used for variouus project). But now i don't want to changed my code for that encrpted database. Is there is any way bye which i can use my written code without changing it.
Any help will be appreciated.
It depends on how your existing application code is written.
The below approach may solve your problem
In your project, if there are entity classes for all tables in DB which extends CActiveRecord then you can use attributeLables() so that you can map your existing column names to encrypted column names. (Assumed that your application code access that table attributes via labels).
Related
I am a novice in SQL organization! I essentially have an inventory app written in php with an sql database. If I want to allow multiple users to create inventories independent of one another using my web app, would I just use foreign keys linked to a user table or should I be creating new tables for each user, or another option that I have not considered?
thank you!
I have said before that it's a code smell if you hear the word "per" in the context of of database design.
I'm going to create a table per user.
That could result in a lot of tables. How many users will you have? Hundreds? Thousands? Millions? Can your database handle millions of tables? How can you test this? Does that mean your application must create new tables on the fly as new users register?
In your application code, would you create a separate PHP class for each user? Probably not -- you'd create one class that can be reused for many users. One of the class data members would distinguish the user, so each object instance of that class is for one user. But it's the same class.
Likewise, it's almost always better to create one table, and make sure the table includes a column to identify the user. It's simpler to add new users by INSERTing new rows into the table, instead of requiring new tables to be created.
There are exceptions to every rule, of course. You might have so many users that you must split the database over multiple database servers. Or you might have a very strict privacy requirement and separating the data into multiple tables is a good way to enforce it. But if you're just starting out with a small project, those exception cases probably don't affect you yet.
How to implement pre-audit system for a web-app? I mean when the data changes made by regular users are saved for review and only after that they can be applied (or rejected) to main tables.
How to organize and keep in sync relations between data table and preliminary table, when the table name is changed for example, or worse, table structure?
How to validate submitted data for constraints?
Is there something similar that I can use, or read about?
I have two tables in DB (topic, topic_content):
what kind of entities i should create for symfony2?
I think, i should have something like this in my symfony structure (Entities/Topic.php, Entities/Topic_content.php) help me please..
Yes, you would create Topic and Topic Content. And likely also a User Entity (because user_id looks like a foreign key).
However, the idea in Symfony2 is to approach the application from the Model site instead of the database site. Quoting https://doctrine-orm.readthedocs.org/en/latest/tutorials/getting-started-database.html:
Development Workflows
When you Code First, you start with developing Objects and then map them onto your database. When you Model First, you are modelling your application using tools (for example UML) and generate database schema and PHP code from this model. When you have a Database First, you already have a database schema and generate the corresponding PHP code from it.
For database first, there is a generator that will derive objects based on your schema:
https://github.com/beberlei/DoctrineCodeGenerator
The recommended approach though is to have Doctrine generate the db schema from your Entities.
Quoting Getting Started - Generating the DB Schema
Doctrine has a Command-Line Interface that allows you to access the SchemaTool, a component that generates the required tables to work with the metadata.
It requires some setup, which is explained in the guide. Once you have that, you simply tell Doctrine to generate or update your schema, whenever your object structure changes.
i'm using codeigniter.
i'm limited to 1 mysql database.
if i have a web application with many tables for use on 1 company.
i would access it like:
http://www.abc.com/login
http://www.abc.com/member/sales.php
if i want to use the same application for other companies in the same database, how should i proceed? and how can i access it using codeigniter?
i can't seems to figure it out.
many thanks for your guidance.
Try to create a table names with the prefix of the Company name that will give the clarity of the table names also...In the code u can easily identify the Name with the prefix.
I guess in your case codeignitor is mere a development framework not more than that so try to create a seperate table with name of companies and use PID of company table for identify all the records related to the company.
Or if creating schemas is not an issue than codeignitor provides you facility to connect more than one database at a time, please go through following link -
"Connecting to Multiple Databases"
Hey Friends I want to make a form builder using Yii.
For that I made the database table as:
[user]-> user_id
[form]-> id, user_id
[form_elements]-> form_id
[form_values]-> id, form_id
[table]-> id, form_id, form_elements_id, form_values_id, user_id
I made the model class for the database tables for making them accessible. So for making the form_builder do i need to make them CRUD or make them form generator through Gii tools?
Please help me as I am new to Yii.
If I grasp your schema correctly, you're about to make a layer on top of CForm. Your application will presumably have two interfaces:
one that is generating forms based on the data in your database, and accepting end-user inputs,
and another that will manipulate the form fields.
For the first, you need to develop a special library to interpret your data into CForm configuration and store the input in a separate database (and by separate I mean a database that is not covered in your specs above).
For the second, yes, you will need a CRUD application (as a start at least) to deal with those objects in a convenient way.