Пример #1
0
//function to execute SELECT * query
wyInt32
TableView::ExecuteTableData()
{
	wyString        query;
    wyInt32         ret;
    MySQLDataEx*    pdata;

    query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString());

    //get filter info
    GetFilterInfo(query);

    //get sort info
    GetSortInfo(query);

    //get limits
    GetLimits(query);

    //execut query
    m_mydata->m_datares = ExecuteQuery(query);

    //is thread stopped
	if(ThreadStopStatus())
	{	
        return TE_STOPPED;
	}

    //any error? show error dialog
	if(!m_mydata->m_datares)
	{
        return HandleErrors(query);
	}

    //allocate row array, if the thread is stopped, delete them
    if((ret = AllocateRowsExArray()) != TE_SUCCESS || 
        (ret = GetTableDetails()) != TE_SUCCESS)
    {
        pdata = ResetData(m_data);
        delete pdata;
        return ret;
    }

    //add new row in the end
    AddNewRow();

    return TE_SUCCESS;
}
Пример #2
0
//function to execute SELECT * query
wyInt32
TableView::ExecuteTableData()
{
	wyString        query;
    wyInt32         ret,extraindex,j=0,no_row;
    MySQLDataEx*    pdata;
	MYSQL_ROW        fieldrow;

    query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString());

    //get filter info
    GetFilterInfo(query);

    //get sort info
    GetSortInfo(query);

    //get limits
    GetLimits(query);

    //execut query
    m_mydata->m_datares = ExecuteQuery(query);

    //is thread stopped
	if(ThreadStopStatus())
	{	
        return TE_STOPPED;
	}

    //any error? show error dialog
	if(!m_mydata->m_datares)
	{
        return HandleErrors(query);
	}

    //allocate row array, if the thread is stopped, delete them
    if((ret = AllocateRowsExArray()) != TE_SUCCESS || 
        (ret = GetTableDetails()) != TE_SUCCESS)
    {
        pdata = ResetData(m_data);
        delete pdata;
        return ret;
    }
	extraindex = GetFieldIndex(m_wnd->m_tunnel, m_data->m_fieldres, "Extra");
	no_row = m_wnd->m_tunnel->mysql_num_rows(m_data->m_fieldres);
	m_data->m_colvirtual = (wyInt32*)calloc(no_row, sizeof(wyInt32));

	while(fieldrow = m_wnd->m_tunnel->mysql_fetch_row(m_data->m_fieldres)){

	if(!strstr(fieldrow[extraindex], "VIRTUAL") && !strstr(fieldrow[extraindex], "PERSISTENT") && !strstr(fieldrow[extraindex], "STORED"))
		{
			m_data->m_colvirtual[j++] = 0;
		}

		else 
		{
			m_data->m_colvirtual[j++] = 1;
		}
	
	}

    //add new row in the end
    AddNewRow();

    return TE_SUCCESS;
}