Ejemplo n.º 1
0
<?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>";
Ejemplo n.º 2
0
 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;
 }