Coder Social home page Coder Social logo

class-php-for-back-end's Introduction

Class PHP

this class for back end php, you can use this class for function in sistem, and then CRUD (Create Read update Delete) for your sistem.

Requirements

  • Mysqli
  • PHP 5.2+

How to Use

User for select one data

 public function name_function( $param )
 {
   self::$db->where('name_field', $param);
 	$row = self::$db->getOne('table_name', 'value');
 	if( $row != false ){
 		return $row->value;
 	} else
 		return;
 }

User for select all data

 public function name_function( )
 {
  $tbl = 'table_name';
  $cols  = '*';
  $row = self::$db->get($tbl, null, $cols);
  
  if($row != false){
     return $row;
  } else {
     return false;
  }
 }

User for select data with join and group by

 public function name_function( )
 {
   $tbl = 'table_name1 AS tbl1';

			$cols  = '*';

			self::$db->join('table_name2 AS tbl2', 'tbl1.id = tbl2.no', 'LEFT');
			self::$db->groupBy('tbl1.id');
			$row = self::$db->get($tbl, null, $cols);

			if($row != false){
				return $row;
			} else {
				return false;
			}
 }

If you want to use LEFT JOIN in parameter you must make LEFT, if RIGHT parameter is RIGHT and if inner join, this parameter is none

Use for insert data

 public function name_function( $param )
 {
  arrs = array(
				'val1' => $val1,
				'val2' => $val2,
				'val3' => $val3,
				'val4' => $val4
			);

			self::$db->insert('table_name', arrs);
			self::$db->getInsertId();
 }

Use for update data

 public function name_function( $param )
 {
  self::$db->where('id', $param);
	 self::$db->delete('table_name');
	}

Use for delete data

 public function name_function( $param )
 {
  self::$db->where('id', $param);
		self::$db->delete('table_name');
	}

class-php-for-back-end's People

Contributors

andrimaruf avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.