(PHP / Postgresql)调用返回void的函数?

时间:2017-07-01 11:08:10

标签: php html postgresql web

我疯狂地尝试在PHP代码中调用一个返回void的函数,使用pg_prepare / pg__execute ......

      call.enqueue(new Callback<WeatherData>() {
    @Override
    public void onResponse(Call<WeatherData> call, Response<WeatherData> response) {

       if(response.isSuccessful() && response.body != null) {
            WeatherData data = response.body();
            List<Weather> weatherList = data.getWeatherList(); 
           //Pass this list to your adapter
       }

    }

    @Override
    public void onFailure(Call<WeatherData> call, Throwable t) {
        Toast toast = Toast.makeText(Forecast5Days.this, "Something went wrong with request", Toast.LENGTH_LONG);
        toast.show();
    }
});

我做错了pg_prepare / pg_execute的设置吗? 感谢

1 个答案:

答案 0 :(得分:1)

您可能想要做一些不同的事情:

pg_prepare:不要放置具体值,而是放置占位符。稍后您将它们绑定到值。我更喜欢总是给陈述一个名字。

如果dungeonasdb.crea_personaggio是返回void的函数,您可以通过以下方式调用它:

SELECT dungeonasdb.crea_personaggio(...)

您无法通过SELECT * FROM dungeonasdb.crea_personaggio(...)调用您的函数,因为这意味着dungeonasdb.crea_personaggioset returning function,而不是。{/ p>

所以你可能希望你的陈述是:

$result = pg_prepare($dbconn, "crea_personnagio", 
   'SELECT dungeonasdb.crea_personaggio($1, $2, $3, $4)'); 
$result = pg_execute($dbconn, "crea_personnagio", 
    ARRAY($nome, $descrizione, $email, $password)) 
    or die('Query execuzione fallita');

您的第二个语句是pg_execute语句,参数绑定到所有者($1,...),然后执行。

相关问题