当前位置: 首页>>代码示例>>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;未经允许,请勿转载。