Connecting to the database at each request can be expensive the solution to that could be using memcached. However i have been working on a php socket server that will be available in the background to fetch data from. This way on my php server i can fetch all the data i need and on the web request connect to it and retrieve the data without having to go through the data base.
I couldn't find any data on this so my question is how expensive is it to connect to my php server using sockets. Is there a down side to it?
Note: The php socket server is running on the same machine and will be able to serve multiple applications.
Related
I would like to access a local mysql database through my php script hosted on a remote server. Is there a way to code a script, that I save on the local mashine, and receives queries from my remote php script, executes, and the results are submitted back to the script?
How is this technology called?
I know, that I could just open the mysql port on my firewall, but I don't want to do that.
The technology is called AJAX.
Is it possible to me to read data from sqlite with php and send it with php script to another server?
Ex: I have a "Local sqlite" database, i have a web. Basically i want someone can see some prefered content at my "Local sqlite database" from my web.
is that possible to do it with php tcp socket script?
PHP Read Local sqlite -> send the data to server through socket -> server listened and received the data -> Php show received data.
I can't do it right for now so i ask my problem here.
Yes, it is possible to switch from MySQL to SQLite if you already have working code.
You have to use either SQLite extension or PDO.
Most queries do not need modification and can be used transparently between these databases.
I have an application written in VB.net that runs on a clients pc.
I also have a website written in mostly javascript, http and php.
The thing I want to do is to connect the website to the application, so that when i.e. a certain button is pressed, it connects to the client application and raises an event.
I have tried approaches like TCP socket communication by having a TCP Socket Server running in the background of the client application. I can connect to the server by having a client connection from another vb.net application, but whenever I try to connect through PHP it fails. (I have only tried PHP since server-side scripting seems to make more sense in this case)
Another approach I have tried is to have an HTTP server running in the background of my desktop application and then have a PHP script connect to it, that fails as well.
One thing that I've been thinking about as a last resort is to simply have a textfile on the webserver and a PHP script writing to it after given parameters and then have the client application to read the file every few seconds. But this wouldn't be very efficient with larger amounts of data, would it?
What is the proper way of doing this?
If you have any questions about the code I've been using, feel free to ask.
If you don't get my blurry explanation, try this image: http://i.imgur.com/8njxVFj.png
Thanks in advance.
To have your data more organized i would suggest you to store your data on a database server for example mysql (which is free).
I've spent quite some time now trying to figure out how to pass a few rows from a server inside a SonicWall VPN to a remote VPS cloud server. The server inside the VPN is Microsoft 2003 running SQL Server 2005, the destination server is a CentOS 6 with MySQL. I've been unable to find a way for the CentOS to easily and securely access the MSSql server from outside the VPN. I have extremely limited knowledge of SonicWall or other firewalls in general and I really don't want to open the door to security risks. So in light of this I've come up with the following solution:
1) A scheduled PHP script extracts the rows and encrypts them in AES-256 inside a password protected excel file
2) The script then uploads the excel file to my remote server using FTP
3) The remote server, having the same encryption keys, decrypts the file and uploads the rows to the MySQL database.
Two questions:
1) Is this a safe method of moving sensitive data from one server to another?
2) Is there an easier way to access the data that I have not thought of?
You're involving FTP and files for what is essentially a system-to-system transfer which can result in trouble due to file locks and just looks ugly.
A better approach would be to have the remote CentOS box expose a port / web service that is exposed by HTTPS which requires client side authentication :
Your script retrieves the rows from some source
The script converts the rows to a form the server can read
The script calls the port exposed by the client, this is an outgoing connection so should be easier to get outside the VPN (based on the fact that getting an FTP connection outside the VPN is possible)
The script verifies the server side certificate and provides it's own client side certificate and transmits the rows over SSL
The CentOS host receives the rows and processes them as required.
With your current approach you will need to secure the FTP connection somehow, to do so securely will require both the service and client to authenticate themselves to one another and SSL does most of the heavy lifting in that regard in terms of connection negotiation and protocol flow.
I have access to a remote Oracle database when using Toad or SQL Developer.
The connection is specified by a TNS record and user+password of course.
Now I wish to have a local webpage that shows (regularly refreshed) data from the database. At first I was thinking of using php but I guess that can only be used on the server itself and I am unable to create files on the server. Of course a server page would be more suitable when there's multiple users but here there's only one.
In fact I just want to do the same as is done by running queries from the tools mentioned, but now called from a custom webpage. I feel this should be possible because the tool has to establish the connection from client to server db also; but I don't know how to set up my local client webpage(s).
Is this possible by applying php or javascript if that's more suitable?
Well you have to understand that the functionality of connecting to oracle database is packaged as part of frameworks, there are no such frameworks in javascript which can help you.
you are right with php, however it needs a webserver to run and they are free :)
the reason why php can connect to oracle database is, it has the framework to do those operations.
for now the answer is no.
or you can see if you can write an Activex which can connect to Oracle database and refresh, microsoft provides framework / api to connect to databases
The best way to do that kind of thing is AJAX: a javascript code calls a PHP page on the web server, this page connects to the DB and returns data to the javascript that updates the page.