Database access

103 views
Skip to first unread message

Chris Moody

unread,
Feb 7, 2018, 5:47:30 PM2/7/18
to Fat-Free Framework
Hi all,

With F3 is there anyway to make an app that is not database specific?
I'm currently working on a blogging app, and would eventually like it so
in the config file you can specify any kind of database and have it just
work. (With proper logging information of course).

Is this possible?

Chris

Nuwanda

unread,
Feb 7, 2018, 6:05:58 PM2/7/18
to Fat-Free Framework
Use text files to store your data which is as unspecific as you can get. F3 has the Jig mapper for that:

https://fatfreeframework.com/3.6/jig

Chris Moody

unread,
Feb 7, 2018, 6:10:26 PM2/7/18
to Nuwanda via Fat-Free Framework

That's an idea, but not very practical :) Doesn't Laravel offer something like this?


On 02/07/2018 05:05 PM, Nuwanda via Fat-Free Framework wrote:
Use text files to store your data which is as unspecific as you can get. F3 has the Jig mapper for that:

https://fatfreeframework.com/3.6/jig
--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/c539d726-4bdf-4bbc-9401-52588c0aeae9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ved

unread,
Feb 7, 2018, 6:47:46 PM2/7/18
to Fat-Free Framework
Not really sure what you're asking. F3's data mappers already support a few different database systems since it pretty much extends php pdo classes.

You could put something like dbtype=oracle on your config and just have your app choose the correct dsn to initialize it?

You can even go with f3-cortex and have mongodb in the mix as well with the same api.

Chris Moody

unread,
Feb 7, 2018, 6:53:54 PM2/7/18
to f3-fra...@googlegroups.com

What I'm asking is for like a generic SQL so that the code I write doesn't care what type of DB its talking to, be it MySQL, PostgreSQL, MicrosoftSQL etc.

In other words I could write something like, $f3->insert (db_name, fields, variables); and then f3 gives the proper instructions to whatever database its talking to.

Yes I realize this wouldn't be easy, was just curious if it was possible.

Chris

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.

ved

unread,
Feb 7, 2018, 7:24:19 PM2/7/18
to Fat-Free Framework

What I'm asking is for like a generic SQL so that the code I write doesn't care what type of DB its talking to, be it MySQL, PostgreSQL, MicrosoftSQL etc.

In other words I could write something like, $f3->insert (db_name, fields, variables); and then f3 gives the proper instructions to whatever database its talking to.


That's exactly what the F3 ORM does.

Quote:
F3 derives the data mapper structure directly from the database schema. No guesswork involved. It understands the differences between MySQL, SQLite, MSSQL, Sybase, and PostgreSQL database engines.

This should work on "all" databases:
$user=new DB\SQL\Mapper($db,'users');
$user
->userID='jane';
$user
->password=md5('secret');
$user
->visits=0;
$user
->save();

Reply all
Reply to author
Forward
0 new messages