List Info

Thread: note 78102 added to function.pg-insert




note 78102 added to function.pg-insert
user name
2007-09-27 14:49:18
If you need schema support, this function will do something
similar to pg_insert:

function pg_insert_with_schema($connection, $table,
$updates) 
{
 $schema = 'public';
 if (strpos($table, '.') !== false)
	list($schema, $table) = explode('.', $table);

	if (count($updates) == 0) {
		$sql = "INSERT INTO $schema."$table"
DEFAULT VALUES";
			return pg_query($sql);
	    } else {
 $sql = "INSERT INTO $schema."$table"
";
			
 $sql .= '("';
 $sql .= join('", "', array_keys($updates));
 $sql .= '")';

 $sql .= ' values (';
 for($i = 0; $i < count($updates); $i++)
   $sql .= ($i != 0? ', ':'').'$'.($i+1);
 $sql .= ')';
 return pg_query_params($connection, $sql,
array_values($updates));
 }
}
----
Server IP: 209.41.74.194
Probable Submitter: 216.145.226.130
----
Manual Page -- h
ttp://www.php.net/manual/en/function.pg-insert.php
Edit        -- https://master
.php.net/note/edit/78102
Del: integrated  -- h
ttps://master.php.net/note/delete/78102/integrated
Del: useless     -- http
s://master.php.net/note/delete/78102/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78102/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78102/spam
Del: non-english -- 
https://master.php.net/note/delete/78102/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78102/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78102
Reject      -- https://mast
er.php.net/note/reject/78102
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )