回答編集履歴

1

MDB2_PREPARE_MANIP

2020/07/28 02:24

投稿

thyda.eiqau
thyda.eiqau

スコア2982

test CHANGED
@@ -11,3 +11,17 @@
11
11
  - [Manual :: Prepare and execute SQL statements](https://pear.php.net/manual/en/package.database.mdb2.intro-execute.php)
12
12
 
13
13
  - [Docs For Class MDB2_Statement_Common #execute](https://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2_Statement_Common.html#methodexecute)
14
+
15
+
16
+
17
+ # 追記 Jul 28, 2020 11:23 AM
18
+
19
+ [MDB2のソースコード](https://github.com/pear/MDB2/blob/master/MDB2.php) を見ました。
20
+
21
+ 結論を言うとprepare()の第3引数に `MDB2_PREPARE_MANIP` を渡すと、影響を受けた行数が帰ってくるようです。
22
+
23
+
24
+
25
+ **というか先述のドキュメントにも書いてありました。**
26
+
27
+ > Since DML (data manipulation language - INSERT, UPDATE, DELETE) statements have different return values than data fetches the `prepare()` accepts a third parameter. This parameter should be set to **MDB2_PREPARE_MANIP** for DML statements (this way the number of affected rows will be returned). For data reads it should either be set to **MDB2_PREPARE_RESULT**, an array of data types for each of the columns in the result set or **NULL** in order to automatically detect the data types in the result set.