使用JSON管理来自多个表的数据(PHP + MySQL)(Using JSON to manage data from multiple tables (PHP + MySQL))
我目前正在开发一个涉及Android应用程序和MySQL的项目。 我需要从MySQL数据库(位于本地服务器上,我正在使用Apache)获取数据,事实是,我已经通过从SINGLE表获取数据然后使用实现的类来完成此操作“Serializable”我能够“使用”数据。 现在,这是我的.php工作
<?PHP include_once("connection.php"); $query = "SELECT E.Nombre, COUNT(C.Id_Estudiante_FK) AS Cuenta FROM Estudiante E INNER JOIN Comentario C ON E.Id_Estudiante=C.Id_Estudiante_FK GROUP BY E.Id_Estudiante ORDER BY COUNT(C.Id_Estudiante_FK) DESC"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } echo json_encode($data); ?>
它返回我需要编码的数据,我的问题是我如何管理我得到的信息,是否可以创建另一个实现Serializable的类,其中包含我正在返回的行的属性(哪些是“Nombre”)和“Cuenta” )?
这是我用于查询的php,它只涉及一个表(已经工作,我可以“使用”数据):
<?PHP include_once("connection.php"); if(isset($_POST['txttipooferta'])){ $idtipooferta=$_POST['txttipooferta']; $query = "SELECT * FROM oferta WHERE Id_Tipo_Oferta_FK=$idtipooferta AND Cupos>0 ORDER BY Id_Oferta DESC"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } echo json_encode($data); } ?>
这是我用来管理从.php获取的数据的类,注意类的属性与表“Oferta”具有的属性相匹配(因为.php的查询是“SELECT *”)
我的问题是通过创建另一个实现Serializable的类并具有属性“Nombre”和“Cuenta”来解决的吗?
谢谢!
I'm currently working on a project that involves an Android app and MySQL. I need to get data from a MySQL database (Which is located on a local Server, I'm using Apache), the thing is, I've have already done this by getting data from a SINGLE table and then with a class that implements "Serializable" I'm able to "use" the data. Now, here is my .php working
<?PHP include_once("connection.php"); $query = "SELECT E.Nombre, COUNT(C.Id_Estudiante_FK) AS Cuenta FROM Estudiante E INNER JOIN Comentario C ON E.Id_Estudiante=C.Id_Estudiante_FK GROUP BY E.Id_Estudiante ORDER BY COUNT(C.Id_Estudiante_FK) DESC"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } echo json_encode($data); ?>
It returns back the data I need already encoded, my question is how can I manage that information I'm getting, is it possible to just create another class that implements Serializable having as attributes the rows I'm returning (Which are "Nombre" and "Cuenta")?
Here is the php I use for the query that only involves one table (Already works, and I'm able to "use" the data):
<?PHP include_once("connection.php"); if(isset($_POST['txttipooferta'])){ $idtipooferta=$_POST['txttipooferta']; $query = "SELECT * FROM oferta WHERE Id_Tipo_Oferta_FK=$idtipooferta AND Cupos>0 ORDER BY Id_Oferta DESC"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_assoc($result)){ $data[] = $row; } echo json_encode($data); } ?>
Would my problem be solved by just creating another class that implements Serializable and has as attributes "Nombre" and "Cuenta"?
Thank you!
原文:https://stackoverflow.com/questions/37093361
最满意答案
我也有这个问题,问题来自刷新Jenkins插件。
要解决这个问题,你应该:
- 打开你的工作
- 为artifactory添加任务
- 保存你的工作
- 再打开你的工作
现在您应该能够看到您的存储库。
结论:您应该添加/保存并重新加载您的作业,以查看您的神器回购列表。
Ok, so after a very long time I tried again and ... I don't know why but now (I'm quite sure it was not working few months ago) the solution given by aorfevre and user3424040 are working.
I have also upgraded jenkins to 1.565.1 and the artifactory plugin to 2.2.3 and now there is a
Refresh Repositories
button in theDeploy artifacts to Artifactory
task.
相关问答
更多-
删除NonCPS注释应该可以解决问题。 正如您在Jenkins问题中所看到的,Artifactory Jenkins插件不支持NonCPS。 Removing the NonCPS annotation should solve the problem. As you can see in this Jenkins issue, Artifactory Jenkins plugin does not support NonCPS.
-
发布到从Jenkins中的另一个项目工件复制的Artifactory(Publish to Artifactory copied from another project artifacts in Jenkins)[2021-11-28]
您可以编写一个利用Artifactory REST API的小型shell脚本,并在第二个非构建作业中执行它。 You can write a small shell script leveraging Artifactory REST API and execute it in your second, non-build job. -
Artifactory插件(Artifactory plug in)[2023-06-20]
你需要的是Generic(又名自由式)构建 。 在此类构建中,您可以指定将Jenkins工作空间中的哪些工件部署到Artifactory以及在哪个路径下。 您可以部署存档结果,然后使用存档浏览功能获取存档中提供的完整工作站点。 这是一个例子 (请注意网址中的! )。 What you need is the Generic (a.k.a freestyle) build. In this type of build, you can specify which artifacts from your Jen ... -
Artifactory和Tomcat(Artifactory and Tomcat)[2022-01-31]
默认artifactory端口是8081 over HTTP 所以http:// localhost:8081 / artifactory Default artifactory port is 8081 over HTTP So http://localhost:8081/artifactory -
这是一个逃避的问题。 Jenkins-Artifactory-plugin使用/bin/sh运行Conan可执行文件。 这有一个Jira问题 。 在那里你可以找到解决问题的快照。 该修补程序将包含在下一个Jenkins-Artifactory插件发行版中。 与此同时,您可以下载快照版本 This is an escaping issue. Jenkins-Artifactory-plugin run Conan executable with /bin/sh. There is a Jira issue f ...
-
詹金斯和gradle artifactory集成 - 认证(Jenkins and gradle artifactory integration — authentication)[2023-11-04]
这是您可以如何从Jenkins服务器发布到Artifactory,而无需在gradle.properties中提交凭据: artifactory { publish { repository { username = project.hasProperty('artifactory_user') ? project.artifactory_user : System.getenv()['ARTIFACTORY_USER'] password = project.hasPr ... -
我的问题在@Tunaki的问题的评论中得到了回答。 我在我的pom.xml中使用范围来引用我的文章中提到的存储库中的工件。 我切换到使用确切的版本号,它现在工作正常。 My question was answered in the comments of my question by @Tunaki. I was using ranges in my pom.xml to reference the artifacts from the repository mentioned in my post. I ...
-
詹金斯和Artifactory(Jenkins & Artifactory)[2024-01-16]
我也有这个问题,问题来自刷新Jenkins插件。 要解决这个问题,你应该: 打开你的工作 为artifactory添加任务 保存你的工作 再打开你的工作 现在您应该能够看到您的存储库。 结论:您应该添加/保存并重新加载您的作业,以查看您的神器回购列表。 Ok, so after a very long time I tried again and ... I don't know why but now (I'm quite sure it was not working few months ago) t ... -
詹金斯与艺术整合(Jenkins and Artifactory Integration)[2022-04-30]
如果它是maven构建,那么你不应该选择路径。 路径应该从构建的POM和工件的正确坐标中获取。 Maven的布局并不灵活。 If it's a maven build then you should not choose the path. The path should be taken from the POM of your build and the right coordinates of your artifacts. Maven is not flexible with his layout. ... -
您可以在规范路径和规范内容中使用环境变量。 在您的情况下,您可以使用路径中的作业名称将每个作业的规范上传到SCM。 然后,您可以使用环境变量动态设置规范文件路径,如下所示: 另一种方法是在每个作业中设置一个变量(例如PATTERN-PATH)并在规范中使用它。 { "pattern": "libs-snapshot-local/${PATTERN-PATH}/*", "target": "out/downloaded/" } You can use environment variables in ...