Commit Graph

20 Commits

Author SHA1 Message Date
Wez Furlong
a750f195cd Fix Bug #34687; error information from query() not passed back 2005-10-02 22:11:19 +00:00
Marcus Boerger
991a29cfd6 - MFH PDOException base 2005-10-02 20:38:18 +00:00
Edin Kadribasic
35b7ad00a6 Declare functions used by driver as PDO_API in php_pdo_driver.h 2005-09-24 14:18:01 +00:00
Antony Dovgal
9a1c6c55b8 fix build (declare extern HashTable pdo_driver_hash) 2005-09-18 18:05:59 +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
Marcus Boerger
7b2bee1d5b - Fix warnings by doing it the Zend way 2005-03-19 10:51:42 +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
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
Wez Furlong
e3ba31e899 better handling of pdo-level errors 2005-02-06 21:05:59 +00:00
Wez Furlong
3a751f37c6 don't raise errors for the no-error case 2005-01-17 05:28:46 +00:00
Wez Furlong
dd842e4bf4 API support for scrollable cursors 2005-01-12 04:49:12 +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
7937f0a229 Implement persistent connections
$dbh->exec --> $dbh->query
2004-09-23 20:07:02 +00:00
Wez Furlong
bf48daa8d5 Version 1 of PDO_FETCH_LAZY 2004-05-21 13:26:58 +00:00
Wez Furlong
5023a7c61c Enable setting the different error modes via PDO::setAttribute() 2004-05-20 19:16:49 +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
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