Jump to content

  • twitter
  • youtube
  • googleplus
  • facebook
  • rss
  • newsletter


Tutorial info Visit support topic

  • Added on: Feb 25 2009 04:38 AM
  • Views: 4591
 


[IPB 3.0.x] Database Queries

A few basic examples of IPB built in database class.

Posted by Michael on Feb 25 2009 04:38 AM
IP.Board 3.30.x comes with a built in database class. This will perform just about any database query you may have. Below are some of the basics.

Database Select
$this->DB->build( array( 'select' => '*', 'from' => 'db_table' ) ); 
  $this->DB->execute();
  $r = $this->DB->fetch();

Database Insert
$this->DB->insert( 'db_table', array ( 'row1' => "row1", 'row2' => "row2", 'row3' => "row3", ) );

Database Delete
$this->DB->delete( 'db_table', 'id=1' );

You can also add different code to your query, including where, order and limit.

Where
'where' => 'id=1'

Order
'order' => 'date DESC'

Limit
'limit' => array(0,1)


Some areas of IP.Board 3 may require you to setup the DB object at the construct like so.

$this->DB	   = $this->registry->DB();

Powered by Tutorials 1.4.1 © 2012, by Michael McCune