Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 3... Line 3...
3
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
Line 4... Line 4...
4
 
4
 
5
/**
5
/**
6
 * Provides an object interface to a table row
6
 * Provides an object interface to a table row
7
 *
7
 *
8
 * PHP versions 4 and 5
8
 * PHP version 5
9
 *
9
 *
10
 * LICENSE: This source file is subject to version 3.0 of the PHP license
10
 * LICENSE: This source file is subject to version 3.0 of the PHP license
11
 * that is available through the world-wide-web at the following URI:
11
 * that is available through the world-wide-web at the following URI:
12
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
12
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
13
 * the PHP License and are unable to obtain it through the web, please
13
 * the PHP License and are unable to obtain it through the web, please
14
 * send a note to license@php.net so we can mail you a copy immediately.
14
 * send a note to license@php.net so we can mail you a copy immediately.
15
 *
15
 *
16
 * @category   Database
16
 * @category   Database
17
 * @package    DB
17
 * @package    DB
18
 * @author     Stig Bakken <stig@php.net>
18
 * @author     Stig Bakken <stig@php.net>
19
 * @copyright  1997-2005 The PHP Group
19
 * @copyright  1997-2007 The PHP Group
20
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
20
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
21
 * @version    CVS: $Id: storage.php,v 1.21 2005/02/02 02:54:51 danielc Exp $
21
 * @version    CVS: $Id$
22
 * @link       http://pear.php.net/package/DB
22
 * @link       http://pear.php.net/package/DB
Line 23... Line 23...
23
 */
23
 */
24
 
24
 
Line 34... Line 34...
34
 * statements.
34
 * statements.
35
 *
35
 *
36
 * @category   Database
36
 * @category   Database
37
 * @package    DB
37
 * @package    DB
38
 * @author     Stig Bakken <stig@php.net>
38
 * @author     Stig Bakken <stig@php.net>
39
 * @copyright  1997-2005 The PHP Group
39
 * @copyright  1997-2007 The PHP Group
40
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
40
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
41
 * @version    Release: 1.7.6
41
 * @version    Release: 1.9.2
42
 * @link       http://pear.php.net/package/DB
42
 * @link       http://pear.php.net/package/DB
43
 */
43
 */
44
class DB_storage extends PEAR
44
class DB_storage extends PEAR
45
{
45
{
46
    // {{{ properties
46
    // {{{ properties
Line 92... Line 92...
92
     * each new value, called with three parameters: the name of the
92
     * each new value, called with three parameters: the name of the
93
     * field/column that is changing, a reference to the new value and
93
     * field/column that is changing, a reference to the new value and
94
     * a reference to this object
94
     * a reference to this object
95
     *
95
     *
96
     */
96
     */
97
    function DB_storage($table, $keycolumn, &$dbh, $validator = null)
97
    function __construct($table, $keycolumn, &$dbh, $validator = null)
98
    {
98
    {
99
        $this->PEAR('DB_Error');
99
        $this->PEAR('DB_Error');
100
        $this->_table = $table;
100
        $this->_table = $table;
101
        $this->_keycolumn = $keycolumn;
101
        $this->_keycolumn = $keycolumn;
102
        $this->_dbh = $dbh;
102
        $this->_dbh = $dbh;
Line 291... Line 291...
291
     * @return object a new instance of DB_storage or a subclass of it
291
     * @return object a new instance of DB_storage or a subclass of it
292
     */
292
     */
293
    function &create($table, &$data)
293
    function &create($table, &$data)
294
    {
294
    {
295
        $classname = strtolower(get_class($this));
295
        $classname = strtolower(get_class($this));
296
        $obj =& new $classname($table);
296
        $obj = new $classname($table);
297
        foreach ($data as $name => $value) {
297
        foreach ($data as $name => $value) {
298
            $obj->_properties[$name] = true;
298
            $obj->_properties[$name] = true;
299
            $obj->$name = &$value;
299
            $obj->$name = &$value;
300
        }
300
        }
301
        return $obj;
301
        return $obj;
Line 443... Line 443...
443
     *
443
     *
444
     * @return DB_OK or a DB error
444
     * @return DB_OK or a DB error
445
     */
445
     */
446
    function store()
446
    function store()
447
    {
447
    {
-
 
448
        $params = array();
-
 
449
        $vars = array();
448
        foreach ($this->_changes as $name => $foo) {
450
        foreach ($this->_changes as $name => $foo) {
449
            $params[] = &$this->$name;
451
            $params[] = &$this->$name;
450
            $vars[] = $name . ' = ?';
452
            $vars[] = $name . ' = ?';
451
        }
453
        }
452
        if ($vars) {
454
        if ($vars) {