📄 faq.txt
字号:
-----------------------------------------------------------------------------
Document: TmySQL /DOCS/FAQ.TXT
Author: Justin P. Yunke <yunke@productivity.org>
Date: 02/10/2002
Version: 2.1b
Copyrights:
- Copyright (c) 1999, 2000, 2001 Justin P. Yunke <yunke@productivity.org>
[for other copyrights, please see the included *.pas files]
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Basic Information, Taken From the Website
-----------------------------------------------------------------------------
What does TmySQL do?
TmySQL provides access to MySQL servers from Delphi via a visual component
and an extendable non-visual component.
TmySQL utilizes a single client DLL, which is provided by most Windows-
compiled versions of MySQL.
TmySQL has both threaded (synchronous) and non-threaded (asynchronous)
modes.
TmySQL has a 'task queue' mechanism to 'send' multiple SQL statements
to the server in serial order.
What does TmySQL NOT do?
TmySQL does not use the database aware components in Delphi, such as
TDatabase, TQuery, etc.
TmySQL does not use BDE.
TmySQL does not use ODBC.
-----------------------------------------------------------------------------
1.0. Popular Questions
-----------------------------------------------------------------------------
1.1. What DLL is required for use with TmySQL?
libmysql.dll, which is available with most Windows-compiled versions
of mySQL. A copy from a recent compile is available with this
package.
1.2. When will Database-aware components be developed for TmySQL?
There are no plans to produce Database-aware components (like
TDatabase, TQuery, etc.).
1.3. Why can't I get TmySQL compiled/to work/etc.?
TmySQL is one of many projects in which the author involves himself.
Often, you may not get a response by e-mailing him directly. Please
try the Mailing List (http://www.elists.org/) or thoroughly study
the sample application, which was designed to test many of the
commonly-used features of TmySQL.
-----------------------------------------------------------------------------
2.0. TmySQL is not Database Aware, BDE, or ODBC compatible
-----------------------------------------------------------------------------
2.1. Why does TmySQL not use the plethora of Database-aware components?
Want a straight answer? The author thinks they suck. :)
2.2. Why doesn't TmySQL use BDE or ODBC?
The author has had a lot of bad experience keeping versions of BDE
or ODBC working without incompatibilities with other software on
the same computer.
TmySQL, with the included DLL, works on all versions of Windows 95,
Windows 98, Windows NT, Windows 2000, and even Linux under WINE,
without the headaches of the Borland BDE or Microsoft ODBC.
If you can dictate your client environment, you're probably safe
to use BDE or ODBC and can probably do better there.
2.3. But not using the built-in Database Components makes design very
unpleasant and seemingly manual...
Understood. The author has considered writing the components
to be compatible with and/or emulate the standard Database-Aware
components. However, due to interest in other projects, he
has abandoned this task.
Once you get the hang of writing a full-featured threaded
application with TmySQL, and notice how fast and efficient it is,
you may not go back. :)
-----------------------------------------------------------------------------
3.0. TmySQL's Threaded, Task-based Design
-----------------------------------------------------------------------------
3.1. When do I use threaded (synchronous) mode vs. non-threaded
(asynchronous) mode?
Simple rule of thumb: do you want your application to 'lock up'
during its use? When you execute a query, do you want the interface
to cease reacting to cursor movement/keyboard movement?
If you answered 'no' to that question, plan on writing your
application around TmySQL in the Threaded mode. Bear in mind,
however, making TmySQL handle things 'in the background' poses
another set of concerns.
For instance, if you have a TButton activate a query, you may
wish to disable that button after it is pressed and re-enable it
after the query has completed. This makes sure that the user
doesn't accidentally click the button more than once, out of
patience or lack of muscle coordination.
A major exception to this rule arises when you are calling
TmySQL from your own custom TThread. Since you're already
in a thread, turn off the Threaded mode in TmySQL.
All in all, TmySQL's Threaded mode will give your application an
appearance of intense speed (especially over dial-up or otherwise
slow connections). It also allows you to conduct large queries
in the background while the user/your software handles other
tasks.
3.2. What is the deal with the Tasks, like PrepareTask, etc.?
In order to submit multiple SQL statements into the background
for handling within a separate Windows thread, a task-based system
was designed.
For instance, consider an application that needs to load the
contents of four TListBox-es. Instead of having to design your
code around a 'piggyback' approach, i.e. when ListBox1 is
finished, load ListBox2, and when ListBox2 is finished, load
ListBox3, you can send all tasks to the 'task queue' for
completion all at once. They will be processed in sequential
order.
Obviously, if there are inter-dependencies with your queries,
you'll have to think through whether sending all of your tasks
to the queue at once is a wise idea.
Another reason for the 'Task' system is based on the idea that
you may _wish_ the user to be able to activate a new query while
another one is being worked on. An example: part of your
application has a very slow SQL statement due to the complexity
or amount of data handled. You may wish to allow your user to
click on a partial result of this SQL statement that calls
another one. Instead of forcing the user to wait, the Task
system throws the SQL statement onto the queue to be handled
once the first one is complete.
The author feels that the Task system is a good way to allow
asychronous use of TmySQL in a threaded environment.
From the sample application code, here is some helpful
documentation:
//
// Note: for large sequential activities (such as mass-inserts or updates),
// it is wise to use the NON-THREADED mode of TmySQL within your own custom
// TThread.
//
// Also, if you intend to do 'piggy back' tasks -- after a task finishing
// (OnComplete) you add a new task and Execute -- you may run into problems
// with TmySQL's TThread getting stuck in a suspended state. Instead of
// doing this, write your own TThread and call a NON-THREADED instance of
// TmySQL.
//
// The built-in THREADED mode of TmySQL is best used for interactive use
// of a mySQL database, as you'll see in the "Query Database" example.
//
3.3. I still don't understand how threading and tasks work.
Thoroughly investigate the sample application in the 'test'
directory, and specifically look at the source.
3.4. I've read the source and it still doesn't make any sense.
Ask your question on the TmySQL mailing list.
Of course, you also have the option to try out a different
package from the plethora of MySQL and Delphi resources on
the Internet.
-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -