Hello,

I'm a C++ newbie with the following problem (I've used the search function but haven't come up with what I'm looking for. I'm not asking anyone to write this project for me, but a lot of good pointing/ideas is going to help me a lot):

I currently have a MySQL database that works as follows:

Table:Books
Publisher|Author|Book|MemorableQuote
------------------------------------
Data|Data|Data|Data|Data
....


I search this using PHP and I am able to search on ANY or NONE of the above fields using partial searches. In other words you can get as specific or general as you want. IE: If you input "That Guy" in the Author box on the php form it will look in the Author field of the DB and return everything with That Guy in the author section. If you input "a" in the author box and "it was the best of times" in the MemorableQuote section of the php form it will search for both, returning only results where both are present. All results display the entirety of the selected row matching the query. The search is *not* case sensative, and I like it just fine that way.

The database contains about 1500 rows, with all fields containing data, some fields being quite large (paragraphs). The search functionality is of paramoutn importance as it is the entire point of the project.

At present I'm accomplishing this quite well with a WIMP project (MySQL DB accessed through PHP via IIS on Windows). Obvisouly, this requires installing MySQL, PHP, and enabling IIS, and is clumsy as it's only to be accessed at the local computer. I'd like to be able to get the same functionality without installing all of this, ideally through a compiled program. In the future you will need to be able to "Check out" and "Edit" data from the database.

Your suggestions are appreciated. If clearification is needed please let me know.

Dani AI

Generated

A short, practical follow‑up to and : for a single‑machine, compiled app the priority should be the search UX and safe edits. Two valid routes exist — port your logic into a native executable, or embed a small SQL engine and call it from C++. If search speed/accuracy is the main feature, invest in a full‑text index rather than running many LIKE '%…%' scans.

Use a full‑text virtual table (FTS) to get fast, ranked, multi‑field searches and phrase/prefix support. FTS5 supports prefix queries and scoring; for purely arbitrary substring matches you’ll need an n‑gram tokenizer or accept slower LIKE queries. See the FTS5 docs for syntax and tokenizer options.

Example FTS schema and a simple MATCH query:

CREATE VIRTUAL TABLE docs_fts USING fts5(title, author, quote, tokenize='unicode61');

SELECT rowid, title
FROM docs_fts
WHERE docs_fts MATCH 'that guy*';

In C++, prefer prepared statements and a small wrapper to manage RAII and binding. Libraries like SQLiteCpp simplify common patterns and reduce boilerplate. Bind parameters, reuse prepared statements for repeated searches, and load full rows by rowid only when needed to keep queries fast.

For edits and check‑out: keep edits in transactions, use a LastModified or version column for optimistic locking, and keep transactions short. Enable WAL for better concurrency with PRAGMA journal_mode=WAL if writes and reads overlap. Use the backup API for safe copies and consider shipping the DB as a single file (link statically to the amalgamation or bundle the DLL) for zero‑install deployment.

Further reading: SQLite FTS5 reference (search features), WAL documentation (concurrency), and the SQLiteCpp project (simple C++ binding). These will guide implementation details and tradeoffs for a small, fast, local search/editor app.

Recommended Answers

All 3 Replies

I figured something out. SQLite and a C++. Thanks.

Convert your PHP code into C++ code. Compile the program. No need for anything but the database and C++ program then.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.