2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 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 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_DB_DATASET_H_
17 #define incl_HPHP_DB_DATASET_H_
21 #include "hphp/util/dataset.h"
25 ///////////////////////////////////////////////////////////////////////////////
28 * A DataSet that wraps a result set directly from an SQL query.
30 class DBDataSet
: public DataSet
{
36 * Internally called by DBConn::Execute() to prepare a DBDataSet.
38 void addResult(MYSQL
*conn
, MYSQL_RES
*result
);
41 * Merge ds into this, and clear ds.
43 void addDataSet(DBDataSet
&ds
);
46 * Implementing DataSet.
49 virtual int getRowCount() const { return m_rowCount
;}
50 virtual int getColCount() const { return m_colCount
;}
51 virtual int getFieldIndex(const char *fieldName
);
52 virtual MYSQL_FIELD
*getFields() const;
53 virtual void moveFirst();
54 virtual MYSQL_ROW
getRow() const { return m_row
;}
55 virtual void moveNext();
56 virtual const char *getField(int field
) const;
57 virtual int getFieldLength(int field
) const;
60 DBDataSet(const DBDataSet
&ds
) = delete;
61 DBDataSet
& operator=(const DBDataSet
&) = delete;
63 typedef std::list
<MYSQL_RES
*> ResultList
;
65 mutable MYSQL_FIELD
*m_fields
;
70 ResultList::const_iterator m_iter
;
72 unsigned long *m_lengths
;
75 ///////////////////////////////////////////////////////////////////////////////
78 #endif // incl_HPHP_DB_DATASET_H_