Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeigniter/Model - Select Database Table Fields #1072

Closed
tada5hi opened this issue Jun 13, 2018 · 5 comments
Closed

Codeigniter/Model - Select Database Table Fields #1072

tada5hi opened this issue Jun 13, 2018 · 5 comments

Comments

@tada5hi
Copy link
Contributor

tada5hi commented Jun 13, 2018

I like the Idea of protected/allowed Database Table Fields for insertion and updating data sets.
But i miss the opportunity, to specify the fields i want to receive from the database table request/query in the extended Model Classes and the Model Class itself.

Furthermore it would be also great for @lonnieezell Forum App , to set specific fields for Relationship Tables and the own Table which should be selected/received.

@tada5hi tada5hi changed the title Codeigniter/Model - Database Selected Fields Codeigniter/Model - Select Database Table Fields Jun 13, 2018
@puschie286
Copy link
Contributor

would be a nice improvement - also increase table compatibility while development

@InsiteFX
Copy link
Contributor

These type of questions should be asked in the CodeIgniter 4 Forums not here.

@jim-parry
Copy link
Contributor

Agreed. This sounds like a feature request, and should be raised onthe forum. We use github for tracking bugs and approved work packages.

@tada5hi
Copy link
Contributor Author

tada5hi commented Jun 14, 2018

Yo are right, but the model logic needs to be overwritten in some parts, to support the oppurtunity to select only specific fields, otherwise the Model is kinda useless for data selection.
For example expect i want to receive all users or a specific user, i would receive all fields. The password field and other fields included, which you dont want to output to other users. Otherwise you have to filter the result data before displaying it to the user. In addition you load data from the database which is not required.

@lonnieezell
Copy link
Member

First - You can chain Query Builder commands with the model commands, so you should be able to do:

$users = $userModel->select('name, email')->find($id);

Second - you should probably filter the data before displaying it to the user anyway, as a security thing.

Third - don't expect any type of relationships to happen in the models in the core. We've said from day one that an ORM would not be part of the core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants