void
ExportAsSimpleSQL::AddColumnNames(ExportSQLData *data, wyString &value)
{
	wyInt32 count;

	value.Add("(");

	for(count = 0; count < m_myres->field_count; count++)
    {
		if(data->m_selcol[count] == wyTrue)
			value.AddSprintf("`%s`, ", m_myres->fields[count].name);
    }

	value.Strip(2); // Strip one for ',' and one for blank space
	value.Add(") ");
}
Пример #2
0
// Function to get the path the selected item in a  Treeview //
wyBool 
FavoriteBase::SelItemPath(HWND htree, HTREEITEM  item, wyString &fullpath, wyBool bFileFlag)
{	
	wyWChar		data[MAX_PATH + 1] = {0};
	wyWChar		foldpath[MAX_PATH + 1] = {0};
	TVITEM		tvitem;
	wyString	path, temp, temp2, datastr, foldpathstr;
	
	// application data path //
	if(!pGlobals->m_configdirpath.GetLength())
	{
		if(!SUCCEEDED(::SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, foldpath)))
			return OnError(_("Error in favorites"));

		wcscat(foldpath ,L"\\SQLyog");
	}

	else
	{
		//wcscpy(foldpath, pGlobals->m_configdirpath.GetAsWideChar());
		wcsncpy(foldpath, pGlobals->m_configdirpath.GetAsWideChar(), MAX_PATH);
		foldpath[MAX_PATH] = '\0';
	}
	
	while(item)
	{
		tvitem.mask		  = TVIF_TEXT | TVIF_IMAGE;
		tvitem.hItem	  = item;
		tvitem.cchTextMax = MAX_PATH;
		tvitem.pszText	  = data ;

		TreeView_GetItem(htree, &tvitem);
		datastr.SetAs(data);
		if(tvitem.iImage != NFILE || !bFileFlag)
        {
			temp.Sprintf("\\%s", datastr.GetString());
            if(path.GetLength() > 0)
            {
                temp2.SetAs(path);
				path.Sprintf("\\%s%s", datastr.GetString(), temp2.GetString());
            }
            else
				path.Sprintf("\\%s", datastr.GetString());
        }
		
		item = TreeView_GetParent(htree, item);
	}
	
	foldpathstr.SetAs(foldpath);
	fullpath.SetAs(foldpathstr.GetString());
	fullpath.Add(path.GetString());

    return wyTrue;
}
Пример #3
0
void
EditorBase::AddNonResultMsg (Tunnel * tunnel, PMYSQL mysql, wyString& errorormsg, wyUInt32 timetaken )
{
	wyUInt32		rowsret;
	wyString		newmsg;

	rowsret		=	(wyUInt32)tunnel->mysql_affected_rows(*mysql);

	VERIFY(newmsg.Sprintf(_("(%lu row(s) affected)\n(%lu ms taken)\n\n"), rowsret, timetaken ) < SIZE_1024);

	errorormsg.Add(newmsg.GetString());
	
	return;
}
Пример #4
0
// Function to create a favorite file or folder in the given path //
wyBool 
FavoriteBase::InsertFavoriteItem(wyString &path, wyBool isfolder , wyString &favquery)
{	
	DWORD				byteswritten;
	HANDLE				hfile;
	//const unsigned char utf8bom[10] = {unsigned char(0xEF), unsigned char(0xBB), unsigned char(0xBF)};
			
	// if the favorite is file type then add the extension//
	if(!isfolder)
	{
		path.Add(".sql");

        hfile = ::CreateFile(path.GetAsWideChar(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
								   NULL, NULL);

		if(hfile  == INVALID_HANDLE_VALUE)
		{
            if(::GetLastError() == ERROR_FILE_EXISTS)
			{
                if(::MessageBox(NULL, _(L"The name you have entered for the shortcut already exists in Favorites menu.\nWould you like to overwrite it?"), _(L"Add Favorite"), MB_YESNO | MB_TASKMODAL | MB_ICONINFORMATION | MB_DEFBUTTON2) == IDYES)
				{
                    hfile = ::CreateFile(path.GetAsWideChar(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, NULL, NULL);
					
					if(hfile  == INVALID_HANDLE_VALUE)
                         OnError(_("Cannot write into Favorite File"));
				}
				else
					return wyFalse;			
			}
			else
			    return OnError(_("Cannot write into Favorite File"));
		}
		
		//if (!::WriteFile(hfile,  utf8bom, 3, &byteswritten , NULL))
		//	return OnError("Cannot write into Favorite File");

        if (!::WriteFile(hfile,  favquery.GetString(), favquery.GetLength(), &byteswritten , NULL))
			return OnError(_("Cannot write into Favorite File"));

        ::CloseHandle(hfile);
	}
    else if(!::CreateDirectory(path.GetAsWideChar(), NULL))
	  return OnError(_("Cannot create Favorite Folder"));
	
    return wyTrue;
}
Пример #5
0
void
EditorBase::AddErrorMsg(Tunnel * tunnel, PMYSQL mysql, wyString& errorormsg, wyUInt32 timetaken)
{
	wyUInt32     errnum;
	wyString	 newerror;

	errnum = tunnel->mysql_errno(*mysql);

	/* it may happen that due to http error the errornumber is 0 so we return */
	if(0 == errnum)
		return;

	VERIFY(newerror.Sprintf(_("Error Code: %d\n%s\n(%lu ms taken)\n\n"), errnum, tunnel->mysql_error(*mysql), timetaken) < SIZE_1024);

	errorormsg.Add(newerror.GetString());
	
	return;
}
// Function creates a text buffer with all the properties and sends newly allocated buffer.
wyBool
TableMakerAdvProperties::GetAdvPropString( Tunnel *tunnel, PMYSQL mysql,
        TableAdvPropValues* ptav, wyString& str)
{
    wyBool ismysql41 = IsMySQL41(tunnel, mysql);

    if(ptav->m_changed == wyFalse)
        return wyFalse;

    /* 	nCount += sprintf( szQuery+nCount, " ,type=%s ", ptav->szType );
    	This comma is not required, this is required in the alter stmt when this
    	stmt is not the first one. So we are checking it in the query builder
    	In the latest versions we need 'Engine' in place of 'Type'
    */
    if(ptav->m_type.GetLength())
    {
        if(ismysql41 == wyTrue)
            str.AddSprintf(" Engine=%s ", ptav->m_type.GetString());
        else
            str.AddSprintf(" Type=%s ", ptav->m_type.GetString());
    }

    if(ptav->m_checksum.CompareI(STR_DEFAULT) != 0)
        str.AddSprintf("checksum=%s ", ptav->m_checksum.GetString());

    if(ptav->m_auto_incr.GetLength())
        str.AddSprintf("auto_increment=%s ", ptav->m_auto_incr.GetString());

    if(ptav->m_avg_row.GetLength())
        str.AddSprintf("avg_row_length=%s ", ptav->m_avg_row.GetString());

    if(ptav->m_comment.GetLength())
        str.AddSprintf("comment='%s' ", ptav->m_comment.GetString());
    else
        str.Add("comment='' ");

    if(ptav->m_max_rows.GetLength())
        str.AddSprintf("max_rows=%s ", ptav->m_max_rows.GetString());

    if(ptav->m_min_rows.GetLength())
        str.AddSprintf("min_rows=%s ", ptav->m_min_rows.GetString());

    if(ptav->m_delay.CompareI(STR_DEFAULT) != 0)
        str.AddSprintf("delay_key_write=%s ", ptav->m_delay.GetString());

    if(ptav->m_rowformat.GetLength())
        str.AddSprintf("row_format=%s ", ptav->m_rowformat.GetString());

    if(ptav->m_chunks.GetLength())
        str.AddSprintf("raid_chunks=%s ", ptav->m_chunks.GetString());

    if(ptav->m_chunksize.GetLength())
        str.AddSprintf("raid_chunksize=%s ", ptav->m_chunksize.GetString());

    if(ismysql41 == wyTrue)
    {
        if(ptav->m_charset.GetLength() && ptav->m_charset.Compare(STR_DEFAULT) != 0)
            str.AddSprintf("charset=%s ", ptav->m_charset.GetString());

        if(ptav->m_collation.GetLength() && ptav->m_collation.Compare(STR_DEFAULT) != 0)
            str.AddSprintf("collate=%s ", ptav->m_collation.GetString());
    }

    return wyTrue;
}