note 34121 added to function.pg-insert
| From: | rorezende at hotmail dot com | Date: | Wed, 16 Jul 2003 16:49:45 +0000 |
| Subject: | note 34121 added to function.pg-insert | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52210@lists.php.net to get a copy of this message | ||
Time is money, then I write a function similar to pg_insert in PHP (only output sql statement) :
function db_mount_insert($table,$array) {
$str = "insert into $table (";
while(list($name,$value) = each($array)) {
$str .= "$name,";
}
$str[strlen($str)-1] = ')';
$str .= " values (";
reset($array);
while(list($name,$value) = each($array)) {
if(is_string($value))
$str .= "'$value',";
else
$str .= "$value,";
}
$str[strlen($str)-1] = ')';
$str .= ";" ;
return $str;
}
----
Manual Page -- http://www.php.net/manual/en/function.pg-insert.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34121
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34121&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34121&report=yes