當前位置: 首頁>>代碼示例>>PHP>>正文


PHP like函數代碼示例

本文整理匯總了PHP中like函數的典型用法代碼示例。如果您正苦於以下問題:PHP like函數的具體用法?PHP like怎麽用?PHP like使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了like函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testNumber

 function testNumber()
 {
     $driver = new SQLBuilder\Driver\MySQLDriver();
     is(1, $driver->deflate(1));
     is(1.2, $driver->deflate(1.2));
     is('\'1\'', $driver->deflate('1'));
     is('NULL', $driver->deflate(null));
     $d = new DateTime();
     $d->setDate(2000, 01, 01);
     $d->setTime(0, 0, 0);
     # var_dump( $d->format(DateTime::ISO8601) . '' );
     like('/2000-01-01 00:00:00/', $driver->deflate($d));
 }
開發者ID:Ruyka,項目名稱:SQLBuilder,代碼行數:13,代碼來源:InflatorTest.php

示例2: testOptValidValues

 public function testOptValidValues()
 {
     ob_start();
     ok($this->runCommand('example/demo meta --zsh commit opt reuse-message valid-values'));
     $output = ob_get_contents();
     ob_end_clean();
     $lines = explode("\n", trim($output));
     is('#values', $lines[0]);
     array_shift($lines);
     foreach ($lines as $line) {
         like('/^\\w{7}$/', $line);
     }
 }
開發者ID:rockylo,項目名稱:CLIFramework,代碼行數:13,代碼來源:MetaCommandTest.php

示例3: fund

function fund($value, $pid)
{
    /*if (isset($_COOKIE["most_recent_project"])) {
          $pid = $_COOKIE["most_recent_project"];
      } else {
          echo "Refresh, try again";
      } */
    // validate value!!
    if (!is_numeric($value) or $value <= 0) {
        header('Content-Type: application/json');
        echo "Bad value";
        exit;
    }
    // database connection
    $dsn = "mysql:host=localhost;dbname=fundbook";
    //$options = array(PDO::"MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
    $db = new PDO($dsn, "root", "fundbook");
    $projects = $db->query("SELECT * FROM projects WHERE pid='{$pid}'");
    foreach ($projects as $project) {
        $author = $project["user"];
        $goal = $project["goal"];
        $category = $project["topic"];
        $title = $project["name"];
        $numBackers = $project["numBackers"] + 1;
        $raisedAmt = $project["raisedAmt"] + $value;
    }
    if ($value > $goal - $raisedAmt) {
        header('Content-Type: application/json');
        echo "Too high";
        exit;
    }
    // add to backers count for the project, add money to rasiedAmt
    $db->query("UPDATE projects SET numBackers={$numBackers}, raisedAmt={$raisedAmt} WHERE pid='{$pid}'");
    // update the view on screen
    $data = array('action' => 'fund', 'numBackers' => $numBackers, 'raisedAmt' => $raisedAmt, 'goal' => $goal);
    echo json_encode($data);
    // add to interest
    like($pid, 'implicit');
    exit;
}
開發者ID:centaurustech,項目名稱:fundbook,代碼行數:40,代碼來源:ajax_functions.php

示例4: location

    location($dbh, $array, "", $data);
}
if ($type == 'topLocation') {
    location($dbh, $array, "order by likes desc limit 20", $data);
}
if ($type == 'recentAddLocation') {
    location($dbh, $array, "order by id desc limit 20", $data);
}
if ($type == 'allLocation') {
    location($dbh, $array, "", "");
}
if ($type == 'login') {
    login($dbh, $array);
}
if ($type == 'like') {
    like($dbh, $array);
}
function kitSearch($db, $json)
{
    $json[0] = "%" . $json[0] . "%";
    $sql = "select id, Image.url, brand, model, item, date,userID from Kit join Image on \n\t \t\t\t\t\t\tKit.image = Image.imageID where concat(image,brand,model,item,date) \n\t\t\t\t\t\t\t\t\tlike '{$json['0']}'  and userID =  {$json['1']} ;";
    returnResults($db, $sql);
}
function challangePage($db, $json)
{
    $sql = "select id, userID, name, date_added, description, url , likes from Challange join Image \n\t \t\t\ton Challange.image = Image.imageID where id =  {$json['0']} ;";
    returnResults($db, $sql);
}
function challangeImage($db, $json)
{
    $sql = "select  url from Challange join challangeImage on Challange.id = challangeImage.ChallangeID\n\t\t\t\tjoin Image on challangeImage.ImageID = Image.imageID where id =  24;";
開發者ID:up730418,項目名稱:WebScript,代碼行數:31,代碼來源:dbSearch.php

示例5: like

<?php

require_once "include.php";
if (is_connected()) {
    $request = like($_POST, $connect);
} else {
    $request = 0;
}
echo $request;
開發者ID:ItsJimi,項目名稱:42,代碼行數:9,代碼來源:like.php

示例6: array

	$validvalues = array("ANY","NEG");
	if (!in_array($sign, $validvalues)) $sign = "ANY";
	$type = isset($_GET["type"]) ? $_GET["type"] : "RECV";
	$validvalues = array("RECV","SENT");
	if (!in_array($type, $validvalues)) $type = "RECV";
	if ($type == "RECV") {
		$validkeys = array('id', 'rater_nick', 'rater_total_rating', 'rated_nick', 'created_at', 'rating', 'notes');
		$sortby = "rater_total_rating";
		$sortorder = "DESC";
	} else {
		$validkeys = array('id', 'rater_nick', 'rated_nick', 'ratee_total_rating', 'created_at', 'rating', 'notes');
		$sortby = "ratee_total_rating";
		$sortorder = "DESC";
	}
	$nick = isset($_GET["nick"]) ? $_GET["nick"] : "";
	$nickfilter = html_entity_decode(like($nick, '|'));
	$nick = html_entity_decode($nick);
	$outformat = isset($_GET["outformat"]) ? $_GET["outformat"] : "";
	$outformat = html_entity_decode($outformat);
?>
<?php
	try { $db = new PDO('sqlite:./otc/RatingSystem.db'); }
	catch (PDOException $e) { die($e->getMessage()); }

	include('querytojson.php');
	if ($outformat == 'json'){
		$signqueries = array('ANY' => ' ', 'POS' => ' AND ratings.rating > 0', 'NEG' => ' AND ratings.rating < 0');
		$typequeries = array('RECV' => "users2.nick LIKE ? ESCAPE '|' AND users2.id = ratings.rated_user_id AND users.id = ratings.rater_user_id", 'SENT' => "users.nick LIKE ? ESCAPE '|' AND users.id = ratings.rater_user_id AND users2.id = ratings.rated_user_id");
		$sql = "SELECT ratings.id as id, users.nick as rater_nick, users2.nick as rated_nick, ratings.created_at as created_at, ratings.rating as rating, ratings.notes as notes from users, users as users2, ratings WHERE " . $typequeries[$type] . $signqueries[$sign];
		$sth = $db->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
		$sth->setFetchMode(PDO::FETCH_ASSOC);
開發者ID:badzso,項目名稱:supybot-bitcoin-marketmonitor,代碼行數:31,代碼來源:viewratingdetail.php

示例7: testJoin

 public function testJoin()
 {
     $authors = new AuthorCollection();
     $authors->join(new \AuthorBooks\Model\Address(), 'LEFT', 'a');
     $authors->fetch();
     $sql = $authors->toSQL();
     like('/LEFT JOIN addresses AS a ON \\(m.id = a.author_id\\)/', $sql);
 }
開發者ID:corneltek,項目名稱:lazyrecord,代碼行數:8,代碼來源:AuthorCollectionTest.php

示例8: testBasicCRUDOperations

 /**
  * Basic CRUD Test 
  */
 public function testBasicCRUDOperations()
 {
     $author = new Author();
     $a2 = new Author();
     $ret = $a2->find(array('name' => 'A record does not exist.'));
     $this->assertResultFail($ret);
     ok(!$a2->id);
     $ret = $a2->create(array('xxx' => true, 'name' => 'long string \'` long string', 'email' => 'email2', 'identity' => 'id2'));
     $this->assertResultSuccess($ret);
     ok($a2->id);
     $ret = $author->create(array());
     $this->assertResultFail($ret);
     ok($ret->message);
     like('/Empty arguments/', $ret->message);
     $ret = $author->create(array('name' => 'Foo', 'email' => 'foo@google.com', 'identity' => 'foo'));
     $this->assertResultSuccess($ret);
     ok($id = $ret->id);
     is('Foo', $author->name);
     is('foo@google.com', $author->email);
     $ret = $author->load($id);
     $this->assertResultSuccess($ret);
     is($id, $author->id);
     is('Foo', $author->name);
     is('foo@google.com', $author->email);
     is(false, $author->confirmed);
     $ret = $author->find(array('name' => 'Foo'));
     $this->assertResultSuccess($ret);
     is($id, $author->id);
     is('Foo', $author->name);
     is('foo@google.com', $author->email);
     is(false, $author->confirmed);
     $ret = $author->update(array('name' => 'Bar'));
     $this->assertResultSuccess($ret);
     is('Bar', $author->name);
     $ret = $author->delete();
     $this->assertResultSuccess($ret);
     $data = $author->toArray();
     $this->assertEmpty($data);
 }
開發者ID:azole,項目名稱:LazyRecord,代碼行數:42,代碼來源:AuthorModelTest.php

示例9: testCreateRecordWithEmptyArgument

 public function testCreateRecordWithEmptyArgument()
 {
     $author = new Author();
     $ret = $author->create(array());
     $this->assertResultFail($ret);
     ok($ret->message);
     like('/Empty arguments/', $ret->message);
 }
開發者ID:corneltek,項目名稱:lazyrecord,代碼行數:8,代碼來源:AuthorModelTest.php

示例10: mysql_query

if (is_null($action)) {
    $query = 'UPDATE confa_posts set views=views + 1 where id=' . $msg_id;
    $result = mysql_query($query);
    if (!$result) {
        mysql_log(__FILE__, 'query failed ' . mysql_error() . ' QUERY: ' . $query);
        die('Query failed');
    }
}
if (!is_null($action)) {
    if (!strcmp($action, "like")) {
        if (like($user_id, $msg_id, 1) === false) {
            die('Query failed');
        }
    } else {
        if (!strcmp($action, "dislike")) {
            if (like($user_id, $msg_id, -1) === false) {
                die('Query failed');
            }
        } else {
            if (!strcmp($action, "bookmark")) {
                if (bookmark($user_id, $msg_id, true) == false) {
                    die('Query failed');
                }
            } else {
                if (!strcmp($action, "unbookmark")) {
                    if (bookmark($user_id, $msg_id, false) == false) {
                        die('Query failed');
                    }
                } else {
                    if (!strcmp($action, "closethread") || !strcmp($action, "openthread")) {
                        $query = "SELECT t.author as t_author, t.properties as t_properties, t.id as thread_id  from confa_threads t, confa_posts p where p.thread_id = t.id and p.id=" . $msg_id;
開發者ID:BGmot,項目名稱:kitchen,代碼行數:31,代碼來源:msg.php

示例11: function

    $response->setContentType('application/json');
    return $response;
});
/**
 * DELETE /messages/$id/like
 */
$app->delete('/api/messages/{id:[0-9]+}/like', function ($msg_id) {
    global $logged_in, $user_id, $err_login;
    $response = new Response();
    if (!$logged_in) {
        $response->setStatusCode(403, 'Authentication error');
        $response->setContentType('application/json');
        $response->setJsonContent(array('status' => 'ERROR', 'messages' => array(is_null($err_login) ? "User not logged in" : $err_login)));
        return $response;
    }
    $new_value = like($user_id, $msg_id, -1);
    if ($new_value === false) {
        // error
        $response->setStatusCode(400, 'Error');
        $response->setJsonContent(array('status' => 'ERROR', 'messages' => array(mysql_error())));
    } else {
        $response->setJsonContent(array('value' => intval($new_value)));
    }
    $response->setContentType('application/json');
    return $response;
});
/**
 * PUT /messages/$id/bookmark
 */
$app->put('/api/messages/{id:[0-9]+}/bookmark', function ($msg_id) {
    global $logged_in, $user_id, $err_login;
開發者ID:BGmot,項目名稱:kitchen,代碼行數:31,代碼來源:index.php

示例12: testSpecCollection

 function testSpecCollection()
 {
     $opt = new \GetOptionKit\GetOptionKit();
     ok($opt);
     $opt->add('f|foo:', 'option requires a value.');
     $opt->add('b|bar+', 'option with multiple value.');
     $opt->add('z|zoo?', 'option with optional value.');
     $opt->add('v|verbose', 'verbose message.');
     $opt->add('d|debug', 'debug message.');
     $opt->add('long', 'long option name only.');
     $opt->add('s', 'short option name only.');
     ok($opt->specs->all());
     ok($opt->specs);
     ok($opt->getSpecs());
     count_ok(7, $array = $opt->specs->toArray());
     ok(isset($array[0]['long']));
     ok(isset($array[0]['short']));
     ok(isset($array[0]['description']));
     ob_start();
     $opt->specs->printOptions();
     $content = ob_get_contents();
     ob_clean();
     like('/option with/m', $content);
     # echo "\n".$content;
 }
開發者ID:kilmas,項目名稱:framework,代碼行數:25,代碼來源:GetOptionKitTest.php

示例13: returnError

<?php

require './post.php';
$id = $loginUser;
if (!$id) {
    returnError('гКох╣гб╪');
    return;
}
$wall = $_POST['wall_id'];
like($wall, $id);
開發者ID:bdbai,項目名稱:wawall-sae,代碼行數:10,代碼來源:likewall.php

示例14: is

is($r->add('sing', 'singing')->as_string(), 'sing(?:ing)?', 'super slide sing singing');
$r = new Regexp_Assemble();
is($r->add('sing', 'singing', 'sling')->as_string(), 's(?:(?:ing)?|l)ing', 'super slide sing singing sling');
$r = new Regexp_Assemble();
is($r->add('sing', 'singing', 'sling', 'slinging')->as_string(), 'sl?(?:ing)?ing', 'super slide sing singing sling slinging');
$r = new Regexp_Assemble();
is($r->add('sing', 'singing', 'sling', 'slinging', 'sting', 'stinging')->as_string(), 's[lt]?(?:ing)?ing', 'super slide sing singing sling slinging sting stinging');
$r = new Regexp_Assemble();
is($r->add('sing', 'singing', 'sling', 'slinging', 'sting', 'stinging', 'string', 'stringing', 'swing', 'swinging')->as_string(), 's(?:[lw]|tr?)?(?:ing)?ing', 'super slide sing singing sling slinging sting stinging string stringing swing swinging');
$re = new Regexp_Assemble(['flags' => 'i']);
$re->add('^ab', '^are', 'de');
like('able', "/{$re}/", '{^ab ^are de} /i matches able');
like('About', "/{$re}/", '{^ab ^are de} /i matches About');
unlike('bare', "/{$re}/", '{^ab ^are de} /i fails bare');
like('death', "/{$re}/", '{^ab ^are de} /i matches death');
like('DEEP', "/{$re}/", '{^ab ^are de} /i matches DEEP');
$re = new Regexp_Assemble();
$re->add('abc', 'def', 'ghi');
is($re->stats_add(), 3, "stats add 3x3");
is($re->stats_raw(), 9, "stats raw 3x3");
is($re->stats_cooked(), 9, "stats cooked 3x3");
ok(!$re->stats_dup(), "stats dup 3x3");
$re->add('de');
is($re->stats_add(), 4, "stats add 3x3 +1");
is($re->stats_raw(), 11, "stats raw 3x3 +1");
is($re->stats_cooked(), 11, "stats cooked 3x3 +1");
$re = new Regexp_Assemble();
$re->add('\\Qabc.def.ghi\\E');
is($re->stats_add(), 1, "stats add qm");
is($re->stats_raw(), 15, "stats raw qm");
is($re->stats_cooked(), 13, "stats cooked qm");
開發者ID:rti7743,項目名稱:Regexp_Assemble_For_PHP,代碼行數:31,代碼來源:06_general.t.php

示例15: array

	ok(0, 'ok()');
	check_capture(false);

	is(2, 3, 'is()');
	check_capture(false);

	is("2", 3, 'is()');
	check_capture(false);

	isnt(2, 2, 'isnt()');
	check_capture(false);

	isnt(2, "2", 'isnt()');
	check_capture(false);

	like("foo", '!oof!', 'like()');
	check_capture(false);

	unlike("foo", '!oo!', 'unlike()');
	check_capture(false);

	cmp_ok(1, '==', 2, 'cmp_ok()');
	check_capture(false);

	cmp_ok(1, '>', 2, 'cmp_ok()');
	check_capture(false);

	cmp_ok(2, '<', 1, 'cmp_ok()');
	check_capture(false);

	can_ok($test_obj, array('foo', 'bar', 'baz'));
開發者ID:nmx,項目名稱:Modyllic,代碼行數:31,代碼來源:test.php


注:本文中的like函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。