本文整理汇总了PHP中ADORecordSet_array类的典型用法代码示例。如果您正苦于以下问题:PHP ADORecordSet_array类的具体用法?PHP ADORecordSet_array怎么用?PHP ADORecordSet_array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ADORecordSet_array类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_find_on_association_with_conditions_array_sql
public function test_find_on_association_with_conditions_array_sql()
{
$this->installAndIncludeModels(array('Friend' => 'id,name'));
$Mary =& $this->Friend->create(array('name' => 'Mary'));
$Mary->friend->add($this->Friend->create(array('name' => 'James')));
//$db = new AkDbAdapter(array()); // no conection details, we're using a Mock
Mock::generate('ADOConnection');
$connection = new MockADOConnection();
$result = new ADORecordSet_array(-1);
$result->InitArray(array(array('id' => 1, 'name' => 'James')), array('id' => 'I', 'name' => 'C'));
$connection->setReturnValue('Execute', $result);
if ($Mary->_db->type() == 'sqlite') {
$connection->expectAt(0, 'Execute', array('SELECT friends.* FROM friends LEFT OUTER JOIN friends_friends AS _FriendFriend ON _FriendFriend.related_id = friends.id LEFT OUTER JOIN friends AS _Friend ON _FriendFriend.friend_id = _Friend.id WHERE (friends.name = ?) AND (_FriendFriend.friend_id LIKE 1) AND 1', array('James')));
} else {
$connection->expectAt(0, 'Execute', array('SELECT friends.* FROM friends LEFT OUTER JOIN friends_friends AS _FriendFriend ON _FriendFriend.related_id = friends.id LEFT OUTER JOIN friends AS _Friend ON _FriendFriend.friend_id = _Friend.id WHERE (friends.name = ?) AND (_FriendFriend.friend_id = 1)', array('James')));
}
$oldConnection = $Mary->_db->connection;
$Mary->_db->connection =& $connection;
//$Mary->_db = $db;
$Mary->friend->find(array('conditions' => array('name = ?', 'James')));
$Mary->_db->connection = $oldConnection;
}
示例2: ADORecordSet_array
<?php
include_once '../adodb.inc.php';
$rs = new ADORecordSet_array();
$array = array(array('Name', 'Age'), array('John', '12'), array('Jill', '8'), array('Bill', '49'));
$typearr = array('C', 'I');
$rs->InitArray($array, $typearr);
while (!$rs->EOF) {
print_r($rs->fields);
echo "<br>";
$rs->MoveNext();
}
echo "<hr> 1 Seek<br>";
$rs->Move(1);
while (!$rs->EOF) {
print_r($rs->fields);
echo "<br>";
$rs->MoveNext();
}
echo "<hr> 2 Seek<br>";
$rs->Move(2);
while (!$rs->EOF) {
print_r($rs->fields);
echo "<br>";
$rs->MoveNext();
}
echo "<hr> 3 Seek<br>";
$rs->Move(3);
while (!$rs->EOF) {
print_r($rs->fields);
echo "<br>";
示例3: xmlrpcval2rs
/**
* Given a well-formed xmlrpc struct object returns an AdoDB object
*
* @todo add some error checking on the input value
*/
function xmlrpcval2rs(&$xmlrpcval)
{
$fields_array = array();
$data_array = array();
// rebuild column information
$header = $xmlrpcval->structmem('header');
$numfields = $header->structmem('fieldcount');
$numfields = $numfields->scalarval();
$numrecords = $header->structmem('recordcount');
$numrecords = $numrecords->scalarval();
$sqlstring = $header->structmem('sql');
$sqlstring = $sqlstring->scalarval();
$fieldinfo = $header->structmem('fieldinfo');
for ($i = 0; $i < $numfields; $i++) {
$temp = $fieldinfo->arraymem($i);
$fld = new ADOFieldObject();
while (list($key, $value) = $temp->structeach()) {
if ($key == "name") {
$fld->name = $value->scalarval();
}
if ($key == "type") {
$fld->type = $value->scalarval();
}
if ($key == "max_length") {
$fld->max_length = $value->scalarval();
}
if ($key == "not_null") {
$fld->not_null = $value->scalarval();
}
if ($key == "has_default") {
$fld->has_default = $value->scalarval();
}
if ($key == "default_value") {
$fld->default_value = $value->scalarval();
}
}
// while
$fields_array[] = $fld;
}
// for
// fetch recordset information into php array
$body = $xmlrpcval->structmem('body');
for ($i = 0; $i < $numrecords; $i++) {
$data_array[$i] = array();
$xmlrpcrs_row = $body->arraymem($i);
for ($j = 0; $j < $numfields; $j++) {
$temp = $xmlrpcrs_row->arraymem($j);
$data_array[$i][$j] = $temp->scalarval();
}
// for j
}
// for i
// finally build in-memory recordset object and return it
$rs = new ADORecordSet_array();
$rs->InitArrayFields($data_array, $fields_array);
return $rs;
}
示例4: strpos
//.........这里部分代码省略.........
$rs->affectedrows = (int) $meta[3];
$rs->insertid = $meta[4];
return $rs;
}
# If detect timeout here return false, forcing a fresh query and new cache values
#
# Under high volume loads, we want only 1 thread/process to _write_file
# so that we don't have 50 processes queueing to write the same data.
#
# We implement a probabilistic blocking write:
#
# -2 sec before timeout, give processes 1/16 chance of writing to file with blocking io
# -1 sec after timeout give processes 1/4 chance of writing with blocking
# +0 sec after timeout, give processes 100% chance writing with blocking
if (sizeof($meta) > 1) {
if ($timeout > 0) {
$tdiff = $meta[1] + $timeout - time();
if ($tdiff <= 2) {
switch ($tdiff) {
case 2:
if ((rand() & 0xf) == 0) {
fclose($fp);
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 0x3) == 0) {
fclose($fp);
$err = "Timeout 1";
return false;
}
break;
default:
fclose($fp);
$err = "Timeout 0";
return false;
}
// switch
}
// if check flush cache
}
// (timeout>0)
$ttl = $meta[1];
}
$meta = false;
$meta = fgetcsv($fp, 16000, ",");
if (!$meta) {
fclose($fp);
$err = "Unexpected EOF 1";
return false;
}
}
// Get Column definitions
$flds = array();
foreach ($meta as $o) {
$o2 = explode(':', $o);
if (sizeof($o2) != 3) {
$arr[] = $meta;
$flds = false;
break;
}
$fld = new ADOFieldObject();
$fld->name = urldecode($o2[0]);
$fld->type = $o2[1];
$fld->max_length = $o2[2];
$flds[] = $fld;
}
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
return false;
}
// slurp in the data
$MAXSIZE = 128000;
$text = fread($fp, $MAXSIZE);
$cnt = 1;
while (strlen($text) == $MAXSIZE * $cnt) {
$text .= fread($fp, $MAXSIZE);
$cnt += 1;
}
fclose($fp);
//print "<hr>";
//print_r($text);
//if (strlen($text) == 0) $arr = array();
//else
$arr = unserialize($text);
//print_r($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF (in serialized recordset)";
if (get_magic_quotes_runtime()) {
$err .= ". Magic Quotes Runtime should be disabled!";
}
return false;
}
$rs = new ADORecordSet_array();
$rs->timeCreated = $ttl;
$rs->InitArrayFields($arr, $flds);
return $rs;
}
示例5: flock
//.........这里部分代码省略.........
fclose($fp);
return false;
}
fclose($fp);
if ($timeout > 0) {
$err = ' Timeout for insert/update/delete illegal';
return false;
}
$val = 1;
$rs = new ADORecordSet($val);
$rs->EOF = true;
$rs->_numOfFields = 0;
$rs->sql = urldecode($meta[2]);
$rs->affectedrows = (int) $meta[3];
$rs->insertid = $meta[4];
$rs->aa = '100';
return $rs;
}
# Under high volume loads, we want only 1 thread/process to _write_file
# so that we don't have 50 processes queueing to write the same data.
# Would require probabilistic blocking write
#
# -2 sec before timeout, give processes 1/16 chance of writing to file with blocking io
# -1 sec after timeout give processes 1/4 chance of writing with blocking
# +0 sec after timeout, give processes 100% chance writing with blocking
if (sizeof($meta) > 1) {
if ($timeout > 0) {
$tdiff = $meta[1] + $timeout - time();
if ($tdiff <= 2) {
switch ($tdiff) {
case 2:
if ((rand() & 15) == 0) {
fclose($fp);
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 3) == 0) {
fclose($fp);
$err = "Timeout 1";
return false;
}
break;
default:
fclose($fp);
$err = "Timeout 0";
return false;
}
// switch
}
// if check flush cache
}
// (timeout>0)
$ttl = $meta[1];
}
$meta = fgetcsv($fp, 8192, ",");
if (!$meta) {
fclose($fp);
$err = "Unexpected EOF 1";
return false;
}
}
// Get Column definitions
$flds = array();
foreach ($meta as $o) {
$o2 = explode(':', $o);
if (sizeof($o2) != 3) {
$arr[] = $meta;
$flds = false;
break;
}
$fld = new ADOFieldObject();
$fld->name = urldecode($o2[0]);
$fld->type = $o2[1];
$fld->max_length = $o2[2];
$flds[] = $fld;
}
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
//print "$url ";print_r($meta);
//die();
return false;
}
// slurp in the data
$text = fread($fp, MAX_BLOB_SIZE);
fclose($fp);
//$text = substr($text,0,44);
$arr = @unserialize($text);
//var_dump($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF 3";
return false;
}
$rs = new ADORecordSet_array();
$rs->timeCreated = $ttl;
$rs->InitArrayFields($arr, $flds);
return $rs;
}
示例6: array
function &_rs2rs(&$rs, $nrows = -1, $offset = -1)
{
$arr =& $rs->GetArrayLimit($nrows, $offset);
$flds = array();
for ($i = 0, $max = $rs->FieldCount(); $i < $max; $i++) {
$flds[] =& $rs->FetchField($i);
}
$rs->Close();
$rs2 = new ADORecordSet_array();
$rs2->InitArrayFields($arr, $flds);
return $rs2;
}
示例7: csv2rs
//.........这里部分代码省略.........
$err = "Timeout 3";
return false;
}
break;
case 2:
if ((rand() & 15) == 0) {
fclose($fp);
$err = "Timeout 2";
return false;
}
break;
case 1:
if ((rand() & 3) == 0) {
fclose($fp);
$err = "Timeout 1";
return false;
}
break;
default:
fclose($fp);
$err = "Timeout 0";
return false;
}
// switch
}
// if check flush cache
}
// (timeout>0)
$ttl = $meta[1];
}
//================================================
// new cache format - use serialize extensively...
if ($meta[0] === '====1') {
// slurp in the data
$MAXSIZE = 128000;
$text = fread($fp, $MAXSIZE);
if (strlen($text)) {
while ($txt = fread($fp, $MAXSIZE)) {
$text .= $txt;
}
}
fclose($fp);
$rs = unserialize($text);
if (is_object($rs)) {
$rs->timeCreated = $ttl;
} else {
$err = "Unable to unserialize recordset";
//echo htmlspecialchars($text),' !--END--!<p>';
}
return $rs;
}
$meta = false;
$meta = fgetcsv($fp, 32000, ",");
if (!$meta) {
fclose($fp);
$err = "Unexpected EOF 1";
return false;
}
}
// Get Column definitions
$flds = array();
foreach ($meta as $o) {
$o2 = explode(':', $o);
if (sizeof($o2) != 3) {
$arr[] = $meta;
$flds = false;
break;
}
$fld = new ADOFieldObject();
$fld->name = urldecode($o2[0]);
$fld->type = $o2[1];
$fld->max_length = $o2[2];
$flds[] = $fld;
}
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
return false;
}
// slurp in the data
$MAXSIZE = 128000;
$text = '';
while ($txt = fread($fp, $MAXSIZE)) {
$text .= $txt;
}
fclose($fp);
@($arr = unserialize($text));
//var_dump($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF (in serialized recordset)";
if (get_magic_quotes_runtime()) {
$err .= ". Magic Quotes Runtime should be disabled!";
}
return false;
}
$rs = new ADORecordSet_array();
$rs->timeCreated = $ttl;
$rs->InitArrayFields($arr, $flds);
return $rs;
}
示例8: UnixTimeStamp
static function UnixTimeStamp($v)
{
global $ADODB_sybase_mths;
//11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
//Changed [0-9] to [0-9 ] in day conversion
if (!preg_match("/([A-Za-z]{3})[-/\\. ]([0-9 ]{1,2})[-/\\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})/", $v, $rr)) {
return parent::UnixTimeStamp($v);
}
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) {
return 0;
}
$themth = substr(strtoupper($rr[1]), 0, 3);
$themth = $ADODB_sybase_mths[$themth];
if ($themth <= 0) {
return false;
}
switch (strtoupper($rr[6])) {
case 'P':
if ($rr[4] < 12) {
$rr[4] += 12;
}
break;
case 'A':
if ($rr[4] == 12) {
$rr[4] = 0;
}
break;
default:
break;
}
// h-m-s-MM-DD-YY
return adodb_mktime($rr[4], $rr[5], 0, $themth, $rr[2], $rr[3]);
}
示例9: UnixTimeStamp
function UnixTimeStamp($v)
{
if (is_numeric(substr($v, 0, 1)) && ADODB_PHPVER >= 0x4200) {
return parent::UnixTimeStamp($v);
}
global $ADODB_mssql_mths, $ADODB_mssql_date_order;
//Dec 30 2000 12:00AM
if ($ADODB_mssql_date_order == 'dmy') {
if (!preg_match("|^([0-9]{1,2})[-/\\. ]+([A-Za-z]{3})[-/\\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|", $v, $rr)) {
return parent::UnixTimeStamp($v);
}
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) {
return 0;
}
$theday = $rr[1];
$themth = substr(strtoupper($rr[2]), 0, 3);
} else {
if (!preg_match("|^([A-Za-z]{3})[-/\\. ]+([0-9]{1,2})[-/\\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|", $v, $rr)) {
return parent::UnixTimeStamp($v);
}
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) {
return 0;
}
$theday = $rr[2];
$themth = substr(strtoupper($rr[1]), 0, 3);
}
$themth = $ADODB_mssql_mths[$themth];
if ($themth <= 0) {
return false;
}
switch (strtoupper($rr[6])) {
case 'P':
if ($rr[4] < 12) {
$rr[4] += 12;
}
break;
case 'A':
if ($rr[4] == 12) {
$rr[4] = 0;
}
break;
default:
break;
}
// h-m-s-MM-DD-YY
return mktime($rr[4], $rr[5], 0, $themth, $theday, $rr[3]);
}
示例10:
function __construct(&$conn, $mode = false)
{
parent::__construct();
$this->InitArray($conn->_rezarray, $conn->_reztypes, $conn->_reznames);
$conn->_rezarray = false;
}
示例11:
function __construct($id = -1, $mode = false)
{
parent::__construct($id, $mode);
}