From 87bb8cd69cc593fe6bed330fb1791eac9df87167 Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 23 Oct 2007 18:28:40 +0000 Subject: Merge with WordPress, rev 6285 and untested git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1125 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/wp-db.php | 108 ++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 56 deletions(-) (limited to 'wp-includes/wp-db.php') diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 88840fe..9c11646 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -321,6 +321,39 @@ class wpdb { return $return_val; } + /** + * Insert an array of data into a table + * @param string $table WARNING: not sanitized! + * @param array $data should not already be SQL-escaped + * @return mixed results of $this->query() + */ + function insert($table, $data) { + $data = add_magic_quotes($data); + $fields = array_keys($data); + return $this->query("INSERT INTO $table (`" . implode('`,`',$fields) . "`) VALUES ('".implode("','",$data)."')"); + } + + /** + * Update a row in the table with an array of data + * @param string $table WARNING: not sanitized! + * @param array $data should not already be SQL-escaped + * @param array $where a named array of WHERE column => value relationships. Multiple member pairs will be joined with ANDs. WARNING: the column names are not currently sanitized! + * @return mixed results of $this->query() + */ + function update($table, $data, $where){ + $data = add_magic_quotes($data); + $bits = $wheres = array(); + foreach ( array_keys($data) as $k ) + $bits[] = "`$k` = '$data[$k]'"; + + if ( is_array( $where ) ) + foreach ( $where as $c => $v ) + $wheres[] = "$c = '" . $this->escape( $v ) . "'"; + else + return false; + return $this->query( "UPDATE $table SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ) . ' LIMIT 1' ); + } + /** * Get one variable from the database * @param string $query (can be null as well, for caching, see codex) @@ -472,65 +505,28 @@ class wpdb { function bail($message) { // Just wraps errors in a nice header and footer if ( !$this->show_errors ) return false; - - header('Content-Type: text/html; charset=utf-8'); - - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) - $admin_dir = ''; - else - $admin_dir = 'wp-admin/'; - -?> - - - - WordPress › Error - - - - -

WordPress

-

- - -=') ); } } -- cgit