Commit Graph

82 Commits

Author SHA1 Message Date
Marcus Boerger
40d180a87d - Reorganize ctor_args handling (fixes some bugs) 2005-02-23 00:52:46 +00:00
Marcus Boerger
3c743e3a98 - Allow to derive PDOStatement
- Verify fetch modes
- Add last fetch mode PDO_FETCH_FUNC (only valid inside fetchAll()) that
  allows to completley customize the way data is treated on the fly
2005-02-22 19:27:34 +00:00
Marcus Boerger
d56ce00b85 - Add fetch flag PDO_FETCH_CLASSTYPE 2005-02-20 16:12:57 +00:00
Marcus Boerger
3239a56526 - Only call the ctor once 2005-02-20 15:28:09 +00:00
Marcus Boerger
5a2620349e - Fix memleak and optimize PDO_FETCH_CLASS 2005-02-20 14:31:44 +00:00
Marcus Boerger
883ee83478 - Call ctor after initializing the props like regular db exts do 2005-02-20 13:42:03 +00:00
Marcus Boerger
07a8ea220f - Need to specify class_entry in PDO_FETCH_CLASS mode 2005-02-20 13:33:45 +00:00
Marcus Boerger
b788dc9d2a - Add fetch mode PDO_FETCH_UNIQUE 2005-02-19 23:48:30 +00:00
Marcus Boerger
a452a445cf - Simplify 2005-02-19 23:36:58 +00:00
Marcus Boerger
474fcab623 - Add PDO_FETCH_GROUP to fetchAll() 2005-02-19 23:11:23 +00:00
Marcus Boerger
41674da59f - Add full PDO_FETCH_CLASS capabilities to fetchAll() 2005-02-19 21:49:42 +00:00
Marcus Boerger
e6a5ebbdab - Default to stdClass in PDO_FETCH_CLASS mode if no classname is given 2005-02-19 21:35:31 +00:00
Marcus Boerger
f860c70362 - In fetch mode PDO_FETCH_CLASS handle constructor args
- Add PDOStatement::fetchObject
2005-02-13 17:04:04 +00:00
Wez Furlong
81999fdeba Fix variable declaration 2005-02-13 06:42:19 +00:00
Wez Furlong
0da6a84edf implement mapping of :name to ? parameters for drivers that only support ?
placeholders.
The current restriction is that you may not use the same named parameter
more than one in a given query, as there is a danger of scary things happen
with the zval if it gets bound multiple times.
2005-02-13 06:29:35 +00:00
Ilia Alshanetsky
1b3dd5db8b remove unused vars. 2005-02-09 15:56:27 +00:00
Wez Furlong
36e3ea8cb2 add input/output parameter type flag 2005-02-07 01:12:49 +00:00
Wez Furlong
ccf0a6a557 add a caller_frees parameter to get_col() to allow drivers that need
to allocate data on demand to do so without worrying about cleaning it up.

Spec out how LOB parameters are returned.
2005-02-06 22:11:12 +00:00
Wez Furlong
e3ba31e899 better handling of pdo-level errors 2005-02-06 21:05:59 +00:00
Wez Furlong
b2126a848a This will probably fix PECL Bug #3273 2005-02-06 16:46:18 +00:00
Edin Kadribasic
64e8c3105c Return lobs as strings for now 2005-02-05 22:46:26 +00:00
Wez Furlong
15e754201f pass param type to quoter functions 2005-02-05 21:29:42 +00:00
Wez Furlong
6ddbfa0733 Revise query parser so that it can rewrite from one bind syntax to another.
Expose it as PDO_API.  No drivers utilize this feature yet.
2005-01-21 03:57:06 +00:00
Wez Furlong
a39d50c95f don't propogate an unspecified length to the driver.
Drivers will used a 0 length as a hint that the parameter is an in-out or out
parameter.
2005-01-19 05:25:40 +00:00
Wez Furlong
a536e31fb1 leak/segv less 2005-01-19 03:44:49 +00:00
Wez Furlong
544d61873d proto bool PDOStatement::nextRowset()
Advances to the next rowset in a multi-rowset statement handle. Returns true if
it succeded, false otherwise
2005-01-19 01:12:52 +00:00
Wez Furlong
a9d98544de Allow drivers to select bind emulation on a per statement basis 2005-01-18 04:58:50 +00:00
Wez Furlong
8b35436cb1 remove error and hook up rowCount 2005-01-18 00:58:15 +00:00
Wez Furlong
37ea5fbeb5 Tidy up driver specific method handling 2005-01-17 23:59:16 +00:00
Wez Furlong
dd842e4bf4 API support for scrollable cursors 2005-01-12 04:49:12 +00:00
Wez Furlong
076bc75c01 add theoretical support for returning ints as ints and bools as bools.
individual drivers need to support returning data in these formats.
2005-01-12 03:26:46 +00:00
Wez Furlong
6e0d8dd06f implement SQLSTATE style error codes.
Allow drivers to add methods to dbh and stmt objects
(note that we can't use a class, because the use only sees the PDO class).
Clarify the api slightly:
  PDO::exec() is used for one-shot queries that don't return rows
  PDO::query() is a convenience function for returning a rowset without
  having to go through the steps of preparing and executing.
2005-01-07 05:23:10 +00:00
Wez Furlong
73186934d8 more get_method signature changes 2004-12-27 22:04:54 +00:00
Marcus Boerger
dbd717591a - TSRM Fix 2004-10-28 07:47:46 +00:00
Wez Furlong
35b00ffdab Synopsis:
PDOStatement::setFetchMode()
	reset default fetch() mode for a statement to PDO_FETCH_BOTH

PDOStatement::setFetchMode(PDO_FETCH_NUM)
PDOStatement::setFetchMode(PDO_FETCH_ASSOC)
PDOStatement::setFetchMode(PDO_FETCH_BOTH)
PDOStatement::setFetchMode(PDO_FETCH_OBJ)
	set default fetch() mode for a statement.

PDOStatement::setFetchMode(PDO_FETCH_COLUMN, int colno)
	set default fetch() mode to retrieve colno-th column on each fetch() call.

PDOStatement::setFetchMode(PDO_FETCH_CLASS, string classname [, array ctor args])
	set default fetch() mode to create an instance of classname,
	calling it's ctor, passing the optional ctor args.
	The names of the columns in the result set will be used as property names on
	the object instance.  PPP rules apply.

	[NOTE: calling ctor is not yet implemented]
	[TODO: this might crash PHP for persistent PDO handles]

PDOStatement::setFetchMode(PDO_FETCH_INTO, object obj)
	Similar to PDO_FETCH_CLASS, except that each iteration will update the
	supplied object properties.

	[TODO: this might crash PHP for persistent PDO handles]

The default fetch() mode is used when no parameters are passed to
PDOStatement::fetch().  When using a statement in an iterator context,
PDOStatement::fetch() is called implicitly on each iteration.

object PDO::queryAndIterate(string sql, <PDOStatement::setFetchMode args>)
	This is semantically equivalent to:

	$stmt = $pdo->prepare($sql);
	$stmt->execute();
	$stmt->setFetchMode($args);
	return $stmt;


Example/Intended usage:

/* fetch an array with numeric and string keys */
foreach ($pdo->queryAndIterate("select NAME, VALUE from test") as $row) {
	debug_zval_dump($row);
}

/* fetch the value of column 1 into $row on each iteration */
foreach ($pdo->queryAndIterate("select NAME, VALUE from test",
		PDO_FETCH_COLUMN, 1) as $row) {
	debug_zval_dump($row); // string(3) "foo"
}

/* create a new instance of class Foo on each iteration */
foreach ($pdo->queryAndIterate("select NAME, VALUE from test",
		PDO_FETCH_CLASS, 'Foo') as $row) {
	debug_zval_dump($row);
/*
	Object(Foo)#4 (2) refcount(2){
		["NAME"]=>
  		string(12) "foo220051429" refcount(2)
		["VALUE"]=>
		string(12) "bar789825748" refcount(2)
	}
*/
}

etc.
2004-10-27 10:26:27 +00:00
Wez Furlong
eb0cd48d60 Add rough cut at fetching meta data. 2004-09-26 20:45:44 +00:00
Wez Furlong
0d002664fb Implement empty-string-to-null conversion option for oracle compat.
This can be enabled using:
	$dbh->setAttribute(PDO_ATTR_ORACLE_NULLS, true);
2004-07-19 09:35:36 +00:00
Ilia Alshanetsky
905fbfd85e Added missing constant and correct bound column retrieval. When bound
columns are specified only return status (TRUE/FALSE) indicator.
2004-07-12 20:12:39 +00:00
Ilia Alshanetsky
41b639fffe Fixed function proto. 2004-07-09 17:49:08 +00:00
Ilia Alshanetsky
2ba792cd0b Don't use alloca() where it can reached by the users. 2004-07-05 21:16:29 +00:00
Ard Biesheuvel
f91395898c Un-revert param index fix 2004-06-15 10:22:21 +00:00
Ard Biesheuvel
e48d127244 Revert (at Wez's request) 2004-06-15 10:06:41 +00:00
Ard Biesheuvel
1d7a4ed492 Report param binding error 2004-06-13 22:09:54 +00:00
Ard Biesheuvel
50ac5db2b4 Added double param type
Added param struct initialiser
Reversed param parsing order (long <=> string)
2004-06-12 02:35:34 +00:00
Wez Furlong
d2a8d5a80f get/set attributes for statements 2004-05-25 18:32:48 +00:00
Wez Furlong
7a87af3321 Some definitions for cursors.
Define a mechanism for driver-specific attributes.
Use a refcount for the stmt structure.
2004-05-25 17:43:24 +00:00
Ilia Alshanetsky
cf75eb8a6f Cleanup. 2004-05-25 16:49:32 +00:00
Ilia Alshanetsky
402de24fc4 One more leak down. 2004-05-25 16:40:54 +00:00
Ilia Alshanetsky
b7ecaca17f More leak fixes. 2004-05-25 16:38:28 +00:00
Ilia Alshanetsky
0c762dff03 More possible leak fixes (Thanks Tony). 2004-05-25 14:47:22 +00:00