db::join PHP Method

join() static public method

Joins two tables and returns data from them
static public join ( string $table_1, string $table_2, string $on, mixed $select, mixed $where = null, string $order = null, integer $page = null, integer $limit = null, string $type = "JOIN" ) : mixed
$table_1 string The table name of the first table
$table_2 string The table name of the second table
$on string The MySQL ON clause without the ON keyword. ie: "user_id = comment_user"
$select mixed Either an array of fields or a MySQL string of fields
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
$order string Order clause without the order keyword. ie: "added desc"
$page integer a page number
$limit integer a number for rows to return
$type string The join type (JOIN, LEFT, RIGHT, INNER)
return mixed
    static function join($table_1, $table_2, $on, $select, $where = null, $order = null, $page = null, $limit = null, $type = "JOIN")
    {
        return self::select(self::prefix($table_1) . ' ' . $type . ' ' . self::prefix($table_2) . ' ON ' . self::where($on), $select, self::where($where), $order, $page, $limit);
    }

Usage Example

Example #1
0
 function view()
 {
     db::table('info_files');
     db::join('info_sections', 'info_files', 'section_id');
     $r = db::select();
     while ($a = mysql_fetch_assoc($r)) {
         //$a = filter::get('item_pub', array('unpub', 'pub'), $a);
         s::roll('items', $a);
     }
 }
All Usage Examples Of db::join