| @@ -127,11 +127,16 @@ | ||
| 127 | 127 | * @param mixed $field |
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | 130 | public function escapeValue($data, $field) { |
| 131 | + # MYSQLI doesn't has numeric field. | |
| 132 | + if ($this->wpdb->use_mysqli) { | |
| 133 | + $field->numeric = $field->flags & MYSQLI_NUM_FLAG; | |
| 134 | + } | |
| 135 | + # Check if numeric | |
| 131 | 136 | switch ($field->numeric) { |
| 132 | 137 | case 0: |
| 133 | - $data = mysql_real_escape_string($data, $this->wpdb->dbh); | |
| 138 | + $data = esc_sql($data); | |
| 134 | 139 | $data = "'{$data}'"; |
| 135 | 140 | break; |
| 136 | 141 | case 1: |
| 137 | 142 | $data = (int) $data; |
| @@ -164,9 +169,9 @@ | ||
| 164 | 169 | * @param mixed $table |
| 165 | 170 | */ |
| 166 | 171 | public function getColumns($table) { |
| 167 | 172 | $columns = array(); |
| 168 | - $this->select("SELECT * FROM {$table} WHERE 1!=1;"); | |
| 173 | + $this->select("SELECT * FROM {$table} WHERE 1!=1 LIMIT 0,1;"); | |
| 169 | 174 | // Use field name as element key. |
| 170 | 175 | foreach ($this->wpdb->col_info as $index => $column) { |
| 171 | 176 | $columns[$column->name] = $column; |
| 172 | 177 | } |
| @@ -180,8 +185,24 @@ | ||
| 180 | 185 | public function getInsertId () { |
| 181 | 186 | return $this->wpdb->insert_id; |
| 182 | 187 | } |
| 183 | 188 | |
| 189 | + /** | |
| 190 | + * put your comment there... | |
| 191 | + * | |
| 192 | + * @param mixed $query | |
| 193 | + * @param mixed $returnType | |
| 194 | + * @param mixed $default | |
| 195 | + */ | |
| 196 | + public function getRow($query, $returnType = OBJECT_K, $default = null) { | |
| 197 | + $row = null; | |
| 198 | + // Fetch al result set! | |
| 199 | + $result = $this->select($query, $returnType); | |
| 200 | + if ($result) { | |
| 201 | + $row = reset($result); | |
| 202 | + } | |
| 203 | + return $row; | |
| 204 | + } | |
| 184 | 205 | /** |
| 185 | 206 | * put your comment there... |
| 186 | 207 | * |
| 187 | 208 | */ |