/***************************** {{{ LICENSE ********************************\ * dbobj, the relational object persistence module for PHP * * Copyright (C) 2006 Adam Banko * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * \***************************** LICENSE }}} ********************************/ #ifndef DBOBJ_SQL_H #define DBOBJ_SQL_H #include "php_dbobj.h" #include "dbTypes.h" #include "objTypes.h" #include "basicPropConfig.h" typedef struct _selectExtraData { char* where; //...WHERE id=5 AND $where... char* orderby; //...ORDER BY $orderby... char* limit; //...LIMIT $limit... } selectExtraData; /* * including the matching sql keyword(eg. SELECT ) * ...L funtions return how many characters needed for the specific operation * write functions: start writing at place pointed by first argument (start) * return pointer to the char after the last char written */ //selects from one table //SELECT a,b,c FROM tablename DBOBJ_API uint SQL_SELECTsL(basicPropConfig dbPropConfs[], uint dbPropConfsL, uint tableNameL); DBOBJ_API char* SQL_SELECTs(char* start, basicPropConfig dbPropConfs[], uint dbPropConfsL, uint tableNameL, char* tableName); //DELETE from tableName DBOBJ_API uint SQL_DELETEsL(uint tableNameL); DBOBJ_API char* SQL_DELETEs(char* start, uint tableNameL, char* tableName); // WHERE a=$1 AND b=$2 DBOBJ_API uint SQL_WHEREPKsL(uint* paramCounter, basicPropConfig PKs[], uint PKsL); DBOBJ_API char* SQL_WHEREPKs(char* start, uint* paramCounter, basicPropConfig PKs[], uint PKsL); // WHERE a=$1 AND b=$2 struct _dbCondition; DBOBJ_API uint SQL_WHERECONDITIONsL(uint* paramCounter, struct _dbCondition* conditions, uint conditionsL); DBOBJ_API char* SQL_WHERECONDITIONs(char* start, uint* paramCounter, struct _dbCondition* conditions, uint conditionsL); //INSERT INTO tablename(a,b,c)VALUES($1,$2,$3);\0 DBOBJ_API uint SQL_INSERTsL(uint* paramCounter, uint tableNameL, basicPropConfig dbPropConfs[], uint dbPropConfsL); DBOBJ_API char* SQL_INSERTs(char* start, uint* paramCounter, uint tableNameL, basicPropConfig dbPropConfs[], uint dbPropConfsL, char* tableName); //UPDATE tablanev SET a=%1 DBOBJ_API uint SQL_UPDATEsL(uint* paramCounter, uint tableNameL, basicPropConfig dbPropConfs[], uint dbPropConfsL); DBOBJ_API char* SQL_UPDATEs(char* start, uint* paramCounter, uint tableNameL, basicPropConfig dbPropConfs[], uint dbPropConfsL, char* tableName); //DECLARE dbobj_cursor_15 SCROLL CURSOR FOR DBOBJ_API uint SQL_DECLAREsL(uint cursorNameL, bool scroll); DBOBJ_API char* SQL_DECLAREs(char* start, char* cursorName, uint cursorNameL, bool scroll); //;\0 #define SQL_ENDsL(paramCounter) (2+(*paramCounter%10)*2+(*paramCounter/10%10)*3+(*paramCounter/100%10)*4) #define SQL_ENDs(start) (*(start++)=';',*(start++)='\0',start) #endif //DBOBJ_SQL_H /* * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */