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


PHP SQLite3::createFunction方法代码示例

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


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

示例1: locationKeywordSearch

/**
 * Get a list of venues which are whitin $distance of location ($lat, long)
 * and have a category similar to $keyword
 * 
 * returns list of venue information
 */
function locationKeywordSearch($lat, $long, $keyword, $distance, $limit = 25)
{
    $_SESSION['lat'] = $lat;
    $_SESSION['long'] = $long;
    $_SESSION['keyword'] = $keyword;
    global $databaseName;
    $db = new SQLite3($databaseName);
    // Attach methods haversineGreatCircleDistance,stringSimilarity to
    // Database engine so that we can use them in our query
    $db->createFunction("DISTANCE", "haversineGreatCircleDistance");
    $db->createFunction("SIMILARITY", "stringSimilarity");
    // Search query: get venue information for venues close to location, with categories most similar to the keyword/phrase
    $statement = $db->prepare('SELECT venueId, name, lat, long, categories, address, DISTANCE(lat, long) as distance, SIMILARITY(categories)' . " as similarity FROM Venues WHERE distance < :dist ORDER BY similarity DESC LIMIT :limit");
    // Bind some parameters to the query
    $statement->bindValue(':limit', $limit);
    $statement->bindValue(':dist', $distance, SQLITE3_INTEGER);
    // Obtain the venues from the db and put them in a list
    $qry = $statement->execute();
    $venues = [];
    while ($venue = $qry->fetchArray()) {
        $venues[] = $venue;
    }
    $db->close();
    return $venues;
}
开发者ID:wardlawp,项目名称:VenueWebsite,代码行数:31,代码来源:SearchMethods.php

示例2: mainAction

 public function mainAction()
 {
     $this->dbconf = Phalcon\DI::getDefault()->getConfig()->database;
     $file = $this->getDI()->getConfig()->dirs->config . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR . $this->dbconf->adapter . '.sql';
     $this->schema = realpath($file);
     if ($this->schema === false) {
         throw new \Exception('Unsupported database adapter: ' . $this->dbconf->adapter);
     }
     echo "{$this->dbconf->adapter}\n";
     echo $this->dropDatabase();
     switch ($this->dbconf->adapter) {
         case 'mysql':
             echo $this->createDatabase();
             echo $this->loadSchema();
             echo $this->loadFixtures();
             break;
         case 'sqlite':
             $dbfile = $this->di->getConfig()->dirs->data . DIRECTORY_SEPARATOR . $this->di->get('config')->database->dbname . '.sqlite';
             $db = new SQLite3($dbfile);
             chmod($dbfile, 0664);
             $db->createFunction('MD5', 'md5');
             $db->exec(file_get_contents($this->schema));
             $db->exec(file_get_contents(preg_replace('/sqlite.sql$/', 'fixtures.sql', $this->schema)));
             break;
         default:
             throw new \Exception('Unsupported database adapter: ' . $this->dbconf->adapter);
             break;
     }
 }
开发者ID:siciarek,项目名称:suggester,代码行数:29,代码来源:DbTask.php

示例3: __construct

 public function __construct($filename, $flags = null, $encryptionKey = null, $busyTimeout = null, array $userDefinedFunctions = array(), array $userDefinedExtensions = array())
 {
     if (null === $flags) {
         $flags = \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE;
     }
     $this->_conn = new SQLite3($filename, $flags, $encryptionKey);
     if (null !== $busyTimeout) {
         $this->_conn->busyTimeout($busyTimeout);
     } else {
         $this->_conn->busyTimeout(60000);
     }
     foreach ($userDefinedFunctions as $fn => $data) {
         $this->_conn->createFunction($fn, $data['callback'], $data['numArgs']);
     }
     foreach ($userDefinedExtensions as $extension) {
         $this->_conn->loadExtension($extension);
     }
 }
开发者ID:jsor,项目名称:dbal-sqlite3,代码行数:18,代码来源:Connection.php

示例4: fetch_relevant_pois

/**
 * @param $lat latitude of the client's location
 * @param $lon longitude of the client's location
 * @param $dbname name of the database
 * @param $lang Detected language for localization
 * @return string An XML string containing POIs close to the client's location
 */
function fetch_relevant_pois($lat, $lon, $dbname)
{
    if (is_null($lat) || is_null($lon)) {
        // Return empty result.
        createLocationBasedAREL(array());
        return null;
    }
    //connect to the SQLite database
    $db = new SQLite3($dbname);
    $db->createFunction('DISTANCE', 'sqlite3_distance_func', 4);
    //run a proximity query to fetch ONLY close by POIs
    $records = $db->query("SELECT * FROM POIsM WHERE DISTANCE(latitude,longitude,{$lat},{$lon}) < 50 ORDER BY abs(latitude - {$lat}) + abs(longitude - {$lon});");
    //build an AREL XML with the relevant POIs
    $poiXML = build_xml($records, "en");
    $db->close();
    return $poiXML;
}
开发者ID:Theekshana,项目名称:junaio-quickstarts,代码行数:24,代码来源:index.php

示例5: sendSMS

                if (is_dir($dirPath . $folder)) {
                    deleteDir($dirPath . $folder . "/");
                } else {
                    unlink($dirPath . $folder);
                }
            }
        }
        rmdir($dirPath);
        closedir($temp);
    }
}
function sendSMS($nomorhp, $sms)
{
    global $config;
    $status = file_get_contents($config->SMS_URL_Parameter . "?" . $config->SMS_Number_Parameter . "={$nomorhp}&" . $config->SMS_Text_Parameter . "=" . urlencode($sms) . "&" . $config->SMS_Additional_Parameter);
    if (strpos($status, $config->SMS_Success_Parameter) === false) {
        return '<span class="label label-danger"><span class="glyphicon glyphicon-remove"></span>' . " GAGAL</span><br>\r\n";
    } else {
        return '<span class="label label-success"><span class="glyphicon glyphicon-ok"></span>' . " SUKSES</span><br>\r\n";
    }
}
$db->createFunction('labelExist', 'labelExist', 2);
function labelExist($label, $dicari)
{
    if (strpos($label, $dicari) === false) {
        return false;
    } else {
        return true;
    }
}
$bulanArray = array("Januari", "Pebruari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
开发者ID:HuiZone,项目名称:Waruga,代码行数:31,代码来源:conf.php

示例6: parse

<?php

require "../includes/include.php";
$sections = [];
$count = 0;
$sqlite = new SQLite3($db_str, SQLITE3_OPEN_READONLY);
$sqlite->createFunction("parse", "parseRecord", 12);
$sqlite->exec("select parse(s_id,s_name,s_container,s_position,s_created,s_updated,l_id,l_url,l_comment,l_created,l_updated,l_accessed) from sections left join links on s_id=l_section order by s_id asc");
usort($sections, function ($a, $b) {
    return $a->getPosition() - $b->getPosition();
});
$all = "";
foreach ($sections as $section) {
    if ($section->getContainer() == null) {
        $all .= $section->sortSections()->sortLinks()->toString();
    }
}
$sqlite->close();
header('Content-Type: text/plain');
header("Content-Transfer-Encoding: Ascii");
header("Content-disposition: attachment; filename=\"links-" . date("Ymd-His") . ".txt\"");
print $all;
开发者ID:jatolmed,项目名称:links,代码行数:22,代码来源:all_txt.php

示例7: recorded

    }
    if (!(strpos($followers, $login) === FALSE)) {
        return 1;
    }
    if (!(strpos($persons, $login) === FALSE)) {
        return 1;
    }
    return 0;
}
function recorded($login, $persons)
{
    if (!(strpos($persons, $login) === FALSE)) {
        return 1;
    }
    return 0;
}
function month($time)
{
    return utf8_encode(strftime('%B %Y', $time));
}
function week($time)
{
    $t2 = $time - $_SESSION["date_debut"];
    //timestamp du 2 octobre 2014
    return floor($t2 / 604800);
    //Correspond au nombre de seconde pour 7 jours
}
$db->createFunction('concerned', 'concerned', 4);
$db->createFunction('recorded', 'recorded', 2);
$db->createFunction('month', 'month', 1);
$db->createFunction('week', 'week', 1);
开发者ID:mslagmu,项目名称:Atelier,代码行数:31,代码来源:open_db.php


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