当前位置: 首页>>代码示例>>PHP>>正文


PHP R::convertToBeans方法代码示例

本文整理汇总了PHP中R::convertToBeans方法的典型用法代码示例。如果您正苦于以下问题:PHP R::convertToBeans方法的具体用法?PHP R::convertToBeans怎么用?PHP R::convertToBeans使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::convertToBeans方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContactosJustNamesByClientId

function getContactosJustNamesByClientId($clientid)
{
    $rows = R::getAll("select c.id, c.clientes_id, c.nombre from contactos c where c.clientes_id=?", array($clientid));
    $contactos = R::convertToBeans('contactos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($contactos));
}
开发者ID:eluar,项目名称:shipping_app,代码行数:9,代码来源:contactos.php

示例2: getSegmentosJustNames

function getSegmentosJustNames($clientid)
{
    $app = \Slim\Slim::getInstance();
    $rows = R::getAll("select s.id, s.clientes_id, s.nombre from segmento s where s.clientes_id=?", array($clientid));
    $segmentos = R::convertToBeans('segmentos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($segmentos));
}
开发者ID:eluar,项目名称:shipping_app,代码行数:10,代码来源:segmentos.php

示例3: function

// handle GET requests for /vehiculos
$app->get('/vehiculos', function () use($app) {
    // query database for all vehiculos
    $vehiculos = R::findAll('vehiculos', 'ORDER BY economico');
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    foreach ($vehiculos as $vehiculo) {
        $vehiculo->tipo_vehiculos = $vehiculo->tipo_vehiculos;
    }
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($vehiculos));
});
$app->get('/vehiculos/justnames', function () use($app) {
    $rows = R::getAll("select v.id, concat(v.economico,'  :  ',t.descripcion ) as economico  from vehiculos v, tipo_vehiculos t\nwhere v.tipo_vehiculos_id=t.id");
    $vehiculos = R::convertToBeans('vehiculos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($vehiculos));
});
// handle GET requests for client's ID
$app->get('/vehiculos/:id', function ($id) use($app) {
    $vehiculo = R::findOne('vehiculos', 'id=?', array($id));
    try {
        if ($vehiculo) {
            $app->response()->header('Content-Type', 'application/json');
            echo json_encode(R::exportAll($vehiculo)[0]);
        } else {
            throw new ResourceNotFoundException();
        }
开发者ID:eluar,项目名称:shipping_app,代码行数:30,代码来源:vehiculos.php

示例4: function

});
$app->get('/schoolContract', function () use($app) {
    $sql = "select agent.oname as oname, contract.price as price, school.* from contract" . " join agent on agent.aid = contract.aid join school on school.id = contract.sid";
    try {
        $result = R::getAll($sql);
        $data = R::convertToBeans('contract', $result);
        success(R::exportAll($data));
    } catch (RedBeanPHP\RedException\SQL $e) {
        fail($e);
    }
});
$app->get('/student/:id', function ($id) use($app) {
    $sql = "select school.name as sname, user.* from school join user on user.sid='" . $id . "'";
    try {
        $result = R::getAll($sql);
        $data = R::convertToBeans('user', $result);
        success(R::exportAll($data));
    } catch (RedBeanPHP\RedException\SQL $e) {
        fail($e);
    }
});
$app->get('/', function () use($app) {
    header("Location: intro.php");
    die;
});
function setUnique($bean, $arr)
{
    $bean->setMeta("buildcommand.unique", array($arr));
}
function safeStore($obj)
{
开发者ID:rbrb,项目名称:smartqna,代码行数:31,代码来源:index.php

示例5: manageView

 public function manageView()
 {
     /*
      * Loadings libraries and helpers
      */
     $this->load->library(array('rb'));
     $this->load->helper(array('form'));
     /*
      * User is logged?
      */
     if (!parent::_isLogged()) {
         redirect('dashboard');
     }
     /*
      * General Information
      */
     $openRequestsQry = '
         SELECT r.*
         FROM status AS s
         JOIN request AS r 
         ON r.id = s.request_id 
         WHERE 
             s.current = "Y" 
             AND ( s.type = "waiting-open" 
                 OR s.type = "request_created" 
                 OR s.type = "request_moved" 
                 OR s.type = "request_extended" 
             ) 
     ';
     $openRequests = R::getAll($openRequestsQry);
     $openRequests = R::convertToBeans('request', $openRequests);
     $deadlineRequestsQry = '
         SELECT r.*
         FROM status AS s 
         JOIN request AS r 
         ON r.id = s.request_id 
         WHERE 
             ( 
                 NOW() > DATE_ADD( r.created_at, INTERVAL 20 DAY )
                 AND
                 ( SELECT COUNT(*) FROM status AS ss WHERE request_id = r.id AND type = "request_extended" ) <= 0
             )
             OR
             (
                 NOW() > DATE_ADD( r.created_at, INTERVAL 30 DAY )
                 AND
                 ( SELECT COUNT(*) FROM status AS ss WHERE request_id = r.id AND type = "request_extended" ) > 0
             )
     ';
     $deadlineRequests = R::getAll($deadlineRequestsQry);
     $deadlineRequests = R::convertToBeans('request', $deadlineRequests);
     $repliedRequestsQry = '
         SELECT r.*
         FROM status AS s
         JOIN request AS r 
         ON r.id = s.request_id 
         WHERE 
             s.current = "Y" 
             AND s.type = "request_replied" 
     ';
     $repliedRequests = R::getAll($repliedRequestsQry);
     $repliedRequests = R::convertToBeans('request', $repliedRequests);
     $data = array('ics' => R::find('ic', ' active="yes" '), 'openRequests' => count($openRequests), 'deadlineRequests' => count($deadlineRequests), 'replyRequests' => count($repliedRequests), 'totalRequests' => R::count('request'));
     /*
      * Loading views
      */
     $this->load->view('dashboard/template/header');
     $this->load->view('dashboard/template/menu', array('menu' => parent::_getMenu(parent::_getIc()->id), 'ics' => parent::_getIcs(), 'ic' => parent::_getIc()));
     $this->load->view('dashboard/manage', $data);
     $this->load->view('dashboard/template/footer');
 }
开发者ID:victorschinaider,项目名称:solicitacao-informacao,代码行数:71,代码来源:Dashboard.php

示例6: getLessonById

 static function getLessonById($id)
 {
     $user = R::duplicate($_SESSION['user']);
     $data = R::load('lesson', $id);
     $userInfo = R::getAll('SELECT * FROM information_user WHERE user_id = ?', [$_SESSION['user']->id]);
     $userInfo = R::convertToBeans('information_user', $userInfo);
     if (!empty($data->education_id) && $_SESSION['user']->status == 'student') {
         $education = R::load('education', $data->education_id);
         if ($education->number != 1) {
             $numb = $education->number - 1;
             //получаем id предметов, которые предшевствуют текущему
             $prev_education = R::findAll('education', ' WHERE number =? and information_id=?', [$numb, $education->information_id]);
             foreach ($prev_education as $item) {
                 //проверяем, содержит ли массив $userInfo id приведущего модуля
                 foreach ($userInfo as $it) {
                     if ($item->id == $it->education_id && is_null($it->status)) {
                         return false;
                     }
                 }
             }
         }
     }
     if ($data->number != 1 && $_SESSION['user']->status == 'student') {
         $numb = $data->number - 1;
         //            echo $numb;
         if (!empty($data->education_id)) {
             $query = ' WHERE number =? and education_id=?';
             $dataArray = [$numb, $data->education_id];
         } else {
             $query = ' WHERE number =? and information_id=?';
             $dataArray = [$numb, $data->information_id];
         }
         $lesson_parent = R::findAll('lesson', $query, $dataArray);
         //            print_r($lesson_parent);
         $lesson_flag = false;
         foreach ($lesson_parent as $item) {
             //проверяем, содержит ли массив $userInfo id приведущего модуля
             foreach ($userInfo as $it) {
                 if ($item->id == $it->lesson_id && !is_null($it->status)) {
                     $lesson_flag = true;
                 }
             }
             if ($lesson_flag == false) {
                 return false;
             }
         }
     }
     $prev = '';
     $next = '';
     if (!empty($data->education_id)) {
         $next_lesson = array_values(R::find('lesson', "where number = ? and education_id=? and block=1", [$data->number + 1, $data->education_id]));
     } else {
         $next_lesson = array_values(R::find('lesson', "where number = ? and information_id=? and block=1", [$data->number + 1, $data->information_id]));
     }
     if ($data->number == 1) {
         $help_class_prev = 'disabled';
         //            $prev = 1;
     } else {
         $help_class_prev = '';
         if (!empty($data->education_id)) {
             $prev = array_values(R::find('lesson', "where number = ? and education_id=? and block=1", [$data->number - 1, $data->education_id]))[0]->id;
         } else {
             $prev = array_values(R::find('lesson', "where number = ? and information_id=? and block=1", [$data->number - 1, $data->information_id]))[0]->id;
         }
         //            print_r($prev);
     }
     if (!empty($next_lesson)) {
         $help_class_next = '';
         $next = $next_lesson[0]->id;
     } else {
         $help_class_next = 'disabled';
         $next = $data->id;
     }
     $out = '';
     $out = "<h1>" . $data->name . "</h1><div class='col-sm-12'>" . $data->text . "</div>";
     $out .= "\r\n<div class='col-sm-4'></div>\r\n<div class='col-sm-2'><a role='button' href='?ctrl=cabinet&action=GetLesson&id=" . $prev . "' class='btn " . $help_class_prev . " btn-success btn-block'><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\"></span>Назад</a></div>\r\n<div class='col-sm-2'><a role='button' href='?ctrl=cabinet&action=GetLesson&id=" . $next . "' class='btn " . $help_class_next . " btn-success btn-block'>Далее<span class=\"glyphicon glyphicon-arrow-right\" aria-hidden=\"true\"></span></a></div>\r\n<div class='col-sm-4'></div>\r\n";
     return $out;
 }
开发者ID:Jluct,项目名称:obuceisea,代码行数:78,代码来源:cabinet.php

示例7: catch

    } catch (Exception $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    }
});
$app->get('/subsegmentos/justnames/', function () use($app) {
    $rows = R::getAll("select s.id, s.segmento_id, s.nombre from subsegmento s");
    $subsegmentos = R::convertToBeans('subsegmentos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($subsegmentos));
});
$app->get('/subsegmentos/justnames/:segmentid', function ($segmentid) use($app) {
    $rows = R::getAll("select s.id, s.segmento_id, s.nombre from subsegmento s where s.segmento_id=?", array($segmentid));
    $subsegmentos = R::convertToBeans('subsegmentos', $rows);
    // send response header for JSON content type
    $app->response()->header('Content-Type', 'application/json');
    // return JSON-encoded response body with query results
    echo json_encode(R::exportAll($subsegmentos));
});
$app->get('/subsegmentos/total/', function () use($app) {
    $total = R::dispense('total');
    $total->total = R::count('subsegmento');
    $app->response()->header('Content-Type: text/html; charset=utf-8');
    $app->response()->header('Content-Type', 'application/json');
    //TODO: Buscar un modo elegante de hacer lo siguiente:
    echo json_encode(R::exportAll($total)[0]);
});
$app->get('/subsegmentos/page/:pagenumber', function ($pagenumber) use($app) {
    // query database for all segmentos
开发者ID:eluar,项目名称:shipping_app,代码行数:31,代码来源:subsegmentos.php

示例8: convertToBeans

 public function convertToBeans($sql)
 {
     $rows = R::getAll($sql);
     $items = R::convertToBeans($this->table, $rows);
     return $items;
 }
开发者ID:Hannes1,项目名称:WorstFrameworkEver,代码行数:6,代码来源:WFEModel.php

示例9: json_decode

    $json = $app->request->getBody();
    $obj = json_decode($json);
    $aid = $obj->{'aid'};
    $fee = $obj->{'fee'};
    $sql = "UPDATE agent SET fee = '{$fee}' WHERE aid = '{$aid}'";
    try {
        R::exec($sql);
    } catch (RedBeanPHP\RedException\SQL $e) {
        fail($e);
    }
});
$app->get('/schoolContract', function () use($app) {
    $sql = "select agent.oname as oname, contract.price as price, school.* from contract" . " join agent on agent.aid = contract.aid join school on school.id = contract.sid";
    try {
        $result = R::getAll($sql);
        $data = R::convertToBeans('contract', $result);
        success(R::exportAll($data));
    } catch (RedBeanPHP\RedException\SQL $e) {
        fail($e);
    }
});
$app->get('/student/:id', function () use($app) {
    //  R::find('user',)
});
$app->get('/', function () use($app) {
    $center = 'style="display:block; height:100%; margin-left:auto; margin-right:auto"';
    echo "<a href='login.php'><img src=intro/toonysam.jpg {$center}></a>";
});
function setUnique($bean, $arr)
{
    $bean->setMeta("buildcommand.unique", array($arr));
开发者ID:rbrb,项目名称:smartqna,代码行数:31,代码来源:index.php

示例10: answeredView

 public function answeredView($id = NULL)
 {
     /*
      * Loading libraries
      */
     $this->load->library(array('rb', 'session'));
     $this->load->helper(array('form'));
     /*
      * User is logged?
      */
     if (!parent::_isLogged()) {
         redirect('dashboard');
         exit;
     }
     /*
      * Verify if user has autority to view the ic's
      */
     if (!parent::_hasAuth('view_request', $this->session->userdata('user_ic'))) {
         echo "Você não tem permissão para realizar este procedimento.";
         exit;
     }
     /* 
      * If $id is NULL, then load all answered requests. Otherwise, show only the specified request
      */
     if ($id == NULL) {
         /* 
          * Verify if the user is logged in MASTER IC or not. If it's the MASTER IC
          * then it shows all the Requests, otherwise, only show Requests from actual IC.
          */
         $requests = null;
         $isMasterIc = R::count('ic', 'id=? AND master="yes" ', array($this->session->userdata('user_ic')));
         if ($isMasterIc) {
             $rows = R::getAll('
                 SELECT r.* FROM request AS r 
                 JOIN status AS s ON s.request_id = r.id
                 WHERE s.type = "request_replied" AND s.current = "Y"
             ');
             $requests = R::convertToBeans('request', $rows);
         } else {
             $rows = R::getAll('
                 SELECT r.* FROM request AS r 
                 JOIN status AS s ON s.request_id = r.id
                 WHERE s.type = "request_replied" AND s.current = "Y" AND s.ic_id = ?
                 ', array($this->session->userdata('user_ic')));
             $requests = R::convertToBeans('request', $rows);
         }
         /*
          * Loading views
          */
         $this->load->view('dashboard/template/header');
         $this->load->view('dashboard/template/menu', array('menu' => parent::_getMenu(parent::_getIc()->id), 'ics' => parent::_getIcs(), 'ic' => parent::_getIc()));
         $this->load->view('dashboard/request/answered', array('requests' => $requests));
         $this->load->view('dashboard/template/footer');
     } else {
         /* 
          * Loading the request
          */
         $request = R::findOne('request', ' id = ? ', array($id));
         /* 
          * Request exists? 
          */
         if ($request == NULL) {
             $this->session->set_flashdata('success', 'A solicitação não existe.');
             redirect('dashboard/request/answered');
         }
         /* 
          * Getting current status of request
          */
         $status = R::findOne('status', 'request_id = ? AND current = "Y" ', array($request->id));
         /*
          * Can user access the request?
          */
         if (!self::_canAcessRequest($request)) {
             $this->session->set_flashdata('success', 'Você não tem autorização para acessar esta solicitação.');
             redirect('dashboard/request/answered');
         }
         /*
          * Loading views
          */
         $this->load->view('dashboard/template/header');
         $this->load->view('dashboard/template/menu', array('menu' => parent::_getMenu(parent::_getIc()->id), 'ics' => parent::_getIcs(), 'ic' => parent::_getIc()));
         $this->load->view('dashboard/request/answered-select', array('status' => $status, 'request' => $request));
         $this->load->view('dashboard/template/footer');
     }
 }
开发者ID:victorschinaider,项目名称:solicitacao-informacao,代码行数:85,代码来源:Request.php

示例11: asrt

$book->rating = 3;
$id2 = R::store($book);
$book1 = R::load("book", $id1);
$book2 = R::load("book", $id2);
asrt($book1->rating, '2');
asrt($book2->rating, '3');
$books = R::batch("book", array($id1, $id2));
R::swap($books, "rating");
$book1 = R::load("book", $id1);
$book2 = R::load("book", $id2);
asrt($book1->rating, '3');
asrt($book2->rating, '2');
testpack("Test R::convertToBeans");
$SQL = "SELECT '1' as id, a.name AS name, b.title AS title, '123' as rating FROM author AS a LEFT JOIN book as b ON b.id = ?  WHERE a.id = ? ";
$rows = R::$adapter->get($SQL, array($id2, $aid));
$beans = R::convertToBeans("something", $rows);
$bean = reset($beans);
asrt($bean->getMeta("type"), "something");
asrt($bean->name, "Bobby");
asrt($bean->title, "secondbook");
asrt($bean->rating, "123");
testpack("Ext Assoc with facade and findRelated");
//R::setup("sqlite:/Users/prive/blaataap.db");
R::exec("DROP TABLE IF EXISTS performer");
R::exec("DROP TABLE IF EXISTS cd_track");
R::exec("DROP TABLE IF EXISTS track");
R::exec("DROP TABLE IF EXISTS cd");
$cd = R::dispense("cd");
$cd->title = "Midnight Jazzfest";
R::store($cd);
$track = R::dispense("track");
开发者ID:ryjkov,项目名称:redbean,代码行数:31,代码来源:test.php

示例12: checktoomany

function checktoomany($cron = 1, $userid = 0)
{
    global $watches;
    $abusers = "";
    $found = 0;
    if ($cron) {
        $rows = R::getAll('SELECT * FROM users LEFT JOIN limits ON users.id=limits.userid');
        $users = R::convertToBeans('users', $rows);
        if (!empty($users)) {
            foreach ($users as $user) {
                $numberofrentals = R::count('history', 'userid=:userid AND action=:action AND time>:time', [':userid' => $user->id, ':action' => 'RENT', 'time' => date("Y-m-d H:i:s", time() - $watches["timetoomany"] * 3600)]);
                if ($numberofrentals >= $userlimit + $watches["numbertoomany"]) {
                    $abusers .= " " . $numberofrentals . " (" . _('limit') . " " . $user->userlimit . ") " . _('by') . " " . $user->username . ",";
                    $found = 1;
                }
            }
        }
    } else {
        $rows = R::getAll('SELECT * FROM users LEFT JOIN limits ON users.id=limits.userid WHERE users.id=?', [$userid]);
        $users = R::convertToBeans('users', $rows);
        if (!empty($users)) {
            foreach ($users as $user) {
                $numberofrentals = R::count('history', 'userid=:userid AND action=:action AND time>:time', [':userid' => $user->id, ':action' => 'RENT', 'time' => date("Y-m-d H:i:s", time() - $watches["timetoomany"] * 3600)]);
                if ($result->num_rows >= $userlimit + $watches["numbertoomany"]) {
                    $abusers .= " " . $numberofrentals . " (" . _('limit') . " " . $user->userlimit . ") " . _('by') . " " . $user->username . ",";
                    $found = 1;
                }
            }
        }
    }
    if ($found) {
        $abusers = substr($abusers, 0, strlen($abusers) - 1);
        notifyAdmins(_('Over limit in') . " " . $watches["timetoomany"] . " " . _('hs') . ":" . $abusers);
    }
}
开发者ID:arshadalisoomro,项目名称:OpenSourceBikeShare,代码行数:35,代码来源:common.php

示例13: actionListConversations

 protected function actionListConversations()
 {
     // create the user object
     $this->user = $this->setUser($this->request['user']);
     // halt on fail
     if (!$this->user) {
         return;
     }
     // get messages sent from the user
     // one latest message for each receipient
     $rows = R::getAll('
         SELECT *
         FROM message
         RIGHT JOIN (
             SELECT max(creation_time) as creation_time
             FROM message
             WHERE user_id = :user_id
             GROUP BY receipient_id
         ) AS latest ON message.creation_time = latest.creation_time
         WHERE user_id = :user_id', array(':user_id' => $this->user->id));
     // convert array into bean objects
     $messages = R::convertToBeans('message', $rows);
     // create conversations objects based on messages
     $conversations = array();
     foreach ($messages as $id => $message) {
         $conversations[$id] = new Conversation($message);
     }
     // add them to the data array for output
     $this->data = $conversations;
 }
开发者ID:esamo,项目名称:WebFoundary_PHPDeveloperTest,代码行数:30,代码来源:class-communicator.php

示例14: testBasicThroughFacade

 /**
  * Basic tests through Facade.
  * 
  * @return void
  */
 public function testBasicThroughFacade()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new RedBean_AssociationManager($toolbox);
     asrt(R::$redbean instanceof RedBean_OODB, TRUE);
     asrt(R::$toolbox instanceof RedBean_Toolbox, TRUE);
     asrt(R::$adapter instanceof RedBean_Adapter, TRUE);
     asrt(R::$writer instanceof RedBean_QueryWriter, TRUE);
     $book = R::dispense("book");
     asrt($book instanceof RedBean_OODBBean, TRUE);
     $book->title = "a nice book";
     $id = R::store($book);
     asrt($id > 0, TRUE);
     $book = R::load("book", (int) $id);
     asrt($book->title, "a nice book");
     $author = R::dispense("author");
     $author->name = "me";
     R::store($author);
     $book9 = R::dispense("book");
     $author9 = R::dispense("author");
     $author9->name = "mr Nine";
     $a9 = R::store($author9);
     $book9->author_id = $a9;
     $bk9 = R::store($book9);
     $book9 = R::load("book", $bk9);
     $author = R::load("author", $book9->author_id);
     asrt($author->name, "mr Nine");
     R::trash($author);
     R::trash($book9);
     pass();
     $book2 = R::dispense("book");
     $book2->title = "second";
     R::store($book2);
     R::associate($book, $book2);
     asrt(count(R::related($book, "book")), 1);
     $book3 = R::dispense("book");
     $book3->title = "third";
     R::store($book3);
     R::associate($book, $book3);
     asrt(count(R::related($book, "book")), 2);
     asrt(count(R::find("book")), 3);
     asrt(count(R::findAll("book")), 3);
     asrt(count(R::findAll("book", " WHERE ROWNUM <= 2")), 2);
     asrt(count(R::find("book", " id=id ")), 3);
     asrt(count(R::find("book", " title LIKE ?", array("third"))), 1);
     asrt(count(R::find("book", " title LIKE ?", array("%d%"))), 2);
     // Now with new SQL Helper argument
     asrt(count(R::find("book", R::$f->begin()->addSQL('title LIKE ? ')->put('third'))), 1);
     asrt(count(R::find("book", R::$f->begin()->addSQL('title LIKE ? ')->put('%d%'))), 2);
     asrt(count(R::find("book", R::$f->begin()->addSQL('title')->like(' ? ')->addSQL(' ORDER BY id ')->desc()->put('%d%'))), 2);
     //Find without where clause
     asrt(count(R::findAll('book', ' order by id')), 3);
     R::unassociate($book, $book2);
     asrt(count(R::related($book, "book")), 1);
     R::trash($book3);
     R::trash($book2);
     asrt(count(R::related($book, "book")), 0);
     asrt(count(R::getAll("SELECT * FROM book ")), 1);
     asrt(count(R::getCol("SELECT title FROM book ")), 1);
     asrt((int) R::getCell("SELECT 123 FROM DUAL "), 123);
     $book = R::dispense("book");
     $book->title = "not so original title";
     $author = R::dispense("author");
     $author->name = "Bobby";
     R::store($book);
     $aid = R::store($author);
     R::associate($book, $author);
     $author = R::findOne("author", " name = ? ", array("Bobby"));
     $books = R::related($author, "book");
     $book = reset($books);
     testpack("Test Swap function in R-facade");
     $book = R::dispense("book");
     $book->title = "firstbook";
     $book->rating = 2;
     $id1 = R::store($book);
     $book = R::dispense("book");
     $book->title = "secondbook";
     $book->rating = 3;
     $id2 = R::store($book);
     $book1 = R::load("book", $id1);
     $book2 = R::load("book", $id2);
     asrt($book1->rating, '2');
     asrt($book2->rating, '3');
     $books = R::batch("book", array($id1, $id2));
     R::swap($books, "rating");
     $book1 = R::load("book", $id1);
     $book2 = R::load("book", $id2);
     asrt($book1->rating, '3');
     asrt($book2->rating, '2');
     testpack("Test R::convertToBeans");
     $SQL = "SELECT '1' as id, a.name AS name, b.title AS title, '123' as rating FROM author a LEFT JOIN book b ON b.id = ?  WHERE a.id = ? ";
//.........这里部分代码省略.........
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:101,代码来源:Facade.php


注:本文中的R::convertToBeans方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。