Nooku Framework is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

nooku-framework

Commit 2225

User picture
  • Author: johanjanssens
  • 2010-06-17 14:59 (almost 4 years ago)

re #3 : Added KDatabaseRowAbstract::count and load functions. The load function will try to load a row from the database using row data, while the count function will count the rows in the table that match the row data.

Files Affected

 
22242225
181
        $this->_table = $identifier;
181
        $this->_table = $identifier;
182
        return $this;
182
        return $this;
183
    }
183
    }
184
 
184
    
 
 
185
    /**
 
 
186
     * Load the row from the database.
 
 
187
     *
 
 
188
     * @return KDatabaseRowAbstract
 
 
189
     */
 
 
190
    public function load()
 
 
191
    {
 
 
192
        $table = KFactory::get($this->getTable());
 
 
193
        
 
 
194
        //Filter the data
 
 
195
        $data  = $table->filter($this->getData(true), true);
 
 
196
        
 
 
197
        //Select the row
 
 
198
        $row = $table->select($data, KDatabase::FETCH_ROW);
 
 
199
        
 
 
200
        //Set the data if the row was found
 
 
201
        if(!$row->isNew()) 
 
 
202
        {
 
 
203
            $this->setData($row->getData(), false);
 
 
204
            $this->_modified = array();
 
 
205
            $this->_new      = false;
 
 
206
        }
 
 
207
        
 
 
208
        return $this;
 
 
209
    }
 
 
210
    
185
    /**
211
    /**
186
     * Saves the row to the database.
212
     * Saves the row to the database.
187
     *
213
     *
...
 
...
 
246
 
272
 
247
        return $this;
273
        return $this;
248
    }
274
    }
 
 
275
 
 
 
276
    /**
 
 
277
     * Count the rows in the database based on the data in the row
 
 
278
     *
 
 
279
     * @return KDatabaseRowAbstract
 
 
280
     */
 
 
281
    public function count()
 
 
282
    {
 
 
283
        $data = KFactory::get($this->getTable())
 
 
284
                    ->filter($this->getData(true), true);
 
 
285
 
 
 
286
        return KFactory::get($this->getTable())->count($data);
 
 
287
    }
249
 
288
 
250
    /**
289
    /**
251
     * Retrieve row field value
290
     * Retrieve row field value
22242225
26
     */
26
     */
27
    public function getStatus();
27
    public function getStatus();
28
 
28
 
 
 
29
    /**
 
 
30
     * Load the row from the database.
 
 
31
     *
 
 
32
     * @return KDatabaseRowAbstract
 
 
33
     */
 
 
34
    public function load();
 
 
35
 
29
    /**
36
    /**
30
     * Saves the row to the database.
37
     * Saves the row to the database.
31
     *
38
     *
...
 
...
 
42
     * @return KDatabaseRowInterface
49
     * @return KDatabaseRowInterface
43
     */
50
     */
44
    public function delete();
51
    public function delete();
 
 
52
 
 
 
53
    /**
 
 
54
     * Count the rows in the database based on the data in the row
 
 
55
     *
 
 
56
     * @return KDatabaseRowAbstract
 
 
57
     */
 
 
58
    public function count();
45
 
59
 
46
    /**
60
    /**
47
     * Resets to the default properties
61
     * Resets to the default properties