Skip to content
Zimo Xiao edited this page May 30, 2018 · 7 revisions

sql::select

  • Name:

    select - do a SELECT query
  • Synopsis:

    sql::select($table)
  • Description:

    • Except for select()/fetch()/count(), everything is optional.
    • sql::select('table_name')
        ->where('a=? and b=?',[$a,$b])  //second parameter is optional
        ->limit([2,5])  //limit can be int
        ->order('a_column')
        ->by('desc')
        ->fetch();  
        //if you only need the number of results, use count() instead
        //the above code generates a query like this:
        //SELECT * FROM table_name WHERE a=? AND b=? LIMIT 2,5 ORDER a_column BY desc
    • returns: array (single layer if there is only one result)

sql::insert

  • Name:

    insert - insert data to SQL
  • Synopsis:

    sql::insert($table)
  • Description:

    • insert 2 arrays as seperate lines
    • sql::insert('table_name')->this([$array_1, $array_2]);
       //each array should match your table structure
    • returns: NULL

sql::update

  • Name:

    update - update data in SQL
  • Synopsis:

    sql::update($table)
  • Description:

    • //mode 1
      sql::update('table_name')->this([
          'column_name_1'=>'value_1',
          'column_name_2'=>'value_2'
      ])->where('a=? and b=?',[$a,$b])->limit(3)->execute();
      
      //mode 2
      sql::update('table_name')
        ->this('column_name_1 = "hi", column_name_2 = ?',[$value_2])
        ->execute();
    • returns: NULL

sql::delete

  • Name:

    delete - delete data
  • Synopsis:

    sql::delete($table)
  • Description:

    • sql::delete('table_name')->where('a=? and b=?',[$a,$b])->limit(3)->execute();
    • returns: NULL

sql::run

  • Name:

    run - run a query string
  • Synopsis:

    sql::run($query)
  • Description:

    • sql::run('select from a');
    • returns: NULL

Getting Started

Data Structure

Networking

Operations

Features

Clone this wiki locally