Beispiel #1
0
// 插入一个城市信息,并返回插入的id
int city_insert( City *pCity )
{
	if ( pCity == NULL )
		return -1;
	char szSQL[2048];
	char reconnect_flag = 0;
RE_CITY_INSERT:
	sprintf( szSQL, "INSERT INTO `city` SET `laird_type`='%d',`laird_actorid`='%d',`laird_name`='%s',`laird_shape`='%d',`aclass`='%d',`posx`='%d',`posy`='%d' ",
		pCity->laird_type, pCity->laird_actorid, pCity->laird_name, pCity->laird_shape, pCity->aclass, pCity->posx, pCity->posy );
	if ( mysql_query( myGame, szSQL ) )
	{
		printf( "Query failed (%s)\n", mysql_error( myGame ) );
		write_gamelog( "%s", szSQL );
		if ( reconnect_flag )
			return -1;
		if ( mysql_ping( myGame ) != 0 )
		{
			db_reconnect_game();
			reconnect_flag = 1;
			goto RE_CITY_INSERT;
		}
		return -1;
	}
	return (int)mysql_insert_id( myGame );
}
Beispiel #2
0
void NewtBlackList(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uBlackList FROM tBlackList\
				WHERE uBlackList=%u"
							,uBlackList);
	macro_mySQLRunAndStore(res);
	i=mysql_num_rows(res);

	if(i) 
		//tBlackList("<blink>Record already exists");
		tBlackList(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tBlackList();
	//sprintf(gcQuery,"New record %u added");
	uBlackList=mysql_insert_id(&gMysql);
	uCreatedDate=luGetCreatedDate("tBlackList",uBlackList);
	unxsMailLog(uBlackList,"tBlackList","New");

	if(!uMode)
	{
	sprintf(gcQuery,LANG_NBR_NEWRECADDED,uBlackList);
	tBlackList(gcQuery);
	}

}//NewtBlackList(unsigned uMode)
Beispiel #3
0
int _oph_odb_update_folder_table(ophidiadb * oDB, char *folder_name, int *id_folder, pthread_mutex_t * flag)
{
	if (!oDB || !folder_name || !id_folder) {
		pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Null input parameter\n");
		return OPH_ODB_NULL_PARAM;
	}

	if (oph_odb_check_connection_to_ophidiadb(oDB)) {
		pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Unable to reconnect to OphidiaDB.\n");
		return OPH_ODB_MYSQL_ERROR;
	}

	char insertQuery[MYSQL_BUFLEN];
	int n = snprintf(insertQuery, MYSQL_BUFLEN, MYSQL_QUERY_UPDATE_OPHIDIADB_SESSION_FOLDER, folder_name);

	if (n >= MYSQL_BUFLEN) {
		pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Size of query exceed query limit.\n");
		return OPH_ODB_STR_BUFF_OVERFLOW;
	}

	if (mysql_query(oDB->conn, insertQuery)) {
		pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "MySQL query error: %s\n", mysql_error(oDB->conn));
		return OPH_ODB_MYSQL_ERROR;
	}

	if (!(*id_folder = mysql_insert_id(oDB->conn))) {
		pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Unable to find last inserted folder id\n");
		return OPH_ODB_TOO_MANY_ROWS;
	}

	return OPH_ODB_SUCCESS;
}
Beispiel #4
0
bool DBConn::ProcessNoResultQuery(const char* query, unsigned long long* autoIncrementId)
{
    DebugLog("%s", query);
    
    if (0 != mysql_query(_conn, query))
    {
        MysqlErrorLog("could not excute query");
        return false;
    }
    
    if (NULL != autoIncrementId)
    {
        *autoIncrementId = mysql_insert_id(_conn);
    }
    
    if (mysql_field_count(_conn) == 0)
    {
        //DebugLog("%lu rows affected", (unsigned long)mysql_affected_rows(_conn));
        return true;
    }
    else
    {
        MysqlErrorLog("could not retrieve result set");
        return false;
    }
}
Beispiel #5
0
	int DBTools::insertPoint(INOUT Point3D& point)
	{
		Point3D pTemp = point;
		int pointid = getIdByPoint(pTemp);
		if( pointid == 0)
		{
			std::stringstream ss_x;
			std::stringstream ss_y;
			std::stringstream ss_z; 
			ss_x.precision(9);
		    ss_y.precision(9);
		    ss_z.precision(9);
			ss_x<<floatToInt(pTemp.getLatitude());
			ss_y<<floatToInt(pTemp.getLongitude());
			
			if(pTemp.getAltitude()>0)
			    ss_z<<floatToInt(pTemp.getAltitude());
			else
				ss_z<<0;

			std::string sql="insert into point(x,y,z) values("+ss_x.str()+"," + ss_y.str() + " ," + ss_z.str()+ ");";
			mysql_query(&myCont,sql.c_str());
			 //std::cout<<ss_x.str()<<std::endl;
			pointid = mysql_insert_id(&myCont);//get last inserted id.
			pTemp.setId(pointid);
			point = pTemp;
		}
		point.setId(pointid);
		return pointid;
	}
Beispiel #6
0
void NewtGroupGlue(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uGroupGlue FROM tGroupGlue WHERE uGroupGlue=%u",uGroupGlue);
	MYSQL_RUN_STORE(res);
	i=mysql_num_rows(res);

	if(i) 
		//tGroupGlue("<blink>Record already exists");
		tGroupGlue(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tGroupGlue();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uGroupGlue=mysql_insert_id(&gMysql);

	if(!uMode)
	{
		sprintf(gcQuery,LANG_NBR_NEWRECADDED,uGroupGlue);
		tGroupGlue(gcQuery);
	}

}//NewtGroupGlue(unsigned uMode)
/** 
 * Create a new client with a random login-token
 *
 * the token is a 40-byte string representation
 * of a SHA1 hash generated by an SQL query on
 * some random values and the IP-address 
 * concatenated.
 *
 * addr should be the clients IP-address
 **/
struct client*
nol_s_client_create(const char *addr, const char *user)
{
    struct client* cl;
    time_t now;
    int    a, x;
    char  *p;
    char   q[128];
    int    qlen;

    MYSQL_RES *res;
    MYSQL_ROW *row;

    if ((cl = calloc(1, sizeof(struct client)))) {
        if ((cl->addr.s_addr = inet_addr(addr)) == (in_addr_t)-1
                || !(cl->user = strdup(user))) {
            syslog(LOG_ERR, "invalid address/user");
            free(cl);
            return 0;
        }
        qlen = sprintf(q,
                "SELECT SHA1(CONCAT(CONCAT(CONCAT('%s', NOW()), RAND()), RAND()))",
                addr);
        if (mysql_real_query(srv.mysql, q, qlen) != 0
                || !(res = mysql_store_result(srv.mysql))
                || !(mysql_num_rows(res))
                || !(row = mysql_fetch_row(res))
                ) {
            free(cl);
            return 0;
        }
        if (row[0])
            memcpy(cl->token, row[0], 40);
        else
            return 0;
        cl->token[40] = (char)0;

        mysql_free_result(res);

        /** 
         * add the client to the _client table which will give us an 
         * integer identifier to be used when adding URLs to the log
         * and save target urls
         **/
        qlen = sprintf(q,
                "INSERT INTO nol_client (token) VALUES ('%.40s');",
                cl->token);
        if (mysql_real_query(srv.mysql, q, qlen) != 0) {
            free(cl);
            return 0;
        }
        cl->id = (long)mysql_insert_id(srv.mysql);
        cl->session_id = 0;

        syslog(LOG_INFO,"new client %d:'%.6s...' from %s",
                (int)cl->id, cl->token, addr);
    }

    return cl;
}
Beispiel #8
0
int PlatDbConn::exec_update(const char* sql,
                           int& last_insert_id, int& affected_rows)
{
    if(conn_flag_ == 0)
    {
        int ret = connect();
        if(ret != 0)
        {
            return ret;
        }
    }
    
    if (mysql_real_query(&mysql_, sql, strlen(sql)) != 0)
    {
        snprintf(err_msg_, sizeof(err_msg_), "PlatDbConn mysql_real_query failed:%d,%s",
            mysql_errno(&mysql_), mysql_error(&mysql_));
        //svr gone or lost connection
        if(CR_SERVER_GONE_ERROR==mysql_errno(&mysql_)
            || CR_SERVER_LOST==mysql_errno(&mysql_)
        )
        {
            disconnect(); //清理,便于下次重连
            return -1;
        }
        
        return mysql_errno(&mysql_);
    }
    
    last_insert_id = (int)mysql_insert_id(&mysql_);
    affected_rows = (int)mysql_affected_rows(&mysql_);

    return 0;
}
Beispiel #9
0
void NewtProject(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;
	char gcQuery[128];

	sprintf(gcQuery,"SELECT uProject FROM tProject WHERE uProject=%u",uProject);
	macro_mySQLRunAndStore(res);
	i=mysql_num_rows(res);

	if(i) 
		//tProject("<blink>Record already exists");
		tProject(LANG_NBR_RECEXISTS);

	Insert_tProject();
	//sprintf(gcQuery,"New record %u added");
	uProject=mysql_insert_id(&gMysql);
	uCreatedDate=luGetCreatedDate("tProject",uProject);
	unxsRADLog(uProject,"tProject","New");

	if(!uMode)
	{
		sprintf(gcQuery,LANG_NBR_NEWRECADDED,uProject);
		tProject(gcQuery);
	}

}//NewtProject(unsigned uMode)
Beispiel #10
0
void NewtMonth(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uMonth FROM tMonth\
				WHERE uMonth=%u"
							,uMonth);
	macro_mySQLRunAndStore(res);
	i=mysql_num_rows(res);

	if(i) 
		//tMonth("<blink>Record already exists");
		tMonth(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tMonth();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uMonth=mysql_insert_id(&gMysql);
#ifdef ISM3FIELDS
	uCreatedDate=luGetCreatedDate("tMonth",uMonth);
	unxsSPSLog(uMonth,"tMonth","New");
#endif

	if(!uMode)
	{
	sprintf(gcQuery,LANG_NBR_NEWRECADDED,uMonth);
	tMonth(gcQuery);
	}

}//NewtMonth(unsigned uMode)
Beispiel #11
0
void NewtNAS(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uNAS FROM tNAS WHERE uNAS=%u",uNAS);
	macro_mySQLRunAndStore(res);
	i=mysql_num_rows(res);

	if(i) 
		//tNAS("<blink>Record already exists");
		tNAS(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tNAS();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uNAS=mysql_insert_id(&gMysql);
	uCreatedDate=luGetCreatedDate("tNAS",uNAS);
	unxsRadiusLog(uNAS,"tNAS","New");

	if(!uMode)
	{
		sprintf(gcQuery,LANG_NBR_NEWRECADDED,uNAS);
		tNAS(gcQuery);
	}

}//NewtNAS(unsigned uMode)
			IResult<MYSQL_RES>* ImplMySQLConnection::Execute(
				unsigned long long* r_uint64Newid/*=0 */ 
				)
			{
				int r=mysql_query(_lpMysql,_strSQL);
				//int res=mysql_real_query(_lpMysql,_lpCharSQL,100);
				if(0==r){
					if (0!=r_uint64Newid){
						*r_uint64Newid=mysql_insert_id(_lpMysql);
					}

					MYSQL_RES* lpRes=mysql_store_result(_lpMysql);
					_lpResultTemp->SetRes(lpRes);
					_lpResultTemp->SetErrorCode(0);
					return _lpResultTemp;
				}
				else{
					r=mysql_errno(_lpMysql);
					_lpResultTemp->SetRes(0);
					_lpResultTemp->SetErrorCode(r);
#if _DEBUG
					printf("%s \r\n",_strSQL);
					printf("ExecReturnNewId error code:%d \r\n",r);
#endif // _DEBUG
					return 0;
				}
			}
Beispiel #13
0
void NewtPBX(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uPBX FROM tPBX WHERE uPBX=%u",uPBX);
	macro_mySQLRunAndStore(res);
	i=mysql_num_rows(res);

	if(i) 
		tPBX(LANG_NBR_RECEXISTS);

	Insert_tPBX();
	uPBX=mysql_insert_id(&gMysql);
#ifdef StandardFields
	uCreatedDate=luGetCreatedDate("tPBX",uPBX);
#endif
	unxsSPSLog(uPBX,"tPBX","New");

	if(!uMode)
	{
		sprintf(gcQuery,LANG_NBR_NEWRECADDED,uPBX);
		tPBX(gcQuery);
	}

}//NewtPBX(unsigned uMode)
Beispiel #14
0
int vt_execute(VT_CONN *conn, const char *stmt_str, unsigned long length, int stream) {
  mysql_thread_init();
  clear_result(conn);

  if(mysql_real_query(conn->mysql, stmt_str, length) != 0) {
    return 1;
  }

  if(stream) {
    conn->result = mysql_use_result(conn->mysql);
  } else {
    conn->result = mysql_store_result(conn->mysql);
    conn->affected_rows = mysql_affected_rows(conn->mysql);
  }
  if(conn->result == 0) {
    if(mysql_errno(conn->mysql) != 0) {
      return 1;
    }
    conn->insert_id = mysql_insert_id(conn->mysql);
  } else {
    conn->num_fields = mysql_num_fields(conn->result);
    conn->fields =  mysql_fetch_fields(conn->result);
  }
  return 0;
}
Beispiel #15
0
void NewtConfig(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uConfig FROM tConfig\
				WHERE uConfig=%u"
							,uConfig);
	mysql_query(&gMysql,gcQuery);
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	res=mysql_store_result(&gMysql);
	i=mysql_num_rows(res);

	if(i) 
		//tConfig("<blink>Record already exists");
		tConfig(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tConfig();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uConfig=mysql_insert_id(&gMysql);
#ifdef ISM3FIELDS
	uCreatedDate=luGetCreatedDate("tConfig",uConfig);
	unxsISPLog(uConfig,"tConfig","New");
#endif

	if(!uMode)
	{
	sprintf(gcQuery,LANG_NBR_NEWRECADDED,uConfig);
	tConfig(gcQuery);
	}

}//NewtConfig(unsigned uMode)
Beispiel #16
0
	int MysqlForLua::_LastInsertId(lua_State* L){
		// prepare args
		if(lua_gettop(L) < 1){
			lua_pushnil(L);
			lua_pushstring(L, "missing arg");
			return 2;
		}
		// self
		MysqlForLua* self =0;
		if(!get_object_from_lua< MysqlForLua >(L, 1, self) || !self){
			lua_pushnil(L);
			lua_pushstring(L, "not a valid MysqlForLua Object");
			return 2;
		}
		//// check
		if(!self->m_mysql){
			lua_pushnil(L);
			lua_pushstring(L, "mysql not connected");
			return 2;
		}
		// get insert id
		int64_t id =mysql_insert_id(self->m_mysql);
		lua_pushnumber(L, (float64_t)id);
		return 1;
	}
Beispiel #17
0
int64 CSql::insertId(void)
{
	if ( m_hSql == NULL )
		return 0;

	return mysql_insert_id( m_hSql );
}
Beispiel #18
0
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query.
uint64 Sql_LastInsertId(Sql* self)
{
	if( self )
		return (uint64)mysql_insert_id(&self->handle);
	else
		return 0;
}
Beispiel #19
0
/*! @brief Insert data to table

	@param[in]		conn	context responced by std_db_open
    @param[in]		table	table name
    @param[in]		data	write data generated by std_db_data()
    @return         Success:primary key
******************************************************************************/
my_ulonglong std_db_write(MYSQL *conn,const char *table,GHashTable *data){
	GHashTableIter iter;
	apr_pool_t *pool=NULL;
	g_hash_table_iter_init(&iter,data);
	dbData *val;
	char *key,*keys,*vals;

	apr_pool_create(&pool,NULL);
	keys="";
	vals="";
	while(g_hash_table_iter_next(&iter,(gpointer*)(void*)&key,(gpointer*)(void*)&val)){
		keys=apr_psprintf(pool,"%s`%s`,",keys,key);
		if(val->type==D_TYPE_INT){
			vals=apr_psprintf(pool,"%s%s,",vals,val->data);
		}else{
			vals=apr_psprintf(pool,"%s'%s',",vals,val->data);
		}
	}
	keys[strlen(keys)-1]='\0';
	vals[strlen(vals)-1]='\0';
	char *sql=apr_psprintf(pool,"INSERT INTO %s(%s) VALUES(%s)",table,keys,vals);
	if (mysql_query(conn,sql)) {
		fprintf(stderr, "%s\n", mysql_error(conn));
		fprintf(stderr, "SQL:%s\n", sql);
		exit(1);
	}
	apr_pool_destroy(pool);
	return mysql_insert_id(conn);
}
Beispiel #20
0
void NewtGlossary(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uGlossary FROM tGlossary WHERE uGlossary=%u",uGlossary);
	MYSQL_RUN_STORE(res);
	i=mysql_num_rows(res);

	if(i) 
		//tGlossary("<blink>Record already exists");
		tGlossary(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tGlossary();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uGlossary=mysql_insert_id(&gMysql);
	uCreatedDate=luGetCreatedDate("tGlossary",uGlossary);
	unxsVZLog(uGlossary,"tGlossary","New");

	if(!uMode)
	{
		sprintf(gcQuery,LANG_NBR_NEWRECADDED,uGlossary);
		tGlossary(gcQuery);
	}

}//NewtGlossary(unsigned uMode)
Beispiel #21
0
void NewtTemplateSet(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uTemplateSet FROM tTemplateSet\
				WHERE uTemplateSet=%u"
							,uTemplateSet);
	mysql_query(&gMysql,gcQuery);
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	res=mysql_store_result(&gMysql);
	i=mysql_num_rows(res);

	if(i) 
		//tTemplateSet("<blink>Record already exists");
		tTemplateSet(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tTemplateSet();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uTemplateSet=mysql_insert_id(&gMysql);
#ifdef ISM3FIELDS
	uCreatedDate=luGetCreatedDate("tTemplateSet",uTemplateSet);
	unxsBlogLog(uTemplateSet,"tTemplateSet","New");
#endif

	if(!uMode)
	{
	sprintf(gcQuery,LANG_NBR_NEWRECADDED,uTemplateSet);
	tTemplateSet(gcQuery);
	}

}//NewtTemplateSet(unsigned uMode)
Beispiel #22
0
int
cmyth_mythtv_remove_previos_recorded(cmyth_database_t db,char *query)
{
	MYSQL_RES *res=NULL;
	char N_query[128];
	int rows;

	if(cmyth_db_check_connection(db) != 0)
	{
               cmyth_dbg(CMYTH_DBG_ERROR, "%s: cmyth_db_check_connection failed\n",
                           __FUNCTION__);
               fprintf(stderr,"%s: cmyth_db_check_connection failed\n", __FUNCTION__);
	       return -1;
	}

	mysql_real_escape_string(db->mysql,N_query,query,strlen(query)); 

        if(mysql_query(db->mysql,query)) {
                 cmyth_dbg(CMYTH_DBG_ERROR, "%s: mysql_query() Failed: %s\n", 
                           __FUNCTION__, mysql_error(db->mysql));
		return -1;
       	}
	res = mysql_store_result(db->mysql);
	rows=mysql_insert_id(db->mysql);
	if (rows <=0) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: mysql_query() Failed: %s\n", 
			__FUNCTION__, mysql_error(db->mysql));
	}

	return rows;
}
Beispiel #23
0
void NewtRequest(unsigned uMode)
{
	register int i=0;
	MYSQL_RES *res;

	sprintf(gcQuery,"SELECT uRequest FROM tRequest\
				WHERE uRequest=%u"
							,uRequest);
	mysql_query(&gMysql,gcQuery);
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	res=mysql_store_result(&gMysql);
	i=mysql_num_rows(res);

	if(i) 
		//tRequest("<blink>Record already exists");
		tRequest(LANG_NBR_RECEXISTS);

	//insert query
	Insert_tRequest();
	if(mysql_errno(&gMysql)) htmlPlainTextError(mysql_error(&gMysql));
	//sprintf(gcQuery,"New record %u added");
	uRequest=mysql_insert_id(&gMysql);

	uCreatedDate=luGetCreatedDate("tRequest",uRequest);
	unxsMailLog(uRequest,"tRequest","New");


	if(!uMode)
	{
	sprintf(gcQuery,LANG_NBR_NEWRECADDED,uRequest);
	tRequest(gcQuery);
	}

}//NewtRequest(unsigned uMode)
Beispiel #24
0
long long ObjectsTable::createObject(long lot) {
    std::stringstream str;
    str << "INSERT INTO `luni`.`objects` (`objectid`, `template`) VALUES(NULL, '" << lot << "');";
    Database::Query(str.str());
    long long objid = mysql_insert_id(Database::getConnection());
    return objid;
}
Beispiel #25
0
/* {{{ pdo_mysql_last_insert_id */
static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *len)
{
	pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
	char *id = php_pdo_int64_to_str(mysql_insert_id(H->server));
	PDO_DBG_ENTER("pdo_mysql_last_insert_id");
	*len = strlen(id);
	PDO_DBG_RETURN(id);
}
Beispiel #26
0
DLLEXPORT
unsigned int
clsql_mysql_insert_id (MYSQL* mysql, unsigned int* pHigh32)
{
  my_ulonglong insert_id = mysql_insert_id (mysql);
  *pHigh32 = upper_32bits(insert_id);
  return lower_32bits(insert_id);
}
Beispiel #27
0
int
dbow_insertid(dbow_conn *conn)
{
#ifdef DBOW_MYSQL
	return(mysql_insert_id(conn->dbconn));
#endif
	return(0);
}
Beispiel #28
0
uint64_t Command::GetInsertId()
{
	if (!m_conn->IsConnected()) {
		// ERROR:
		return 0;
	}
	return mysql_insert_id(&m_conn->m_mysql);
}
Beispiel #29
0
/**
 * Returns the last inserted ID.
 * \param _h database handle
 * \return returns the ID as integer or returns 0 if the previous statement
 * does not use an AUTO_INCREMENT value.
 */
int db_last_inserted_id(const db1_con_t* _h)
{
	if (!_h) {
		LM_ERR("invalid parameter value\n");
		return -1;
	}
	return mysql_insert_id(CON_CONNECTION(_h));
}
Beispiel #30
0
            long long session::last_insert_id() const
            {
                if (db_ == nullptr) {
                    return 0;
                }

                return mysql_insert_id(db_.get());
            }