@@ -127,6 +127,18 @@ you can use ->results(); to convert to array or object as you config a "fetch"
127127 ```
128128 you can use `where` method an infinite :)
129129
130+ ### get last records (from last) :
131+
132+ to get last records in table just send seconde parameter to select method, or just first method to true
133+
134+ ```php
135+ $fromLast = $db->table('users')->select(true);
136+
137+ or
138+
139+ $fromLast = $db->table('users')->select(['id', 'name', 'email'], true);
140+ ```
141+
130142### where types :
131143- whereBetween($field, $values = [ ] ) :
132144 ``` php
@@ -368,7 +380,25 @@ var_dump($results->results());
368380now add to url this string query (?page=2 or 3 or 4 .. etc)
369381see (link() method to know how to generate navigation automatically)
370382
383+ <<<<<<< HEAD
371384### link() :
385+ =======
386+ - get last records (from last) :
387+
388+ to get last records in table just send seconde parameter to paginate method, or just first method to true
389+
390+ ``` php
391+ $fromLast = $db->table('users')->paginate(true);
392+
393+ or
394+
395+ $fromLast = $db->table('users')->paginate(20, true);
396+ ```
397+
398+
399+
400+ ### link :
401+ >>>>>>> origin/master
372402 create pagination list to navigate between pages
373403 * compatible with bootstrap and foundation frameworks
374404
@@ -399,6 +429,21 @@ echo $posts->link();
399429
400430```
401431
432+ <<<<<<< HEAD
433+ =======
434+ ## get last records (from last) :
435+
436+ to get last records in table after select or paginate
437+
438+ ``` php
439+ get last records
440+ $lastRecords = $db->table('users')->select()->last();
441+
442+ or get last 10 records
443+
444+ $lastRecords = $db->table('users')->select()->last(10);
445+ ```
446+ >>>>>>> origin/master
402447
403448you can echo out the results directlly that convert
404449the results to json format
@@ -418,6 +463,45 @@ foreach($results as $key => $value)
418463}
419464```
420465
466+ ## orderBy()
467+
468+ to order results " ORDER BY "
469+
470+ ``` php
471+ $db->table('posts')
472+ ->notIn('id', [1, 2, 3, 4, 5])
473+ ->orderBy('id', 'DESC)
474+ ->select();
475+
476+ // OR
477+
478+
479+ $db->table('posts')
480+ ->where('type', 'posts')
481+ ->orderBy('author', 'ASC')
482+ ->select();
483+ ```
484+
485+ plase note :
486+
487+ when you using " limit() with orderBy() " let limit() method after orderBy()
488+ for example :
489+
490+ ``php
491+
492+ // OK
493+ $db->table('posts')
494+ ->orderBy('id', 'DESC)
495+ ->limit(10)
496+ ->select();
497+
498+ // NO
499+ $db->table('posts')
500+ ->limit(10)
501+ ->orderBy('id', 'DESC)
502+ ->select();
503+ ```
504+
421505select(), first(), find(), paginate() methods
422506now return an instance of Collection class
423507
@@ -429,6 +513,18 @@ get last record selected
429513
430514$all = $db->table('my_table')->select();
431515var_dump($all->last());
516+
517+ to get last records in table after select or paginate
518+
519+ ```php
520+ get last records
521+ $lastRecords = $db->table('users')->select()->last();
522+
523+ or get last 10 records
524+
525+ $lastRecords = $db->table('users')->select()->last(10);
526+ ```
527+
432528```
433529
434530### all()
@@ -680,9 +776,16 @@ $db->table('users')->alterSchema(['drop', 'full_name'])->alter();
680776=============================
681777# Change Log
682778
779+ <<<<<<< HEAD
683780### 4.0.0
684781* MODIFY : namesace to ` PHPtricks\Orm `
685782* MODIFY : files structure
783+ =======
784+ ### 3.2.0
785+ * ADD : Order By (orderBy())
786+ * ADD : get Latest Data inserted into table
787+ * MODIFY : last() method to return last -n- recordes
788+ >>>>>>> origin/master
686789
687790### 3.1.0
688791* FIX : Duplicate connection
0 commit comments