@@ -35,7 +35,7 @@ require_once APPPATH.'/models/Model_app.php';
3535// extend the base class
3636class User_model extends Model_app {
3737
38- // create protected property, this mainly used for
38+ // create protected property, this mainly used for
3939 // table operation. So, be sure to put database table's name
4040 // for each model
4141 protected $table = 'users';
@@ -347,116 +347,116 @@ Array collection. Collection of dataset coming/fetching from database's table wi
347347// Example 1 : Using 1st parameter = WHERE and LIKE condition
348348// Availables where condition can be used is, where, where_in, or_where_in, where_not_in, or_where_not_in,or_where, having, or_having, like, like_before, like_after, or_like, or_like_before, or_like_after, not_like, not_like_before, not_like_after, or_not_like, or_not_like_before, or_not_like_after
349349
350- $where = array(
351- 'where' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
352- //'where_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
353- //'or_where_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
354- //'where_not_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
355- //'or_where_not_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
356- //'or_where' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
357- //'having' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
358- //'or_having' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
359- //'like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
360- //'like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
361- //'like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
362- //'or_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
363- //'or_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
364- //'or_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
365- //'not_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
366- //'not_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
367- //'not_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
368- //'or_not_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
369- //'or_not_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
370- //'or_not_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
371- );
372- $this->user_model->get_all_rows($where); // without specified table name or
373- $table = "users";
374- $this->user_model->get_all_rows($where, false, $table);
350+ $where = array(
351+ 'where' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
352+ //'where_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
353+ //'or_where_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
354+ //'where_not_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
355+ //'or_where_not_in' => array( 'id'=> [1, 2], 'email' => ['admin@admin.com'] ),
356+ //'or_where' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
357+ //'having' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
358+ //'or_having' => array('id !=' => 1, 'email =' => 'emi@emi.com' ),
359+ //'like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
360+ //'like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
361+ //'like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
362+ //'or_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
363+ //'or_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
364+ //'or_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
365+ //'not_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
366+ //'not_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
367+ //'not_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
368+ //'or_not_like' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
369+ //'or_not_like_before' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
370+ //'or_not_like_after' => array('name' => 'emi', 'email' => 'emi@emi.com' ),
371+ );
372+ $this->user_model->get_all_rows($where); // without specified table name or
373+ $table = "users";
374+ $this->user_model->get_all_rows($where, false, $table);
375375
376376-----------------------or---------------------------------
377377
378378
379379// Example 2 : Using 2nd paramter = Select all fields or certain fields
380- $fields = 'name, email'; // using string or
381- $fields = array( 'name','email'); // using index array if not provided, then select * is presumed
382- $this->user_model->get_all_rows( false, $fields );
380+ $fields = 'name, email'; // using string or
381+ $fields = array( 'name','email'); // using index array if not provided, then select * is presumed
382+ $this->user_model->get_all_rows( false, $fields );
383383
384384-----------------------or---------------------------------
385385
386386
387387// Example 3 : Using 3rd parameter = table name
388- $this->user_model->get_all_rows(); // this will select all the data inside user model's table if table did not provided OR
389- $table = "users";
390- $this->user_model->get_all_rows( false, false, $table);
388+ $this->user_model->get_all_rows(); // this will select all the data inside user model's table if table did not provided OR
389+ $table = "users";
390+ $this->user_model->get_all_rows( false, false, $table);
391391
392392-----------------------or---------------------------------
393393
394394
395395// Example 4 : Using 4th parameter = join single or multiple
396396// Available join are inner, left, right, left outer, right outer, join, outer, inner
397- $join = array(
398- // single table on particular join
399- 'join' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
400- 'inner' => array( 'users_groups' => 'users.id = users_groups.user_id'),
401- 'left' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
402- 'right' => array( 'users_groups' => 'users.id = users_groups.user_id'),
403- 'outer' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
404- 'left outer' => array( 'users_groups' => 'users.id = users_groups.user_id'),
405- 'right outer' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
406- // multiple table on particular join
407- 'join' => array(
408- 'groups' => 'users_groups.user_id = groups.id',
409- 'users_groups' => 'users.id = users_groups.user_id'
410- ),
411- 'inner' => array(
412- 'groups' => 'users_groups.user_id = groups.id',
413- 'users_groups' => 'users.id = users_groups.user_id'
414- ),
415- 'left' => array(
416- 'groups' => 'users_groups.user_id = groups.id',
417- 'users_groups' => 'users.id = users_groups.user_id'
418- ),
419- 'right' => array(
420- 'groups' => 'users_groups.user_id = groups.id',
421- 'users_groups' => 'users.id = users_groups.user_id'
422- ),
423- 'outer' => array(
424- 'groups' => 'users_groups.user_id = groups.id',
425- 'users_groups' => 'users.id = users_groups.user_id'
426- ),
427- 'left outer' => array(
428- 'groups' => 'users_groups.user_id = groups.id',
429- 'users_groups' => 'users.id = users_groups.user_id'
430- ),
431- 'right outer' => array(
432- 'groups' => 'users_groups.user_id = groups.id',
433- 'users_groups' => 'users.id = users_groups.user_id'
434- ),
435-
436- );
397+ $join = array(
398+ // single table on particular join
399+ 'join' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
400+ 'inner' => array( 'users_groups' => 'users.id = users_groups.user_id'),
401+ 'left' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
402+ 'right' => array( 'users_groups' => 'users.id = users_groups.user_id'),
403+ 'outer' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
404+ 'left outer' => array( 'users_groups' => 'users.id = users_groups.user_id'),
405+ 'right outer' => array( 'users_groups' => 'users.id = users_groups.user_id' ),
406+ // multiple table on particular join
407+ 'join' => array(
408+ 'groups' => 'users_groups.user_id = groups.id',
409+ 'users_groups' => 'users.id = users_groups.user_id'
410+ ),
411+ 'inner' => array(
412+ 'groups' => 'users_groups.user_id = groups.id',
413+ 'users_groups' => 'users.id = users_groups.user_id'
414+ ),
415+ 'left' => array(
416+ 'groups' => 'users_groups.user_id = groups.id',
417+ 'users_groups' => 'users.id = users_groups.user_id'
418+ ),
419+ 'right' => array(
420+ 'groups' => 'users_groups.user_id = groups.id',
421+ 'users_groups' => 'users.id = users_groups.user_id'
422+ ),
423+ 'outer' => array(
424+ 'groups' => 'users_groups.user_id = groups.id',
425+ 'users_groups' => 'users.id = users_groups.user_id'
426+ ),
427+ 'left outer' => array(
428+ 'groups' => 'users_groups.user_id = groups.id',
429+ 'users_groups' => 'users.id = users_groups.user_id'
430+ ),
431+ 'right outer' => array(
432+ 'groups' => 'users_groups.user_id = groups.id',
433+ 'users_groups' => 'users.id = users_groups.user_id'
434+ ),
435+
436+ );
437437
438438-----------------------or---------------------------------
439439
440440
441441// Example 5 : Using 5th parameter = Order by result
442- $orderBy = 'name asc, id desc'; // or
443- $orderBy = array( 'name' => 'asc', 'id' => 'desc' );
444- $this->user_model->get_all_rows( false, false, false, false, $orderBy );
442+ $orderBy = 'name asc, id desc'; // or
443+ $orderBy = array( 'name' => 'asc', 'id' => 'desc' );
444+ $this->user_model->get_all_rows( false, false, false, false, $orderBy );
445445
446446-----------------------or---------------------------------
447447
448448
449449// Example 6 : Using 6th parameter = group by result
450- $groupBy = 'name'; // or $groupBy = array( 'name', 'id' );
451- $this->user_model->get_all_rows( false, false, false, false, false, $groupBy );
450+ $groupBy = 'name'; // or $groupBy = array( 'name', 'id' );
451+ $this->user_model->get_all_rows( false, false, false, false, false, $groupBy );
452452
453453-----------------------or---------------------------------
454454
455455
456456// Example 7 : Using 7th parameter = limit the result
457- $limit = '20'; // limit only
458- $limit = [10 => 20]; // limit and offset, key is a limit, values is an offset
459- $this->user_model->get_all_rows( false, false, false, false, false, false, $limit );
457+ $limit = '20'; // limit only
458+ $limit = [10 => 20]; // limit and offset, key is a limit, values is an offset
459+ $this->user_model->get_all_rows( false, false, false, false, false, false, $limit );
460460```
461461
462462### h) get_specified_row( $where[ , $fields, $table, $join, $orderBy, $groupBy, $limit ] )
0 commit comments