This topic is locked
[SOLVED]

 SQLite database placement and configuration

10/10/2017 11:18:12 AM
PHPRunner General questions
J
justmelat author

Hi, I am working on application, that I want to turn into a standalone desktop app.
After reading through your forum, i found that for what I want/need to do, I should use sqlite, so the desktop application can retain it's data-driven ability.
I have sqlite working in phprunner, I created the desktop exe file, but when i download it, i receive an error msg: "Fatal Error, unable to open db file...". So obviously it can't find the db file, which I placed in the [output/source] folder. Where do I place and then reference the database, so when it is packaged up, all the user needs to do is install and run the application?

HJB 10/10/2017

... so, you would need to search within the web server root folder of the remote/local directory whether or not the relevant .SQL file is in existence ..., and if not, you would need to copy same to that place where the PHPRunner horse is starting its work. Since PHPRunner is NOT mainly focusing on SQLITE operations, but MySQL/MariaDB, requiring that MySQL/MariaDB is running, SQLITE is a file based database where, in simple terms, strings are saved unto the hard disk and recalled once needed. So, in this case, you need to manually copy the .SQL database file to the right root or subdirectory then. When you start to build the project, PHPRUNNER asks for the .SQL database location to get a connection before generating the code. If at that time, the .SQL database is OUTSIDE the final directory, the "... cannot open the DB file ..." is the logical result. By the way, I tested such things under SQLITE with a RAMDISK and need to tell you this: Fasten your seat belts ..., as the acceleration is breath-taking. HTH

Admin 10/10/2017

Show us a screenshot of your connection settings in PHPRunner.

J
justmelat author 10/11/2017



Show us a screenshot of your connection settings in PHPRunner.



HI Sergey, the connections setting that I see are show in the image below. Is this what u wanted to see, or do you want to see code in a particular file? if the later, which file? I see a "connections" file in the "output" folder and within it is a sqlite3connect.php file. do you want that? see attached: sqlite for standalone desktop app

Admin 10/11/2017

I don't need to see any code or any video. Just a full size screenshot of your connection settings in PHPRunner.

HJB 10/12/2017

... redo the project, connecting to the "sql_test_db" seen inside the WWW directory of the already project project this time (rather than to use same sql db outside the web area), that's all.

J
justmelat author 10/14/2017



... redo the project, connecting to the "sql_test_db" seen inside the WWW directory of the already project project this time (rather than to use same sql db outside the web area), that's all.



Could you look at the walk-thru video here: " Video PHP Runner Standalone Desktop App" the issue is - the www folder is not there until after u compile the application. I don't want the user to have to move a file, just download, execute and use.

HJB 10/14/2017



Could you look at the walk-thru video here: " Video PHP Runner Standalone Desktop App" the issue is - the www folder is not there until after u compile the application. I don't want the user to have to move a file, just download, execute and use.


Look, the sql.db at your end is locating in the c:\root ..., so, when you CONNECT to very same under PHPRunner, it (PHPR) is writing the connection details of the c:\root based sql.db into the generated code, and once you browse the generated code, using the PHPRunner built-in server, it looks all okay, simply because it's happening inside the PHPRunner server engine locally on your desktop, so, to find the necessary c:\root based sql.db is NO problem under PHPRunner built-in server, yet, when you compile things into .exe, the "old" server structure is no longer in existence as the "new" engine which is running the compiled stuff later on is a totally different server issue of what the PHPRunner built-in server is all about. To get it to work properly, I mean, to finally own a "unpack .exe, click and run" solution, the most simple way is to create the .exe first, then to unpack it locally to get exactly the PATH details to the WWW directory in which the sql.db should definitely be (not in connection subdirectory or else) and to then do the code generation AGAIN, using the WWW directory based sql.db for connection of your project. This way, PHPRunner would write the correct connection details into the scripts right from the beginning. This is NO mistake by PHPRUNNER at all, it has simply to do with the fact the .exe compilation was meant for MySQL/MariaDB database engines, both having its own separate directories either locally or remote, yet in this case, one has only a FILE (the sql.db) rather than a database engine as it is more likely nothing more or less than a FILE into which data is written or retrieved from, rather than a running MySQL/MariaDB server engine for which is .exe issue was designed under PHPRunner. Finally you can try to do this alternatively: Given, your app to be distributed would own the following PATH, i.e. c:\contacts along with WWW subdirectory in it, you can manually make such PATH on your local machine, then you copy your sql.db into the WWW folder then and once done, you connect via PHPRunner to that very sql.db then to build the .exe file. By doing so, the START and END directory would be the same, the PHPRunner based compilation code would then be able to llink to the "future location" of the SQ3lite DB then, once the unpacking of the .exe file is done.

Admin 10/17/2017

Once your project is ready proceed to 'Output directory' screen and create a new Server Database Connection. Put the following code there:

$dbname=getabspath("sqllite_users_db.db");


Build your project. Copy sqllite_users_db.db file to the output folder. Create a desktop app. Enjoy.
PS. If someone asks to post a simple connection settings screenshot do not make them watch your six minute video. This is simply not nice. Just post the screenshot.

J
justmelat author 10/19/2017



Once your project is ready proceed to 'Output directory' screen and create a new Server Database Connection. Put the following code there:

$dbname=getabspath("sqllite_users_db.db");


Build your project. Copy sqllite_users_db.db file to the output folder. Create a desktop app. Enjoy.
PS. If someone asks to post a simple connection settings screenshot do not make them watch your six minute video. This is simply not nice. Just post the screenshot.



Wow, that string suggestion is excellent.
Note: the reason i posted the excruciatingly long (6 min) video is after posting the initial connection string image, or what I thought was being requested, i had more questions, so I thought it would be easier to see all the steps in my process so it could be determined where I was going wrong.
again, thanks for the string getabspath suggestion

J
justmelat author 10/27/2017



Wow, that string suggestion is excellent.
Note: the reason i posted the excruciatingly long (6 min) video is after posting the initial connection string image, or what I thought was being requested, i had more questions, so I thought it would be easier to see all the steps in my process so it could be determined where I was going wrong.
again, thanks for the string getabspath suggestion



Worked perfectly, thank you.