looking for a db abstraction/substitute that actually works [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
i am looking for a form of data storage that will answer a few requirements. i realize these requirements are non-standard, and for now i'm using activerecord and ORM solutions like everyone else, but this is my "holy grail" - if you know of anything like this, i would be eternally grateful:
pure PHP
multiple repositories, preferably file based for portability, where i can instantiate by telling it "use repository [X]" - i don't want to pre-create repository [X], if i reference it, it exists.
zero database configuration - i don't want to create tables or export SQL dumps, if it's referenced in my code, it needs to be in the database, auto-created without any fuss, my code is my schema
hierarchical, not relational, ideal structure would be just a freeform, schema-less XML, but since XML performs horribly with large trees, it can't simply be an XML file.
i have experimented with flat XML storage (with xpath and xquery) but it gags on a mid-sized repository, and cripples the application.
i have also experimented with key=>value pairs dropped into a SQLite database with a single generic table, but that gags even faster, and re-forming even the simplest record from key=>value pairs is a performance decimator.
finally, i experimented with lucene as implemented in the zend framework, which was pretty close to ideal, apart from the no-update part.
any ideas, anyone?

I've been having great fun with RedBean, it's not quite designed for flatfiles, but runs on PDO, so it should be relatively easy to write a sqlite module for it. Not sure if it will work for your needs, but definitely worth taking a look at.

Here are some links you may find useful:
txtSQL
Gladius DB
Also, have you considered using Berkeley DB?
Some of the DB extensions listed in the PHP Manual are intended to be used on flat-file like databases.
From your description it seems like PHP arrays should work perfectly:
pure PHP
multiple arrays, file or memory based
your code is your schema
hierarchical
You could use serialize() or var_export() functions to enable file storage.

Related

Building an application independent of the SQL engine used [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I wanted to ask that if and how is it possible to make a PHP-based application independent of the SQL engine used?
(Under that I mean that the application can be executed on PostgreSQL, MySQL and maybe also Oracle SQL.)
Current idea is to leave the PDO DSN into the config file, so that the queries etc everything else stay the same, but can I face some problems in regards of CRUD actions to the tables themselves?
If I don't add any complex stuff in it, then is it possible for me to make it so that it doesn't depend on the engine at all, only has the PDO DSN for the database and that it can query everything the same way on each of the SQL engines?
Best regards!
Read about Database Abstraction Layer. There are quite some libraries available for PHP. If you choose any of the popular frameworks, to mention Symfony or Laravel - you will have the DBAL out of the box - either Doctrine or Eloquent. Both offer similar query building functionality, IMO based on HQL.
Definitely don't try to write it "your way". Even if you do only simple queries the gramma is different, to mention just the types, incrementing etc...
If you stick to a common subset of SQL which is supported by all your targeted databases, then yes, you can get away with using the same PDO instance, the same queries, and just switching the PDO DSN.
Practically speaking however, for anything but the most trivial queries, you'll probably be using some database specific features which you'll have to implement slightly differently for different databases. Simply speaking that means your code will have to execute query A if connected to MySQL but a slightly different query B if connected to Postgres.
You certainly do not want to implement that using a lot of if..else, instead you want to be using database specific adapters/drivers. In your business code you'll be calling $database->getUserRecords(), and depending on whether $database uses the MySQL or Postgres adapter the query will be slightly different. (Also see dependency injection.)
You can either do this by implementing those adapters by hand and tweaking the queries for each database, or use a more abstracted ORM/DBAL which can assemble the correct query on the fly using database-specific query builders. There are many existing libraries for that.

I need an introduction to MongoDB/NoSQL Database [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I use PHP/mySQL/CodeIgniter pretty heavily, writing sql statements to handle/manipulate data. I feel doing all that is primitive, and I've heard good things about MongoDB, schema-less database.
In MySQL, schemas helps me figure out the structure of the model. Usually, I draw out a class diagram with basic things like: id, title, description, date
What blows my mind is, MongoDB seems insanely simple, it's hard to grasp where to begin. From what I hear/read, it doesn't have a schema. How do I know what type will it return?
How do I build my models, how do I add relations between different "tables"?
What is the standard way to add relations and map out data? I've tried playing with it, but wasn't sure what I was doing was the correct way.
I've tried reading manuals and such, but couldn't find a good article helping me transition from mySQL to MongoDB.
Is there anyway I could see comparisons of Models with mySQL and MongoDB? Simple things like CRUD.
How do I start, where do I begin?
You could start here.
How do I build my models, how do I add relations between different "tables"?
Answer:
A non-relational approach is the best path to database solutions which scale horizontally to > many machines.
Answer:
MongoDB stores data in JSON documents (which we serialize to BSON). JSON provides us a rich data model that seamlessly maps to native programming language types, and since its schema-less, makes it much easier to evolve your data model than with a system with enforced schemas such as a RDBMS.
Check also What is NoSQL, how does it work, and what benefits does it provide?, I need an advice about NoSQL/MongoDb and data/models structure and Converting simple MySQL database to a NoSQL solution

Javascript/PHP Family Tree Builder with Multiple Parents [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is there an existing PHP, Javascript, or even command line tool that can build a family tree in HTML (preferably) or at the very least create an image for it? Multiple parents are a requirement. I have been googling this for hours, but to no avail.
For instance, the Google Organizational Chart would be ideal, but it only allows each node to have at most one parent. I need two parents to be possible.
Whatever this website does would also be perfect: http://www.familyecho.com/, but it seems to not be done with javascript and they don't publish the code that actually creates the visualization.
Even connecting to an external website to use their API to generate a visualization would be perfect.
You might be interested in Raphaël, especially this demo.
Edit: I just came across a couple other promising-looking options from this question.
Protovis - I knew about this one when I first answered, but didn't think of it at the time. It's really flexible. Check out the examples.
Dracula Graph - haven't tried it. It might be too simple for your uses.
As it's just the JavaScript you're after (I assume, since you're designing your own schema...) the InfoVis framework provides all sorts of complicated relationships - http://thejit.org/static/v20/Jit/Examples/ForceDirected/example1.html.
This is possible with Graphviz. It's an (easy to learn) language, and a command-line executable (for Linux, Solaris, Windows and Mac) which can export at least to PNG and SVG. It is extremely flexible and can do family trees. I suppose multiple parents is not a problem at all. Check http://www.graphviz.org/content/kennedyanc for an example. See all the other examples at: http://www.graphviz.org/Gallery.php
You will probably discover several other uses for Graphviz yourself.
Family Echo now has an API, allowing you to submit a family tree in GEDCOM or FamilyScript format, and view in online via the Family Echo site.
At last if found very useful script for making professional family tree diagram in php. It helped me alot. Just want to share with others, may be helpful to others.
jTree Family Tree Maker Script

PHP / MySQL Query Builder UI with jQuery? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
So, I need to construct a front-facing query builder for a database, but I'm having trouble finding existing code for what I can't imagine is a rare requirement.
Basically, I have non-SQL fluent people needing to build queries on the fly and view the results.
I found this: http://plugins.jquery.com/project/SQL_QUERY_BUILDER (Demo: http://ksistem.com/jquery/sqlbuilderdemo.htm)
But it requires that the database schema be hardcoded, rather than be dynamically generated.
Is there a better solution that dyamically pulls the database schema into a jQuery-like UI for building and executing SELECT queries against a MySQL database?
Active Query Builder ASP.NET Edition's MS Access-like user interface is based on jQuery. It's a commercial component for ASP.NET 2.0 and higher. It can build SELECT statements for MySQL server.
Product page: http://www.activequerybuilder.com/product_asp.html
Demo: http://aspquerybuilder.net
Dynamically creating the database schema might be a problem, because of the relations between tables. You could let the users carry the burden of selecting the relations but if i look at the "non-SQL fluent people" around me.. i'd probably not do that..
Other than that, if you want to create/check the structure on the fly, you practically have to create/check it every time the script is called. Generating a maybe huge, not necessary, overhead. I`d probably rather have a script/db-admin generate/update the structure every time someone twiddles with the database.
I doubt that you'll find something that does exactly what your looking for.
Maybe pulling the structure out of a YAML file that's kept up to date by the db-admin might be better a better solution.

Changelog file: YAML vs JSON vs CSV [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I am creating a simple Changelog lib in CodeIgniter that will basically log a message everytime someone adds, deletes, changes or publish a blog post. I will log messages in files by batches of 300. So every 301st message will go in a new file. At first I wanted to write the logs to simple .log files but then I got the idea to actually style the thing and I had to seperate each "attribute" of each message (ie: the user, the message, the type of the log, etc.). So .log files are out of the question since extracting the info would be a pain.
What is the most appropriate format for such a task? I already ruled out MySQL and XML because they are too heavy (especially considering that the log files won't exceed (about) 300 lines). I suggested YAML vs JSON vs CSV in the title, but is there yet a better alternative?
I'd say it all depends on what you need/want to do with those files :
CSV has one advantage : it can be imported to Excel and such applications -- which might be usefull in some situations, to do reporting to a superior, for instance
JSON is readable in many languages, including Javascript ; but not easy to read by a human being ; and harder to modify "by hand"
And YAML is quite easy to read ; not hard to modify by hand ; but not sure about the availability of libraries to read it in several languages.
If you are in none of these situations :
must be readable
by a human being
in several programming languages
easy to modify
same notes
Then I guess all three formats will be OK ^^
Without knowing more, I would go with either CSV (for the import to Excel stuff), or JSON (for the portability reason).
I guess CSV would be easier because of a couple of reasons:
count how many logs are already in the list (just count number of lines)
adding stuff to a JSON object can't be done by just appending data
Of course, I you choose to create a separate JSON object for each log item and put each on a separate line, this isn't an issue.

Categories