Inquire
Public Function Select () {
/**
Data Sheet
CREATE TABLE ' Student ' (
' id ' int (one) not NULL auto_increment,
' Name ' varchar (255) DEFAULT NULL,
' Age ' int (one) DEFAULT NULL,
' Sex ' varchar (255) DEFAULT ' 1 ',
' Create_at ' int (one) DEFAULT ' 0 ',
' Score ' int (3) DEFAULT ' 0 ' COMMENT ' fraction ',
' class_id ' int (one) DEFAULT NULL COMMENT ' class ID ',
PRIMARY KEY (' id ')
) Engine=myisam auto_increment=11 DEFAULT Charset=utf8;
CREATE TABLE ' Student_class ' (
' class_id ' int (one) not NULL auto_increment,
' title ' varchar (255) DEFAULT NULL,
' Is_show ' int (one) DEFAULT NULL,
PRIMARY KEY (' class_id ')
) Engine=myisam auto_increment=4 DEFAULT Charset=utf8;
*/
$students = db::table (' student ')->select (' name as user_name ')->get ();
$user = db::table (' student ')->where (' name ', ' Try ')->first ();
$name = db::table (' student ')->where ([' name ' = ' Try '])->pluck (' name ');
$lists = db::table (' student ')->lists (' name ');
$users = db::table (' Student ')->where (' Age ', ' > ', ')->orwhere (' sex ', ' = ', 0)->get ();
$users = db::table (' Student ')->wherebetween (' Score ', Array (84,100))->get ();
$users = db::table (' Student ')->wherein (' Score ', Array (85,95))->get ();
$users = db::table (' Student ')->wherenull (' score ')->get ();
$users = db::table (' Student ')->orderby (' Score ', ' desc ')->having (' Score ', ' > ', ")->get ();
$users = db::table (' Student ')->join (' Student_class ', ' student_class.class_id ', ' = ', ' student.class_id ')->get ( );
$users = db::table (' Student ')->count ();
$score = db::table (' Student ')->max (' score ');
$score = db::table (' Student ')->where (' id ', 1)->sum (' score ', ' + ', ' age ');
Insert operation-BULK INSERT
/* $id = db::table (' Student ')->insert (
Array
Array (' name ' = ' Xiaohua ', ' age ' =>8, ' sex ' =>0, ' score ' =>33),
Array (' name ' = ' Xiaocao ', ' age ' =>9, ' sex ' =>0, ' score ' =>82)
)
);*/
$id = db::table (' Student ')->where (' id ', 5)->update (Array (' Sex ' =>1));
$id = db::table (' Student ')->where (' name ', ' Xiaocao ')->delete ();
$first = db::table (' Student ')->wherenull (' class_id ');
$users = db::table (' Student ')->wherenull (' score ')->union ($first)->get ();
$lock = db::table (' Student ')->where (' Score ', ' > ',
->sharedlock ()->get ();
$lock _update = db::table (' Student ')->where (' Score ', ' > ')->lockforupdate ()->get ();
DD ($lock _update);
}
Laravel database-Adding and deleting changes