Article Preview
Buy Now
COLUMN
SQLBuilder and ActiveRecord
Open Source code for Xojo
Issue: 15.5 (September/October 2017)
Author: Scott Boss
Author Bio: Scott Boss is the founder of Nocturnal Coding Monkeys, Llc, who specialize in writing custom software. Scott has been a developer, system administrator, storage engineer, consultant, and architect to businesses from startup to global 100.
Article Description: No description available.
Article Length (in bytes): 7,077
Starting Page Number: 81
Article Number: 15510
Related Web Link(s):
http://www.bkeeney.com/rbinto/activerecord/
Excerpt of article text...
This month we are going to discuss an issue most of us Xojo programmers run into. That most of us are not database gurus. I can admit that I fall into that category. Now most of us have to do the work of the DBA (Database Administrator) as we don't have a seperate person on staff to do that work. And this is where the issue for us arises, we have to deal with using the database for data, but in a safe manner. So this month we are going to take a look at two projects. The first project is SQLBuilder (https://github.com/ktekinay/XOJO-SQLBuilder) by Kem Tekinay and the second is ActiveRecord (http://www.bkeeney.com/rbinto/activerecord/) by BKeeney Software.
I know you are saying that they are different products. You are right. One is a SQL command builder and the other is an ORM (Object Relational Mapper). But let's explore them.
SQLBuilder
First we will talk about Kem's SQLBuilder. SQLBuilder is designed to work on building the correct SQL syntax. But it does it in a way that makes sense to a Xojo programmer. We just cascade the various parts (like
From
,Where
, etc) in an object-oriented way. In the following code listing, see how we cascaded theFrom
,Where
, andPrepare
methods on theSQLSelect
to get the right SQL statement.
// does a "SELECT * FROM table WHERE i = 1" in a recordset.
...End of Excerpt. Please purchase the magazine to read the full article.