Commit Graph

313 Commits

Author SHA1 Message Date
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
3a751f37c6 don't raise errors for the no-error case 2005-01-17 05:28:46 +00:00
Wez Furlong
81664bd2db Remove bogus scroll attribute.
Expose cursor constants to the script
2005-01-12 05:59:27 +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
Marcus Boerger
1875caf1ab - Fix warning
- Fix tsrm usage
2005-01-08 12:35:50 +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
Wez Furlong
b44785e958 don't blow up under HEAD 2004-12-26 04:50:09 +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
Marcus Boerger
32a0465214 - Fix warning 2004-09-26 22:23:14 +00:00
Marcus Boerger
cc7ef25e4a fix build 2004-09-26 22:20:24 +00:00
Wez Furlong
eb0cd48d60 Add rough cut at fetching meta data. 2004-09-26 20:45:44 +00:00
Wez Furlong
2416481fd1 More sensible error codes in the exceptions we throw for broken transactions 2004-09-24 18:49:33 +00:00
Wez Furlong
7937f0a229 Implement persistent connections
$dbh->exec --> $dbh->query
2004-09-23 20:07:02 +00:00
Wez Furlong
ceb551024a Add support for:
$d = new PDO('foobar');  // name has no : character

This will indirect via the entry "pdo.dsn.foobar" from the php.ini file,
so if you have:

pdo.dsn.foobar=sqlite::memory:

the above is equivalent to this:

$d = new PDO('sqlite::memory:');

which creates an in-memory sqlite db.
2004-09-19 19:28:02 +00:00
Wez Furlong
797303d23a un-bogusify uri: stuff... 2004-09-19 18:11:27 +00:00
Wez Furlong
34d10931e2 Add "no permission" error code.
Add a uri: psuedo driver; it specifies the name of a resource that contains,
as its first line, the actual data source to connect to.
The resource can be a local file, or it can be any resource for which PHP
has a wrapper.

// loads connection data from the file "myapp"
$d = new PDO('uri:myapp');

// lets say that public.db.com has a read-only db open for the public
// their connection data is also published via the web:
// (not so great to resolve this on each request though...)
$d = new PDO('uri:http://public.db.com/pdo-connection-data');
2004-09-19 16:58:13 +00:00
Antony Dovgal
fdb29f9fa5 fix leak 2004-08-29 06:10:47 +00:00
Marcus Boerger
af900cb1d0 - Fix SEGV in case ctor failed 2004-07-28 00:01:12 +00:00
George Schlossnagle
c7b7791029 allow pdo to be functionally inherited from. 2004-07-26 07:42:46 +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
George Schlossnagle
9e187415f9 fix for inheritability 2004-06-23 18:06:00 +00:00
Ard Biesheuvel
18cd69ef74 Fixed some int-long issues 2004-06-23 13:20:54 +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
cb4612c735 Added double param type 2004-06-13 10:35:01 +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
Ilia Alshanetsky
9280b88a8c One more memory leak. 2004-05-25 14:35:49 +00:00
Ilia Alshanetsky
d782abf416 More leak fixes. 2004-05-25 14:30:07 +00:00
Ilia Alshanetsky
ce3891347f Fixed memory leak. 2004-05-25 14:12:15 +00:00
Wez Furlong
758b7f1ad4 Bump the version number 2004-05-21 22:26:45 +00:00
George Schlossnagle
4d01a5c2d1 ok, apprently we _don't_ want to count the nulls. 2004-05-21 22:24:20 +00:00
George Schlossnagle
1ee89e1bea remove debugging 2004-05-21 22:20:25 +00:00
George Schlossnagle
518cf77f32 fix fubar'd emulated bindings 2004-05-21 22:19:33 +00:00
Wez Furlong
25049d6cf8 Add some blurb 2004-05-21 17:31:49 +00:00
Wez Furlong
597124e128 Update package/module 2004-05-21 16:53:32 +00:00
Wez Furlong
500922f9a2 Update package file 2004-05-21 16:38:41 +00:00
Wez Furlong
d8d7dd7e14 Allow lazy fetch to work with numeric offsets.
Fix named parameters...
2004-05-21 14:31:51 +00:00
Ilia Alshanetsky
37d8a82b4d Fixed compiler warning. 2004-05-21 14:27:48 +00:00
Wez Furlong
8f5b212612 store the name length in the same manner as it is stored in zvals 2004-05-21 14:14:32 +00:00
Wez Furlong
ed83c5bee5 Tidy up placeholder flags 2004-05-21 14:09:51 +00:00
Wez Furlong
bf48daa8d5 Version 1 of PDO_FETCH_LAZY 2004-05-21 13:26:58 +00:00
Wez Furlong
f0a001a953 Implement case folding of column names as a portability option. 2004-05-20 22:28:53 +00:00
Wez Furlong
e0ac3f66ae Implement PDO_FETCH_OBJ
# todo (after initial release) - specify a particular class, reuse existing
# objects etc.
2004-05-20 22:06:42 +00:00
Ilia Alshanetsky
43a04beb46 Make username & password parameters optional. 2004-05-20 20:25:22 +00:00
George Schlossnagle
e155ad208a sigh... need to include the null byte in hash keys 2004-05-20 19:19:04 +00:00
Wez Furlong
5023a7c61c Enable setting the different error modes via PDO::setAttribute() 2004-05-20 19:16:49 +00:00
Ilia Alshanetsky
726e188cce Fixed typo. 2004-05-20 19:14:44 +00:00
Ilia Alshanetsky
42a2b22a4a Added missing user-land constants. 2004-05-20 19:12:24 +00:00
Ilia Alshanetsky
e596466a1f Added getAttribute() method. 2004-05-20 19:09:35 +00:00
George Schlossnagle
b7b7bedabd remove debug 2004-05-20 18:50:21 +00:00
George Schlossnagle
c22cb0477c off by one error 2004-05-20 18:44:12 +00:00
George Schlossnagle
3366916203 set active_query_string to null in case of failure 2004-05-20 18:29:59 +00:00
Ilia Alshanetsky
cf33729c20 Better error message. 2004-05-20 18:05:44 +00:00
George Schlossnagle
d16625b803 Support ? as a bind in emulated prepares
Throw informative error when pdo_parse_param fails
2004-05-20 17:56:09 +00:00
George Schlossnagle
e3e2370490 keys need to be null-terminated (how did this not get committed before???)
bind-by-name includes the leading : in the name
2004-05-20 17:34:52 +00:00
Wez Furlong
04ccc0134d Add methods for error handling 2004-05-20 17:22:13 +00:00
George Schlossnagle
76b7b5d1e2 iactually support :\w+ as binds 2004-05-20 17:04:57 +00:00
Ilia Alshanetsky
fbbb41a53b Fixed typo. 2004-05-20 15:45:16 +00:00
Ilia Alshanetsky
e770b2b411 Fixed compiler warnings. 2004-05-20 13:57:09 +00:00
Wez Furlong
e7c72f8455 First cut at a "unified" error handling API. The main thing that is missing
currently is a switch in the dbh to indicate what to do with the errors.
2004-05-20 00:05:22 +00:00
Ilia Alshanetsky
c98a99c263 Added fetchAll and fetchSingle methods for data retrieval. 2004-05-19 20:38:53 +00:00
Ilia Alshanetsky
676dfcf581 Timeout stuff. 2004-05-19 20:38:25 +00:00
George Schlossnagle
129997216b exec() now returns row count 2004-05-19 19:27:53 +00:00
Frank M. Kromann
7c5c0fbbea Set correct Win32 line endings and fix ZTS compilation 2004-05-19 18:04:47 +00:00
Ilia Alshanetsky
074ba3fbc0 Added lastInsertId() method for retrieving last insert id.
Made affectedRows() work for MySQL.
Populate error value in MySQL on error.
2004-05-19 17:35:39 +00:00
Ilia Alshanetsky
5a4c3234b9 Skip spaces between connection params. 2004-05-19 17:09:48 +00:00
Wez Furlong
1a91f75193 Add simple error code values and a place to store them 2004-05-19 16:21:43 +00:00
Wez Furlong
641f2c0c40 Let it install correctly when built via phpize 2004-05-19 15:27:27 +00:00
Ilia Alshanetsky
c11d6ca38b Copy the headers 2004-05-19 14:27:32 +00:00
Wez Furlong
fd6b885a19 Revise $dbh->exec().
The driver doer() method should populate dbh->affected_rows if it can determine its value.
2004-05-19 13:55:41 +00:00
Wez Furlong
6cd27ff8be Add $dbh->exec() method.
Rename $dbh->beginWork() to $dbh->beginTransaction().
2004-05-19 13:43:07 +00:00
Edin Kadribasic
7a214b66ae Cosmetics 2004-05-19 13:28:05 +00:00
Ilia Alshanetsky
741e31bdf3 Removed unused vars. 2004-05-19 13:27:54 +00:00
Wez Furlong
4116d9fb0e Expand the prepare() prototype to accept additional options. 2004-05-19 12:37:31 +00:00
Sebastian Bergmann
681ded13bc ZTS fix. 2004-05-19 09:23:15 +00:00
Ilia Alshanetsky
aecad9e37b Fixed build. 2004-05-18 22:45:53 +00:00
Ilia Alshanetsky
cb1239a338 Allow static builds. 2004-05-18 22:31:13 +00:00
George Schlossnagle
f02fb4ada4 should be a strcmp, not a strncmp, thanks, wez 2004-05-18 20:57:19 +00:00
George Schlossnagle
8233053d24 was leaking query_string's 2004-05-18 20:33:30 +00:00
George Schlossnagle
5f4cfcb009 support the read-only property 'queryString' 2004-05-18 20:26:24 +00:00
George Schlossnagle
2e4c3ea35f forgotten off the last commit 2004-05-18 19:30:43 +00:00
Wez Furlong
c4ca0f3378 Give user a nice message when PDO isn't initialized prior to a driver. 2004-05-18 19:30:22 +00:00
Wez Furlong
17d009c3b4 Update generated parser 2004-05-18 15:58:17 +00:00
Wez Furlong
e37b622d3f Add parser to win32 build 2004-05-18 15:58:00 +00:00
Wez Furlong
2a9fa24458 Tweaks for win32 2004-05-18 15:57:46 +00:00
George Schlossnagle
85e3a1bc3b for those without re2c 2004-05-18 15:38:25 +00:00
George Schlossnagle
70f06be16a license/copyright block 2004-05-18 15:22:58 +00:00
George Schlossnagle
a97e1a6646 handle binding/quoting of queries for drivers with emulated prepares 2004-05-18 15:19:31 +00:00
Wez Furlong
c9f736ab6e Skeleton for emulated prepare() 2004-05-18 08:59:27 +00:00
Wez Furlong
940c896e15 Quoting here leads to problems with databases that really support bound parameters.
We should do this conditionally based on the emulate_prepare flag.
2004-05-18 08:45:28 +00:00
George Schlossnagle
2e36e9d06d only rewrite tmp if quoter returns true 2004-05-18 05:34:52 +00:00
George Schlossnagle
636cc3e1dc auto-quote values before binding them in at execute time 2004-05-18 05:31:01 +00:00
George Schlossnagle
2e281baab9 we need the source string length for binary safe string handling 2004-05-18 05:00:52 +00:00
Wez Furlong
2653f34210 Skeleton package file 2004-05-18 00:40:01 +00:00
George Schlossnagle
fd73439882 include guard 2004-05-17 21:12:30 +00:00
Wez Furlong
dd84731577 Allow PDO to build as a self-contained extension.
Install headers so that other self-contained extensions may them.
2004-05-17 18:13:03 +00:00
Wez Furlong
79c513db96 Some pedantic fixes for gcc. 2004-05-17 17:00:35 +00:00
Wez Furlong
684be9cf36 Hello PDO.
Still more to come.  Give it a couple of days before starting to write drivers
for the other databases; a few things might change, so I'd like to coordinate
that, but in a couple of days.
2004-05-17 15:41:51 +00:00