Subversion Repositories PHPX

Rev

Rev 33 | Rev 41 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33 Rev 34
Line 93... Line 93...
93
  * depending on the underlying driver. May not be supported by all databases.
93
  * depending on the underlying driver. May not be supported by all databases.
94
  * @var string
94
  * @var string
95
  */
95
  */
96
  protected $_lastInsertId = '';
96
  protected $_lastInsertId = '';
97
 
97
 
-
 
98
  /**
-
 
99
   * Creates a new <code>Database</code> instance.
-
 
100
   *
-
 
101
   * Each of the parameters is optional and can also be given
-
 
102
   * by a protected property where the parameter name is preceded
-
 
103
   * by <code>_</code>.  Parameter values overwrite the default
-
 
104
   * property values.  It is recommended to use default property
-
 
105
   * values of inheriting classes except for small applications
-
 
106
   * and testing purposes.
-
 
107
   *
-
 
108
   * @param string $dsn
-
 
109
   * @param string $username
-
 
110
   * @param string $password
-
 
111
   * @param mixed $options
-
 
112
   */
98
  public function __construct()
113
  public function __construct($dsn = '', $username = null,
-
 
114
    $password = null, array $options = array())
99
  {
115
  {
-
 
116
    if ($dsn !== '')
-
 
117
    {
-
 
118
      $this->_dsn = $dsn;
-
 
119
    }
-
 
120
   
-
 
121
    if ($username !== null)
-
 
122
    {
-
 
123
      $this->_username = $username;
-
 
124
    }
-
 
125
   
-
 
126
    if ($password !== null)
-
 
127
    {
-
 
128
      $this->_password = $password;
-
 
129
    }
-
 
130
   
-
 
131
    if ($options)
-
 
132
    {
-
 
133
      $this->_options = $options;
-
 
134
    }
-
 
135
   
100
    $this->_connection =
136
    $this->_connection =
101
      new PDO($this->_dsn, $this->_username, $this->_password, $this->_options);
137
      new PDO($this->_dsn, $this->_username, $this->_password, $this->_options);
102
  }
138
  }
103
 
139
 
104
  /**
140
  /**
Line 386... Line 422...
386
422
387
    $params = array();
423
    $params = array();
388
   
424
   
389
    if (is_array($where) && $this->_isAssociativeArray($where))
425
    if (is_array($where) && $this->_isAssociativeArray($where))
390
    {
426
    {
-
 
427
      /* FIXME: Export and reuse this */
391
      foreach ($where as $column => $condition)
428
      foreach ($where as $column => $condition)
392
      {
429
      {
-
 
430
        /* TODO: Also handle function calls as keys */
393
        if (is_array($condition) && $this->_isAssociativeArray($condition))
431
        if (is_array($condition) && $this->_isAssociativeArray($condition))
394
        {
432
        {
395
          reset($condition);
433
          reset($condition);
396
          $condition = $condition[key($condition)];
434
          $condition = $condition[key($condition)];
397
         
435