ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:activerecord:getactiverecordsclass

This is an old revision of the document!


getActiveRecords

syntax
 mixed getActiveRecords(
	string $tableName,
	optional string  $where=false,
	optional mixed[] $bindarr=false,
	optional mixed[] $primaryKeyArray=false
)

/**

 * GetActiveRecordsClass Performs an 'ALL' query 
 * 
 * @param mixed $class This string represents the class of the current active record
 * @param mixed $table Table used by the active record object
 * @param mixed $whereOrderBy Where, order, by clauses
 * @param mixed $bindarr 
 * @param mixed $primkeyArr 
 * @param array $extra Query extras: limit, offset...
 * @param mixed $relations Associative array: table's foreign name, "hasMany", "belongsTo"
 * @access public
 * @return void
 */
function GetActiveRecordsClass(
		$class, $table,$whereOrderBy=false,$bindarr=false, $primkeyArr=false,
		$extra=array(),
		$relations=array())
{
global $_ADODB_ACTIVE_DBS;
	## reduce overhead of adodb.inc.php -- moved to adodb-active-record.inc.php
	## if adodb-active-recordx is loaded -- should be no issue as they will probably use Find()
	if (!isset($_ADODB_ACTIVE_DBS))include_once(ADODB_DIR.'/adodb-active-record.inc.php');
	return adodb_GetActiveRecordsClass($this, $class, $table, $whereOrderBy, $bindarr, $primkeyArr, $extra, $relations);
}

function GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false)
{
	$arr = $this->GetActiveRecordsClass('ADODB_Active_Record', $table, $where, $bindarr, $primkeyArr);
	return $arr;
}

Description

Usage

include 'adodb/adodb.inc.php';
include 'adodb/adodb-activerecord.inc.php';
 
$db = NewADOConnection('mysqli');
$db->connect('','user','password','employees');
 
$activeRecs = $db->GetActiveRecords('departments');
 
v5/activerecord/getactiverecordsclass.1449264934.txt.gz · Last modified: 2017/04/21 11:21 (external edit)