Commit Graph

71 Commits

Author SHA1 Message Date
Ilia Alshanetsky
3be50385ab Allocation checks around persistent allocs that can fail. 2005-04-28 00:25:25 +00:00
Marcus Boerger
c9108bba25 - Simplify code (only implement handlers that are necessary)
- Fix handling of read only property 'queryString'
- Fix overloading
- Move class init code to their defining .c files for simplification
- Mark class PDORow as final until there's a need to inherit this and
  someone implements the handlers correct then.
2005-03-21 00:29:06 +00:00
Wez Furlong
f7ebff804d "thou shalt not throw exceptions except in really exceptional circumstances."
The only allowed places to throw them directly are from within the PDO class
constructors or when dealing with transaction level attributes, where
"hard-failure" is a feature.

All other errors should use the PDO error handling mechanism and respect the
users selected error mode.
2005-03-09 05:50:03 +00:00
Wez Furlong
de1d8b91f0 prep package file for release.
fix my favourite typo.
fix compile warnings
2005-03-09 05:03:58 +00:00
Marcus Boerger
eb330a95f6 - Fix warning 2005-02-28 18:44:14 +00:00
Marcus Boerger
d072f6de54 - Changing handler table definitively results in SEGVs 2005-02-28 18:40:02 +00:00
Joe Orton
bc1c0c2e12 Fix type mismatch. 2005-02-28 13:30:50 +00:00
Wez Furlong
2c5b2fc105 Alan: moved your fields away, but reserved you a pointer.
Changed PDO::lastInsertId() to have following proto:

	string PDO::lastInsertId([string name])

this allows arbitrary unique identitifers to be returned from the driver.

The optional name parameter is for databases that require additional contextual
information to be able to return the correct identifier.  None currently use
it, but pgsql will be on the list of drivers that do.
2005-02-26 17:27:51 +00:00
Marcus Boerger
b786b93b7a - Delay ctor call so that it can overwrite everything and the data can
already be accessed from the ctor.
2005-02-23 23:28:30 +00:00
Marcus Boerger
77cf78caa1 - Make ctor args optional 2005-02-23 00:29:44 +00:00
Marcus Boerger
994006abd4 - Need to also revert operator 2005-02-22 21:22:23 +00:00
Marcus Boerger
d235a2bf4a - Put this back in (forgot to revert) 2005-02-22 20:59:52 +00:00
Marcus Boerger
cb9658feef - Revert signature of PDO:prepare()
old: proto object PDO::prepare(string statment [, array driver_options [, string classname ]])
  now: proto object PDO::prepare(string statment [, array options])
  param 'classname' and and 'ctor_args' are now set through options
  using index PDO_ATTR_STATEMENT_CLASS
- Change all deriver_options parameters to 'options' to reflect the fact
  that they may contain statement as well as driver specific flags
2005-02-22 20:25:56 +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
18985accc4 - Call dtor 2005-02-22 11:37:53 +00:00
Wez Furlong
1051e7076f Fixes the crash part of PECL Bug #3434. 2005-02-13 03:26:43 +00:00
Wez Furlong
91eab3e5bc typo 2005-02-11 02:05:05 +00:00
Wez Furlong
ccd242665b Fix PDO::query() for drivers that emulate bound parameters. 2005-02-11 01:20:59 +00:00
Wez Furlong
94d5261f73 cosmetic changes 2005-02-09 15:12:41 +00:00
Wez Furlong
902ca8c1cf Expose the quoter method of the driver as PDO::quote().
Closes PECL Bug #3393
2005-02-09 06:43:15 +00:00
Wez Furlong
e3ba31e899 better handling of pdo-level errors 2005-02-06 21:05:59 +00:00
Wez Furlong
ca4dc0361c this one too 2005-02-06 17:33:12 +00:00
Wez Furlong
9ba84360e3 handle some generic attributes here 2005-02-06 17:25:09 +00:00
Wez Furlong
7a137a5f84 fix leak 2005-01-21 04:41:52 +00:00
Wez Furlong
dcd3d84ddb Eliminate unused parameter 2005-01-21 00:38:09 +00:00
Wez Furlong
a536e31fb1 leak/segv less 2005-01-19 03:44:49 +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
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
b44785e958 don't blow up under HEAD 2004-12-26 04:50:09 +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
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
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
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
b7ecaca17f More leak fixes. 2004-05-25 16:38:28 +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