Delete ClassInfoHook
[hiphop-php.git] / hphp / util / db-dataset.h
blob0590ddd23966e62ca38605673056a9abfbad35d1
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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_
19 #include <list>
21 #include "hphp/util/dataset.h"
23 namespace HPHP {
25 ///////////////////////////////////////////////////////////////////////////////
27 /**
28 * A DataSet that wraps a result set directly from an SQL query.
30 class DBDataSet : public DataSet {
31 public:
32 DBDataSet();
33 virtual ~DBDataSet();
35 /**
36 * Internally called by DBConn::Execute() to prepare a DBDataSet.
38 void addResult(MYSQL *conn, MYSQL_RES *result);
40 /**
41 * Merge ds into this, and clear ds.
43 void addDataSet(DBDataSet &ds);
45 /**
46 * Implementing DataSet.
48 virtual void close();
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;
59 private:
60 DBDataSet(const DBDataSet &ds) = delete;
61 DBDataSet& operator=(const DBDataSet&) = delete;
63 typedef std::list<MYSQL_RES*> ResultList;
64 ResultList m_results;
65 mutable MYSQL_FIELD *m_fields;
67 int m_rowCount;
68 int m_colCount;
70 ResultList::const_iterator m_iter;
71 MYSQL_ROW m_row;
72 unsigned long *m_lengths;
75 ///////////////////////////////////////////////////////////////////////////////
78 #endif // incl_HPHP_DB_DATASET_H_