I have written an app in PHP which outputs (and receives) RSS feeds.
I want to get the app to email when there is a new item in one of the feeds.
I am looking for an easy way for me to do this without storing contents on a database. Is there a script that does that? If not how is the best way of doing this?
I thought about storing the latest items for each feed in separate text files and marking them as sent when the email was sent. It seems a bit clunky, but might work. I am not sure of the best way to format the text file.
Any ideas would be appreciated.
I know that you're opposed to using a database, but not opposed to storing data in files. Perhaps you wouldn't mind using a database like SQLite.
SQLite databases are stored (and accessed) in files, it doesn't require any installation or a database server, just the file system. Read the linked page above.
It would be more efficient than just flat text files, and take you less time to set up. For a small simple application this could be the right solution.
You should use PDO as the database driver in PHP (not the SQLite class). It's enabled by default on most systems and won't require any edits to php.ini. Using PDO also makes it very easy if you want to switch to a MySQL (or other) database later.
From the installation manual:
PDO and the PDO_SQLITE driver is enabled by default as of PHP 5.1.0.
If the user has less than PHP 5.1 installed, then your script will probably be broken in another way. I find that most common users have 5.3.x.
Related
So I want to build an extension, where you can export the data via php to excel or something similar. Since I'm planning to distribute it, until now not sure if public or just to my close web-dev-friends, it wouldn't be a good idea to connect to the DB by typing in my credentials directly.
Is there a way to import them from the LocalConfiguration.php file? In this way, it will also always work on other installations of T3.
Another or even a better way would be the T3-API, were I did only understand train-station (German proverb). T3-API sounds like C3-POs best friend, though.
You might have noticed that I'm quite new to php and file-generation is maybe a little big task to set oneself. But without challenge, it wouldn't be fun, right?
Environment: TYPO3 7.4.0 // MySQL 5.5.46 // PHP Version 5.6.14
You should use the TYPO3 database connection, which is available in the variable $GLOBALS['TYPO3_DB'] (not sure if there is a better way in newer TYPO3 versions). This connection is automatically created from the database info in LocalConfiguration.php.
The variable is of type \TYPO3\CMS\Core\Database\DatabaseConnection, the API documentation can be found here.
I have not found a library that handles exporting data and structure to SQL. - there are a number of snippets and so on for data only. Exporting structure seems quite a bit more complicated. It must be able to do this without command-line access.
Many of the descriptions I've found online are quite old, so perhaps MySQL has new features that handle this? Or perhaps there are now libraries which do this? (Or perhaps PHPMyAdmin has a self-contained class or set of functions I could hijack?)
You could try this: Sypex Dumper
I used it for a long time with Joomla on XAMPP, very light weight and functional.
You can simply use it standalone or integrate to your application.
This class suited my needs
https://github.com/2createStudio/shuttle-export
You can see several examples in the documentation. The only flaw is that this class don't have the force download option (it always generate the file in disk). I was willing to make a pull request, but there's one push request dating from 6 months ago and the mantainer didn't give a dam.
I have a small mySQL database and a few simple php based webpages that query the database, generate html tables and present them in the browser. The database is no longer being updated. So, searching and viewing subsets of the data is all that is required.
Some users are interested in distributing the searchable database on a cd or usb memory stick. SQLite seems to offer the answer, but I don't understand what is needed to make this work. What will be required to make a web browser based "app" work from a memory stick in the absence of a server like xampp?
XAMPP Lite from http://portableapps.com/apps/development/xampp
What you want is called a "standalone server". This is very common in almost every other modern language except PHP, for some reason. Googling "standalone php server" reveals several options:
QuickPHP
Nanoweb
Server2Go
My project is a collection of PHP scripts using MySQL as a database and needs to be installed locally using WAMP/LAMP/MAMP.
Previously I've been sending the users a link to a zipped archive and having them overwrite it, but since I took the plunge to GitHub, I've realized that there are far better ways; namely Service Hooks in GitHub. However, this would work fine as long as I don't alter the database in any way, which is a good possibility.
I've been toying with the idea of how I would implement this, but I can't find a clear solution. So far I've concluded with that I need to have a directory (say update/) which contains .sql files for each update. The PHP script will then check said directory for a file corresponding with the new version number (not sure how I will define a version number; I was thinking of using the commit ID, but that won't be available until after the commit, so...).
I would love some input on this!
Here's how I would tackle this (not the most elegant or performant):
Add a flag in the DB with a version number
Add a min-version number in your DB layer PHP file
Check that the DB version is greater than the min-version
If it is: continue about your business
Else: Run the PHP file in update/ which would have a series of ALTER TABLE commands to be run on the DB server
Update the min-version number in the DB to the latest number
All done
Alternately instead of querying the DB you can have a file which is generated by your DB interface PHP file (and ignored with .gitignore) which you can just as above.
I would really recommend checking out Doctrine and its migration feature.
This does exactly what you are looking for, plus you get a very nice tool for working with all other aspects of your database handling.
Is it possible to write .MDF files using PHP. I have a simple HTML table - x columns, y rows that I wish to convert into a MS Access dataset. There are no foreign keys or anything exotic, just a number of rows and columns.
I have Google searched but the only advice I seem to be able to find is to save it as a .CSV. Unfortunately this isn't acceptable for my client. They want to simply be able to double click the icon and have the database load up in Access (Seems you have to import csv files and can't just double click them).
Those are actually two different problems:
1) Parsing HTML to separate values
Since you seem to have found a way to export to csv, I won't be answering this. You already got your parser then.
2) Create an mdb file.
You can use odbc to talk to Access, that is, if you are in Windows. That means that PHP must be installed on a Windows machine. I'm not aware of any Linux drivers for Access..
You can use odbc_connect to connect to the database:
$conn = odbc_connect("dbname","" ,"");
From there, working with the database is pretty similar to MySQL as long as you use the ODBC functions.
The only problem is creating the actual MDB. This cannot be done in ODBC, you'll need the JET engine. It may be possible to create an MDB file from PHP, but it may be easier to create an empty MDB once, and copy that file from PHP whenever you need a new database.
Jackcess is a pure Java library for reading from and writing to MS Access databases. It is part of the OpenHMS project from Health Market Science, Inc. . It is not an application. There is no GUI. It's a library, intended for other developers to use to build Java applications.
http://jackcess.sourceforge.net/
But an MDF file is not a standard Access file extension. MDB and MDE are while MDW is for user level security.
Have not tested this but this might help you:
http://devzone.zend.com/article/4065
Note that active development of MDB Tools has moved from Sourceforge to Github
https://github.com/brianb/mdbtools