2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_DATASET_H_
18 #define incl_HPHP_DATASET_H_
20 #include "hphp/util/base.h"
25 DECLARE_BOOST_TYPES(DataSet
);
26 ///////////////////////////////////////////////////////////////////////////////
29 * A class that stores a list of rows, so that one can iterate through them by
31 * int fieldIndex = ds.getFieldIndex("id");
32 * for (ds.moveFirst(); ds.getRow(0); ds.moveNext()) {
33 * const char *value = ds.getField(0);
34 * unsigned int n = ds.getUIntField(fieldIndex);
42 * Close dataset and free up resources.
44 virtual void close() = 0;
47 * Informational functions.
49 virtual int getRowCount() const = 0;
50 virtual int getColCount() const = 0;
51 virtual int getFieldIndex(const char *fieldName
) = 0;
52 virtual MYSQL_FIELD
*getFields() const = 0;
55 * Iteration functions.
57 virtual void moveFirst() = 0;
58 virtual MYSQL_ROW
getRow() const = 0;
59 virtual void moveNext() = 0;
62 * Field value retrieval.
64 virtual const char *getField(int field
) const = 0;
65 virtual int getFieldLength(int field
) const = 0;
66 const char *getStringField(int field
) const; // NULL will become ""
67 int getIntField(int field
) const;
68 unsigned int getUIntField(int field
) const;
69 long long getInt64Field(int field
) const;
70 unsigned long long getUInt64Field(int field
) const;
73 * Returns a one-liner of all fields of current row.
75 std::string
getRowString() const;
79 * Helper function for getRowString().
81 static std::string
escape(const char *s
);
84 ///////////////////////////////////////////////////////////////////////////////
87 #endif // incl_HPHP_DATASET_H_