本文整理汇总了PHP中fail函数的典型用法代码示例。如果您正苦于以下问题:PHP fail函数的具体用法?PHP fail怎么用?PHP fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testBasicsDispense
/**
* Test dispense.
*
* @return void
*/
public function testBasicsDispense()
{
$redbean = R::getRedBean();
// Can we dispense a bean?
$page = $redbean->dispense("page");
// Does it have a meta type?
asrt((bool) $page->getMeta("type"), TRUE);
// Does it have an ID?
asrt(isset($page->id), TRUE);
// Type should be 'page'
asrt($page->getMeta("type"), "page");
// ID should be 0 because bean does not exist in database yet.
asrt($page->id, 0);
// Try some faulty dispense actions.
foreach (array("", ".", "-") as $value) {
try {
$redbean->dispense($value);
fail();
} catch (RedException $e) {
pass();
}
}
$bean = $redbean->dispense("testbean");
$bean["property"] = 123;
$bean["abc"] = "def";
asrt($bean["property"], 123);
asrt($bean["abc"], "def");
asrt($bean->abc, "def");
asrt(isset($bean["abd"]), FALSE);
asrt(isset($bean["abc"]), TRUE);
}
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:36,代码来源:Dispense.php
示例2: fivebeers_alphabet
/**
* Ajax function to load the posts by Letter
*/
function fivebeers_alphabet()
{
$letter = isset($_GET['letter']) ? $_GET['letter'] : null;
if (!$letter) {
fail(__('Error post letter.', 'bits'));
} else {
global $wpdb;
if ($letter == 'num') {
$myposts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE SUBSTRING(LOWER(post_title),1,1) BETWEEN '0' AND '9' AND post_status = 'publish' AND post_type = 'post' ORDER BY post_title ASC");
} else {
$myposts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE post_title LIKE '" . $letter . "%' AND post_status = 'publish' AND post_type = 'post' ORDER BY post_title ASC");
}
//$output = '<div id="#content">';
$output = '';
if (empty($myposts)) {
$output .= 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.';
} else {
foreach ($myposts as $mypost) {
$output .= '<article class="post hentry">';
$output .= '<header class="entry-header">';
$output .= '<h2 class="entry-title">';
$output .= '<a href="' . get_permalink($mypost->ID) . '" rel="bookmark">';
$output .= get_the_title($mypost->ID);
$output .= '</a><h2>';
$output .= '</header>';
$output .= '<div class="entry-content">';
$output .= $mypost->post_content;
$output .= '</div>';
$output .= '</article>';
}
}
echo do_shortcode($output);
die;
}
}
开发者ID:katstar01,项目名称:fivebeers,代码行数:38,代码来源:alphabet.php
示例3: db_connection
function db_connection($query)
{
mysql_connect('127.0.0.1', 'root', 'root') or die(fail('Could not connect to database.'));
mysql_query("SET NAMES 'utf8'");
mysql_select_db('mybd_user');
return mysql_query($query);
}
开发者ID:RomanPopenchuk,项目名称:equipment-server,代码行数:7,代码来源:service.php
示例4: dbConnect
function dbConnect()
{
global $mysqli;
${"GLOBALS"}["syjbprc"] = "dbPass";
$wxopfvv = "dbPort";
${"GLOBALS"}["qgkqlgglqg"] = "dbPort";
${"GLOBALS"}["ukbcqeuznohf"] = "mysqli";
${"GLOBALS"}["gxnvcyyh"] = "mysqli";
global $dbHost;
${"GLOBALS"}["xoogrhxkcl"] = "charset";
global $dbUser;
$xjpxhlspgv = "dbName";
${"GLOBALS"}["jbvecviflksb"] = "dbHost";
global $dbPass;
${"GLOBALS"}["vcxlqh"] = "dbUser";
${"GLOBALS"}["wpnxhmrcoewc"] = "mysqli";
global $dbName;
${"GLOBALS"}["lkujqcuxnug"] = "dbName";
if (isset(${$wxopfvv})) {
${${"GLOBALS"}["wpnxhmrcoewc"]} = new mysqli(${${"GLOBALS"}["xnlmiso"]}, ${${"GLOBALS"}["nvrqhz"]}, ${${"GLOBALS"}["syjbprc"]}, ${$xjpxhlspgv}, ${${"GLOBALS"}["qgkqlgglqg"]});
} else {
${${"GLOBALS"}["gxnvcyyh"]} = new mysqli(${${"GLOBALS"}["jbvecviflksb"]}, ${${"GLOBALS"}["vcxlqh"]}, ${${"GLOBALS"}["muwvgfjip"]}, ${${"GLOBALS"}["lkujqcuxnug"]});
}
if ($mysqli->connect_error) {
fail("<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/><link rel=\"Shortcut Icon\" type=\"image/ico\" href=\"/img/favicon.png\"><title>" . _("Can't connect to database") . "</title></head><style type=\"text/css\">body{background: #ffffff;font-family: Helvetica, Arial;}#wrapper{background: #f2f2f2;width: 300px;height: 110px;margin: -140px 0 0 -150px;position: absolute;top: 50%;left: 50%;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}p{text-align: center;line-height: 18px;font-size: 12px;padding: 0 30px;}h2{font-weight: normal;text-align: center;font-size: 20px;}a{color: #000;}a:hover{text-decoration: none;}</style><body><div id=\"wrapper\"><p><h2>" . _("Can't connect to database") . "</h2></p><p>" . _("There is a problem connecting to the database. Please try again later.") . "</p></div></body></html>");
}
global $charset;
mysqli_set_charset(${${"GLOBALS"}["ukbcqeuznohf"]}, isset(${${"GLOBALS"}["ornuwcbnhed"]}) ? ${${"GLOBALS"}["xoogrhxkcl"]} : "utf8");
return ${${"GLOBALS"}["zymgfktjwdk"]};
}
开发者ID:narareddy,项目名称:sendy,代码行数:30,代码来源:functions.php
示例5: testChill
/**
* Test Chill mode.
*
* @return void
*/
public function testChill()
{
$bean = R::dispense('bean');
$bean->col1 = '1';
$bean->col2 = '2';
R::store($bean);
asrt(count(R::$writer->getColumns('bean')), 3);
$bean->col3 = '3';
R::store($bean);
asrt(count(R::$writer->getColumns('bean')), 4);
R::freeze(array('umbrella'));
$bean->col4 = '4';
R::store($bean);
asrt(count(R::$writer->getColumns('bean')), 5);
R::freeze(array('bean'));
$bean->col5 = '5';
try {
R::store($bean);
fail();
} catch (Exception $e) {
pass();
}
asrt(count(R::$writer->getColumns('bean')), 5);
R::freeze(array());
$bean->col5 = '5';
R::store($bean);
asrt(count(R::$writer->getColumns('bean')), 6);
}
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:33,代码来源:Chill.php
示例6: dbConnect
function dbConnect()
{
${"GLOBALS"}["ynvyvtgrlhv"] = "dbUser";
global $mysqli;
global $dbHost;
global $dbUser;
global $dbPass;
global $dbName;
global $dbPort;
${"GLOBALS"}["cdbebx"] = "mysqli";
$luljlbwrlm = "charset";
$qcnjjmjhshu = "dbPass";
${"GLOBALS"}["urqiwxbggy"] = "dbName";
${"GLOBALS"}["glxpgvwccp"] = "dbHost";
if (isset(${${"GLOBALS"}["ptgzyszv"]})) {
${${"GLOBALS"}["mikmhj"]} = new mysqli(${${"GLOBALS"}["mxccww"]}, ${${"GLOBALS"}["ipgxwvjqcfs"]}, ${$qcnjjmjhshu}, ${${"GLOBALS"}["urqiwxbggy"]}, ${${"GLOBALS"}["ptgzyszv"]});
} else {
${${"GLOBALS"}["mikmhj"]} = new mysqli(${${"GLOBALS"}["glxpgvwccp"]}, ${${"GLOBALS"}["ynvyvtgrlhv"]}, ${${"GLOBALS"}["ukyvrmxs"]}, ${${"GLOBALS"}["thiajcew"]});
}
if ($mysqli->connect_error) {
fail("<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/><link rel=\"Shortcut Icon\" type=\"image/ico\" href=\"/img/favicon.png\"><title>" . _("Can't connect to database") . "</title></head><style type=\"text/css\">body{background: #ffffff;font-family: Helvetica, Arial;}#wrapper{background: #f2f2f2;width: 300px;height: 130px;margin: -140px 0 0 -150px;position: absolute;top: 50%;left: 50%;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}p{text-align: center;line-height: 18px;font-size: 12px;padding: 0 30px;}h2{font-weight: normal;text-align: center;font-size: 20px;}a{color: #000;}a:hover{text-decoration: none;}</style><body><div id=\"wrapper\"><p><h2>" . _("Can't connect to database") . "</h2></p><p>" . _("There is a problem connecting to the database. Please try again later or see this <a href=\"https://sendy.co/troubleshooting#cannot-connect-to-database\" target=\"_blank\">troubleshooting tip</a>.") . "</p></div></body></html>");
}
global $charset;
mysqli_set_charset(${${"GLOBALS"}["mikmhj"]}, isset(${${"GLOBALS"}["iwcsixdue"]}) ? ${$luljlbwrlm} : "utf8");
return ${${"GLOBALS"}["cdbebx"]};
}
开发者ID:ariestiyansyah,项目名称:nggadu,代码行数:26,代码来源:functions.php
示例7: forfeit
function forfeit()
{
global $bot;
// If this bot is not in a game, there's nothing to do.
if (is_null($bot["game"])) {
return;
}
// Otherwise, forfeit the game that this bot is currently playing, starting by
// finding out who our opponent is.
$res = pg_query_params('SELECT bot1, bot2, forfeited_by FROM games WHERE id=$1;', [$bot["game"]]);
if ($res === FALSE || pg_affected_rows($res) !== 1) {
fail("Couldn't find our opponent in game #{$bot['game']}.");
}
$row = pg_fetch_assoc($res);
pg_free_result($res);
// Determine which of the bots in this game was our opponent, and which was us.
if ($row["bot1"] === $bot["id"]) {
$opponent = $row["bot2"];
} else {
$opponent = $row["bot1"];
}
// Release ourselves and our opponent from the game.
$res = pg_query_params('UPDATE bots SET game=NULL, game_timeout=NULL, cards=NULL WHERE id=$1 OR id=$2;', [$bot["id"], $opponent]);
if ($res === FALSE || pg_affected_rows($res) !== 2) {
panic("Failed to update the database to release bots {$bot['id']} and {$opponent} from game {$bot['game']}.");
}
pg_free_result($res);
// Forfeit the game.
$res = pg_query_params('UPDATE games SET forfeited_by=$1, finished=now() WHERE id=$2;', [$bot["id"], $bot["game"]]);
if ($res === FALSE || pg_affected_rows($res) !== 1) {
panic("Failed to forfeit game #{$bot['game']} we're playing.");
}
pg_free_result($res);
}
开发者ID:BenBergman,项目名称:gameai-2014-09,代码行数:34,代码来源:shared.php
示例8: deal
function deal()
{
if (empty($_REQUEST['username'])) {
fail("username缺失");
}
if (empty($_REQUEST['id'])) {
fail("id缺失");
}
if (empty($_REQUEST['phonenum'])) {
fail("phonenum缺失");
}
$conn = @mysql_connect("localhost", "root", "mobilenewspaper") or die("数据库链接错误");
mysql_select_db("qa", $conn);
if (isset($_GET['city']) && isset($_GET['company'])) {
$SQL = "update questionnaire set city = \"" . $_REQUEST['city'] . "\" ,company = \"" . $_REQUEST['company'] . "\", username =\"" . $_REQUEST['username'] . "\",phonenum= " . $_REQUEST['phonenum'] . " where id = " . $_REQUEST['id'];
} else {
$SQL = "update questionnaire set username =\"" . $_REQUEST['username'] . "\",phonenum= " . $_REQUEST['phonenum'] . " where id = " . $_REQUEST['id'];
}
// $SQL="SELECT * FROM questionnaire order by id desc";
// $query=mysql_query($SQL);
if (mysql_query($SQL)) {
echo $_REQUEST['callback'] . '("' . "<xmlmsg><result>-1.0</result><msg>提交成功</msg><scriptcode><![CDATA[alert('提交成功');]]></scriptcode></xmlmsg>" . '")';
} else {
echo "Error creating database: " . mysql_error();
}
// echo "ok";
}
开发者ID:brandyaptx,项目名称:sso-master,代码行数:27,代码来源:info.php
示例9: dbConnect
function dbConnect()
{
//Connect to database
//--------------------------------------------------------------//
// Access global variables
global $mysqli;
global $dbHost;
global $dbUser;
global $dbPass;
global $dbName;
global $dbPort;
// Attempt to connect to database server
if (isset($dbPort)) {
$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName, $dbPort);
} else {
$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
}
// If connection failed...
if ($mysqli->connect_error) {
fail();
}
global $charset;
mysqli_set_charset($mysqli, isset($charset) ? $charset : "utf8");
return $mysqli;
}
开发者ID:ariestiyansyah,项目名称:nggadu,代码行数:25,代码来源:complaints.php
示例10: map_query
function map_query($query)
{
// Connect
mysql_connect('mysql_host', 'mysql_user', 'mysql_password') or die(fail('Could not connect to database.'));
mysql_select_db('mysql_database');
return mysql_query($query);
}
开发者ID:sachsy,项目名称:tutorials-jquery-google-maps,代码行数:7,代码来源:map-service.php
示例11: testTags
/**
* Some basic tests.
*
* @return void
*/
public function testTags()
{
list($c, $d, $e, $f) = R::dispense('coffee', 4);
R::tag($c, 'strong,black');
R::tag($d, 'black');
R::tag($e, 'strong,sweet');
R::tag($f, 'black,strong');
//$x = array_intersect(R::tagged('coffee','sweet'),R::tagged('coffee','strong'));
asrt(count(R::taggedAll('coffee', 'strong,sweet')), 1);
asrt(count(R::taggedAll('coffee', 'strong')), 3);
asrt(count(R::taggedAll('coffee', '')), 0);
asrt(count(R::taggedAll('coffee', 'sweet')), 1);
asrt(count(R::taggedAll('coffee', 'sweet,strong')), 1);
asrt(count(R::taggedAll('coffee', 'black,strong')), 2);
asrt(count(R::taggedAll('coffee', array('black', 'strong'))), 2);
asrt(count(R::taggedAll('coffee', 'salty')), 0);
$blog = R::dispense('blog');
$blog->title = 'testing';
$blog->blog = 'tesing';
R::store($blog);
$blogpost = R::load("blog", 1);
$post = R::dispense("post");
$post->message = "hello";
R::tag($post, "lousy,smart");
asrt(implode(',', R::tag($post)), "lousy,smart");
R::tag($post, "clever,smart");
$tagz = implode(',', R::tag($post));
asrt($tagz == "smart,clever" || $tagz == "clever,smart", TRUE);
R::tag($blog, array("smart", "interesting"));
asrt(implode(',', R::tag($blog)), "smart,interesting");
try {
R::tag($blog, array("smart", "interesting", "lousy!"));
pass();
} catch (RedBean_Exception $e) {
fail();
}
asrt(implode(',', R::tag($blog)), "smart,interesting,lousy!");
R::untag($blog, array("smart", "interesting"));
asrt(implode(",", R::tag($blog)), "lousy!");
asrt(R::hasTag($blog, array("lousy!")), TRUE);
asrt(R::hasTag($blog, array("lousy!", "smart")), TRUE);
asrt(R::hasTag($blog, array("lousy!", "smart"), TRUE), FALSE);
R::tag($blog, FALSE);
asrt(count(R::tag($blog)), 0);
R::tag($blog, array("funny", "comic"));
asrt(count(R::tag($blog)), 2);
R::addTags($blog, array("halloween"));
asrt(count(R::tag($blog)), 3);
asrt(R::hasTag($blog, array("funny", "commic", "halloween"), TRUE), FALSE);
R::unTag($blog, "funny");
R::addTags($blog, "horror");
asrt(count(R::tag($blog)), 3);
asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
//no double tags
R::addTags($blog, "horror");
asrt(R::hasTag($blog, array("horror", "commic", "halloween"), TRUE), FALSE);
asrt(R::hasTag($blog, "horror,commic,halloween", TRUE), FALSE);
asrt(count(R::tag($blog)), 3);
testpack("fetch tagged items");
}
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:65,代码来源:Tags.php
示例12: check_for_typeof
function check_for_typeof($dir)
{
$r = 0;
foreach (glob($dir . "/*.js") as $f) {
$file_contents = file_get_contents($f);
$pattern = '#(.*)for\\((.*)#U';
$replacement = '$1for ($2';
$foundMatches = preg_match_all($pattern, $file_contents, $matches);
if ($foundMatches) {
fail("Bad usage found in: " . $f);
if ($foundMatches) {
echo "Found matches:\n";
foreach ($matches[0] as $line) {
$replaced_with = preg_replace($pattern, $replacement, $line);
echo "\t" . $line . " -=> " . $replaced_with . "\n";
}
}
global $argv;
if (isset($argv[1]) && $argv[1] === "fixit") {
$file_contents = preg_replace($pattern, $replacement, $file_contents);
changed_file($f);
file_put_contents($f, $file_contents);
echo "----- File automatically fixed. -----\n";
}
}
}
}
开发者ID:meganz,项目名称:webclient,代码行数:27,代码来源:patch-for-parenthesis-nospace.php
示例13: check_for_typeof
function check_for_typeof($dir)
{
$r = 0;
foreach (glob($dir . "/*.js") as $f) {
$file_contents = file_get_contents($f);
if (strpos($file_contents, 'typeof(') > -1) {
fail("Bad usage found in: " . $f);
$pattern = '#typeof\\(([a-zA-Z0-9\\.\\-\\_]+)\\)#smU';
$replacement = 'typeof $1';
if (preg_match_all($pattern, $file_contents, $matches)) {
echo "Found matches:\n";
foreach ($matches[0] as $line) {
$replaced_with = preg_replace($pattern, $replacement, $line);
echo "\t" . $line . " -=> " . $replaced_with . "\n";
}
}
global $argv;
if (isset($argv[1]) && $argv[1] === "fixit") {
$file_contents = preg_replace($pattern, $replacement, $file_contents);
changed_file($f);
file_put_contents($f, $file_contents);
echo "----- File automatically fixed. -----\n";
}
}
}
}
开发者ID:meganz,项目名称:webclient,代码行数:26,代码来源:patch-typeof.php
示例14: delete
function delete()
{
$id = $_REQUEST['id'];
$query = "DELETE FROM customers WHERE id={$id}";
mysql_query($query) or fail(mysql_error());
success('delete successful');
}
开发者ID:AmidoriA,项目名称:poon-project,代码行数:7,代码来源:services.php
示例15: dbConnect
function dbConnect()
{
//Connect to database
//--------------------------------------------------------------//
// Access global variables
global $mysqli;
global $dbHost;
global $dbUser;
global $dbPass;
global $dbName;
global $dbPort;
// Attempt to connect to database server
if (isset($dbPort)) {
$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName, $dbPort);
} else {
$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
}
// If connection failed...
if ($mysqli->connect_error) {
fail("<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/><link rel=\"Shortcut Icon\" type=\"image/ico\" href=\"/img/favicon.png\"><title>" . _('Can\'t connect to database') . "</title></head><style type=\"text/css\">body{background: #ffffff;font-family: Helvetica, Arial;}#wrapper{background: #f2f2f2;width: 300px;height: 110px;margin: -140px 0 0 -150px;position: absolute;top: 50%;left: 50%;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}p{text-align: center;line-height: 18px;font-size: 12px;padding: 0 30px;}h2{font-weight: normal;text-align: center;font-size: 20px;}a{color: #000;}a:hover{text-decoration: none;}</style><body><div id=\"wrapper\"><p><h2>" . _('Can\'t connect to database') . "</h2></p><p>" . _('There is a problem connecting to the database. Please try again later.') . "</p></div></body></html>");
}
global $charset;
mysqli_set_charset($mysqli, isset($charset) ? $charset : "utf8");
return $mysqli;
}
开发者ID:5haman,项目名称:Sendy,代码行数:25,代码来源:unsubscribe-success.php
示例16: getMigrations
protected function getMigrations($from_version)
{
if (!is_dir($this->sql_dir)) {
throw new RuntimeException("SQL dir does not exist or not a directory: {$this->sql_dir}");
}
$files = scandir($this->sql_dir);
if (!$files) {
fail("Can't read directory: {$this->sql_dir}");
}
$migrations = array();
foreach ($files as $file) {
if (!preg_match('/^([0-9]{4})_.+\\.sql$/', $file, $match)) {
continue;
}
$version = (int) $match[1];
if ($version <= $from_version) {
continue;
}
if (isset($migrations[$version])) {
throw new RuntimeException("Duplicate migration version: {$version}");
}
$sql = file_get_contents($this->sql_dir . '/' . $file);
if ($sql === false) {
throw new RuntimeException("Could not read migration file: {$file}");
}
$migrations[$version] = array('version' => $version, 'filename' => $file, 'sql' => $sql);
}
return $migrations;
}
开发者ID:apeschar,项目名称:forward-sql,代码行数:29,代码来源:ForwardSQL.php
示例17: connect
/**
* @param string $dsn
* @return \Doctrine\DBAL\Driver
*/
function connect($dsn)
{
try {
return \Doctrine\DBAL\DriverManager::getConnection(array('url' => $dsn, 'charset' => 'utf8', 'driverClass' => 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver'));
} catch (Exception $e) {
fail("Database error: " . $e->getMessage());
}
}
开发者ID:webfactory,项目名称:slimdump,代码行数:12,代码来源:util.php
示例18: Run
/**
* Run a query. PLEASE sanitize inputs BEFORE this...
* (BuildSaveQuery function does sanitize already...
* but you gotta do everything else when the occassion arises.)
* (You can use DB::Safe() to make a value safe to insert)
* @var $query The query to run.
* @return The query result.
*/
public static function Run($query)
{
$r = mysql_query($query);
if (!$r) {
fail("ERROR EXECUTING QUERY: " . mysql_error());
}
return $r;
}
开发者ID:bluegate010,项目名称:ysaward,代码行数:16,代码来源:DB.php
示例19: get_host
function get_host($hostid, $user)
{
$host = BoincHost::lookup_id($hostid);
if (!$host || $host->userid != $user->id) {
fail("We have no record of that computer");
}
return $host;
}
开发者ID:Turante,项目名称:boincweb,代码行数:8,代码来源:host_edit_action.php
示例20: testUnsetParent
/**
* Tests whether we can NULLify a parent bean
* page->book if the parent (book) is already
* NULL. (isset vs array_key_exists bug).
*
* @return void
*/
public function testUnsetParent()
{
R::nuke();
$book = R::dispense('book');
$book->title = 'My Book';
$page = R::dispense('page');
$page->text = 'Lorem Ipsum';
$book->ownPage[] = $page;
R::store($book);
$page = $page->fresh();
R::freeze(TRUE);
asrt((int) $page->book->id, (int) $book->id);
unset($page->book);
R::store($page);
$page = $page->fresh();
asrt((int) $page->book->id, (int) $book->id);
$page->book = NULL;
R::store($page);
$page = $page->fresh();
asrt($page->book, NULL);
asrt($page->book_id, NULL);
asrt($page->bookID, NULL);
asrt($page->bookId, NULL);
$page = R::dispense('page');
$page->text = 'Another Page';
$page->book = NULL;
try {
R::store($page);
fail();
} catch (\Exception $exception) {
pass();
}
unset($page->book);
R::store($page);
$page = $page->fresh();
$page->book = NULL;
//this must set field id to NULL not ADD column!
try {
R::store($page);
pass();
} catch (\Exception $exception) {
fail();
}
$page = $page->fresh();
$page->book = NULL;
R::store($page);
$page = $page->fresh();
asrt(is_null($page->book_id), TRUE);
$page->book = $book;
R::store($page);
$page = $page->fresh();
asrt((int) $page->book->id, (int) $book->id);
$page->book = NULL;
R::store($page);
asrt(is_null($page->book_id), TRUE);
asrt(is_null($page->book), TRUE);
R::freeze(FALSE);
}
开发者ID:cesium147,项目名称:redbean,代码行数:65,代码来源:Null.php
注:本文中的fail函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论