Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.
/ SqlBuilder Public archive

Inspired by PHP Doctrine, Android SqlBuilder is a convenient tool that helps you to build a complex sql query statement in a structural way.

License

Notifications You must be signed in to change notification settings

gusterwoei/SqlBuilder

Repository files navigation

Android SQL Builder

Android SqlBuilder is a convenient tool to helping building a complex sql query statement without developer worrying about the incorrect or missing SQL syntax. In addition, it also takes care of automatic value binding.

Installation

Include the following dependency in your build.gradle file of your project.

repositories {
    jcenter()
}

dependencies {
    compile 'com.guster:sqlbuilder:1.0.4'
}
...

Example

String query = SqlBuilder.newInstance()
                .select("u.*", "COUNT(p.*)")
                .from("users", "u")
                .innerJoin("u", "posts", "p", "p.user_id = u.user_id")
                .innerJoin("u", "books", "b", "b.user_id = u.user_id")
                .leftJoin("p", "comments", "c", "c.post_id = p.post_id")
                .where("u.user_id = :userId")
                .andWhere("u.status = :status")
                .groupBy("u.user_id")
                .orderBy("u.username")
                .bindValue("userId", "user123")
                .bindValue("status", 1)
                .getQuery();

Developed by

License

 Copyright 2015 Gusterwoei

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

About

Inspired by PHP Doctrine, Android SqlBuilder is a convenient tool that helps you to build a complex sql query statement in a structural way.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages