Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $tag = array('item1', 'item2', 'item3');
- // Prepare a query for execution
- $result = pg_prepare($dbconn, "my_query", "INSERT INTO $table ($column) VALUES ($1)");
- // Execute the prepared query. Note that it is not necessary to escape
- // the string "Joe's Widgets" in any way
- $result = pg_execute($dbconn, "my_query", array("$tag"));
- $tag = array('item1', 'item2', 'item3');
- // Prepare a query for execution
- $result = pg_prepare($dbconn, "my_query", "INSERT INTO $table ($column) VALUES ($1)");
- // Execute the prepared query. Note that it is not necessary to escape
- // the string "Joe's Widgets" in any way
- foreach( $tag as $i )
- $result = pg_execute($dbconn, "my_query", array($i));
- /// alternatively you could try this if you really wanna insert a text as array of text without using text[] type - uncomment line below and comment the 2 above
- // $result = pg_execute($dbconn, "my_query", array(json_encode($tag)));
- $tag = array('item1', 'item2', 'item3');
- // Prepare a query for execution
- $result = pg_prepare($dbconn, "my_query", "INSERT INTO $table ($column) VALUES ($1)");
- // Execute the prepared query. Note that it is not necessary to escape
- // the string "Joe's Widgets" in any way
- $tmp = json_encode($tag);
- $tmp[0] = '{';
- $tmp[strlen($tmp) - 1] = '}';
- $result = pg_execute($dbconn, "my_query", array($tmp));
- $tag = array('item1', 'item2', 'item3');
- $tag = serialize($tag);
- // Prepare a query for execution
- $result = pg_prepare($dbconn, "my_query", "INSERT INTO $table ($column) VALUES ($1)");
- // Execute the prepared query. Note that it is not necessary to escape
- // the string "Joe's Widgets" in any way
- $result = pg_execute($dbconn, "my_query", $tag);
Add Comment
Please, Sign In to add comment