I have PHP running on Google App Engine – How do I use a DB?

I have PHP running on Google App Engine – How do I use a DB?

断爱 发布于 2021-11-25 字数 253 浏览 765 回复 5 原文

I followed PHP on the Google appengine to setup and it works great. Any suggestions on how to use a database / datastore with PHP on GAE?

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。



需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。


煞人兵器 2022-06-07 4 楼

There's some discussion on a GQL datastore in the tutorial you just linked to.

Google App Engine’s datastore has a SQL-like syntax called “GQL”. Select statements in GQL can be performed on one table only.

And memcached

anyway for the php to access any kind of database. - I know that Memcached is provided by GAE so we can use that by simply adding a key value pair.

夏日浅笑〃 2022-06-07 3 楼

I think this is what you are looking for
use one of the three MySQL libraries supported, work against local installation of MySQL in local, and the Google CloudSQL when deployed, by having an instance name that you connect to with mysql_connect(). Requires billing being enabled to setup a CloudSQL instance :-(

小情绪 2022-06-07 2 楼

see the URL below for an proof of concept how to use SQL CRUD (Create, Retrieve, Update, Delete) in PHP at Google App Engine.

Oops, new users can not post a link. Click on my name below in the right corner and then click on the website url.

季末如歌 2022-06-07 1 楼

Because Google provides low-level access to the datastore in Java API


You should be able to access those class using the php-java integration, something like:

 // Get a handle on the datastore itself
 $datastore = new Java('com.google.appengine.api.datastore.DatastoreServiceFactory')->getDatastoreService();

 // Lookup data by known key name
 $userEntity = $datastore->get(new Java('com.google.appengine.api.datastore.KeyFactory')->createKey("UserInfo", email));