开发者

Update Postgres table with array elements

I want update the Postgr开发者_如何学JAVAes database table with array elements but I didn't know how.

I tried this but I got this notice: Notice: Undefined index: 'value' in 'file' on line x

Update:

private function debug ($function_name, $arg_names, $arg_vals (<=with func_get_args())  ) 
{
    $arg_names_array = explode(',', $arg_names);
    foreach($arg_names_array as $k => $v)
    {
        $v = trim($v);
        $v = pg_escape_string($v);
        $vars[$k] = $arg_vals[$v];
    }
    $this->return_ = $vars;
    return $this->return_;  
}
pg_query($connect, "UPDATE tabe SET row = {$vars[$first]}  WHERE code = {$vars[$code]} ");
pg_query($connect, "UPDATE tabe SET row = '{$vars[$first]}'  WHERE code = '{$vars[$code]}' ");


I need more context information to be able to help you. I understand you want to update a field wich contains an array of values. Remember that in postgresql, the array syntax is {value1,value2,...,valueN}, where value is enclosed in apostrophes if it is a string.

So what does $vars[$first] contain? if it is a php array, you must convert it first to a situable string for the sql command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜