This is a custom built sql generator which returns string value in-form of SQL commands for basic CRUD fuctions C - Create R - read U - Update D - delete
- AbaezSqlGenerator.jar - Version 1.0
- import abaezcorp.sql.generator.*; to your java file;
- Firstly, create an object of the SqlGenerator() class
- Secondly, Call the table() method with argument representing the Database Table Name
- chain the select() method to table(), to select all column data or select('column1', 'column2') to select the specific column data needed
- you can also add a WHERE clause by chaining the where() method to the select() method in question.
- the where method accepts only two parameters, the 'column name' and the 'column value' respectively.
- finally chain the get() method at the end
* Example :
data = sql.table("users").select().where("username", "=", "abcd").get();
data = sql.table("users").select().where("username", "=", "abcd").andWhere("age", "<=", "20").get();
data = sql.table("users").select().where("username", "=", "abcd").orderBy("id", "ASC").get();
data = sql.table("users").select("first_name", "last_name").where("username", "=", "abcd").get();
- chain the insert() method to table(), the insert() method acccepts unlimited string arguments representing the column Name
- now chain the values() method to the insert() method in question, the values() method acccepts unlimited string arguments representing the columnValue
- finally chain the get() method at the end
* Example :
data = sql.table("users").insert("name", "age").values("abbas", "20", "male").get();
- chain the update() method to table(), the update() method acccepts unlimited string arguments representing the column Name
- now chain the to() method to the insert() method in question, the to() method acccepts unlimited string arguments representing the columnValue
- finally chain the get() method at the end
* Example :
data = sql.table("Books").update("name", "age", "sex").to("abbas", "20", "male").where("username", "=", "abase96").orWhere("username", "=", "abase11").get();
- chain the delete() method to table(), the insert() method acccepts unlimited string arguments representing the columnName
- now chain the where() method to the insert() method in question, the where() method acccepts unlimited string arguments representing the SQL WHERE condition
-
- Example : data = sql.table("users").delete().where("abbas", "=", "male").get();
* No JOIN CLAUSES YET