cvs: pear /MDB2 MDB2.php
| From: | Lukas Smith | Date: | Wed, 07 Apr 2004 21:11:20 +0000 |
| Subject: | cvs: pear /MDB2 MDB2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-17994@lists.php.net to get a copy of this message | ||
lsmith Wed Apr 7 17:11:20 2004 EDT
Modified files:
/pear/MDB2 MDB2.php
Log:
- added seqname_col_name option to modify the column name used inside sequence emulation tables
- moved getOne, getRow, getCol and getAll back into the exteneded container (these methods are a
misuse of prepare queries, if you want to separate your sql from your data use a proper DAO)
http://cvs.php.net/diff.php/pear/MDB2/MDB2.php?r1=1.14&r2=1.15&ty=u
Index: pear/MDB2/MDB2.php
diff -u pear/MDB2/MDB2.php:1.14 pear/MDB2/MDB2.php:1.15
--- pear/MDB2/MDB2.php:1.14 Sun Mar 28 07:12:56 2004
+++ pear/MDB2/MDB2.php Wed Apr 7 17:11:18 2004
@@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2.php,v 1.14 2004/03/28 12:12:56 lsmith Exp $
+// $Id: MDB2.php,v 1.15 2004/04/07 21:11:18 lsmith Exp $
//
/**
@@ -829,6 +829,7 @@
'lob_buffer_length' => 8192,
'log_line_break' => "\n",
'seqname_format' => '%s_seq',
+ 'seqname_col_name' => 'sequence',
'use_transactions' => false,
'decimal_places' => 2,
'portability' => MDB2_PORTABILITY_ALL,
@@ -2359,182 +2360,6 @@
}
// }}}
- // {{{ getOne()
-
- /**
- * Fetch the first column of the first row of data returned from
- * a query. Takes care of doing the query and freeing the results
- * when finished.
- *
- * @param string $query the SQL query
- * @param string $type string that contains the type of the column in the
- * result set
- * @param array $params if supplied, prepare/execute will be used
- * with this array as execute parameters
- * @param array $param_types array that contains the types of the values
- * defined in $params
- * @return mixed MDB2_OK or value on success, a MDB2 error on failure
- * @access public
- */
- function getOne($query, $type = null, $params = array(), $param_types = null)
- {
- settype($params, 'array');
- if (count($params) == 0) {
- return $this->queryOne($query, $type);
- }
-
- $prepared_query = $this->prepare($query, $param_types);
- if (MDB2::isError($prepared_query)) {
- return $prepared_query;
- }
-
- $result = $this->executeParams($prepared_query, $type, $params);
- if ($result == MDB2_OK || MDB2::isError($result)) {
- return $result;
- }
-
- $one = $result->fetch();
- $this->freePrepared($prepared_query);
- $result->free();
- return $one;
- }
-
- // }}}
- // {{{ getRow()
-
- /**
- * Fetch the first row of data returned from a query. Takes care
- * of doing the query and freeing the results when finished.
- *
- * @param string $query the SQL query
- * @param array $types array that contains the types of the columns in
- * the result set
- * @param array $params array if supplied, prepare/execute will be used
- * with this array as execute parameters
- * @param array $param_types array that contains the types of the values
- * defined in $params
- * @param integer $fetchmode the fetch mode to use
- * @return mixed MDB2_OK or data array on success, a MDB2 error on failure
- * @access public
- */
- function getRow($query, $types = null, $params = array(),
- $param_types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT)
- {
- settype($params, 'array');
- if (count($params) == 0) {
- return $this->queryRow($query, $types, $fetchmode);
- }
-
- $prepared_query = $this->prepare($query, $param_types);
- if (MDB2::isError($prepared_query)) {
- return $prepared_query;
- }
-
- $result = $this->executeParams($prepared_query, $types, $params);
- if ($result == MDB2_OK || MDB2::isError($result)) {
- return $result;
- }
-
- $row = $result->fetchRow($fetchmode);
- $this->freePrepared($prepared_query);
- $result->free();
- return $row;
- }
-
- // }}}
- // {{{ getCol()
-
- /**
- * Fetch a single column from a result set and return it as an
- * indexed array.
- *
- * @param string $query the SQL query
- * @param string $type string that contains the type of the column in the
- * result set
- * @param array $params array if supplied, prepare/execute will be used
- * with this array as execute parameters
- * @param array $param_types array that contains the types of the values
- * defined in $params
- * @param mixed $colnum which column to return
- * @return mixed MDB2_OK or data array on success, a MDB2 error on failure
- * @access public
- */
- function getCol($query, $type = null, $params = array(),
- $param_types = null, $colnum = 0)
- {
- settype($params, 'array');
- if (count($params) > 0) {
- $result = $this->queryCol($query, $type, $colnum);
- }
-
- $prepared_query = $this->prepare($query, $param_types);
- if (MDB2::isError($prepared_query)) {
- return $prepared_query;
- }
-
- $result = $this->executeParams($prepared_query, $type, $params);
- if ($result == MDB2_OK || MDB2::isError($result)) {
- return $result;
- }
-
- $col = $result->fetchCol($colnum);
- $this->freePrepared($prepared_query);
- $result->free();
- return $col;
- }
-
- // }}}
- // {{{ getAll()
-
- /**
- * Fetch all the rows returned from a query.
- *
- * @param string $query the SQL query
- * @param array $types array that contains the types of the columns in
- * the result set
- * @param array $params array if supplied, prepare/execute will be used
- * with this array as execute parameters
- * @param array $param_types array that contains the types of the values
- * defined in $params
- * @param integer $fetchmode the fetch mode to use
- * @param boolean $rekey if set to true, the $all will have the first
- * column as its first dimension
- * @param boolean $force_array used only when the query returns exactly
- * two columns. If true, the values of the returned array will be
- * one-element arrays instead of scalars.
- * @param boolean $group if true, the values of the returned array is
- * wrapped in another array. If the same key value (in the first
- * column) repeats itself, the values will be appended to this array
- * instead of overwriting the existing values.
- * @return mixed MDB2_OK or data array on success, a MDB2 error on failure
- * @access public
- */
- function getAll($query, $types = null, $params = array(),
- $param_types = null, $fetchmode = MDB2_FETCHMODE_DEFAULT,
- $rekey = false, $force_array = false, $group = false)
- {
- settype($params, 'array');
- if (count($params) > 0) {
- return $this->queryAll($query, $types, $fetchmode, $rekey, $force_array, $group);
- }
-
- $prepared_query = $this->prepare($query, $param_types);
- if (MDB2::isError($prepared_query)) {
- return $prepared_query;
- }
-
- $result = $this->executeParams($prepared_query, $types, $params);
- if ($result == MDB2_OK || MDB2::isError($result)) {
- return $result;
- }
-
- $all = $result->fetchAll($result, $fetchmode, $rekey, $force_array, $group);
- $this->freePrepared($prepared_query);
- $result->free();
- return $all;
- }
-
- // }}}
// {{{ executeParams()
/**