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


PHP Line::addConnection方法代码示例

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


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

示例1: loadFromArray

/**
    @deprecated?
*/
function loadFromArray($array)
{
    $markers = array();
    $id = "";
    foreach ($array as $marker_array) {
        $marker = new Marker($marker_array[0]['lat'], $marker_array[0]['lng'], $marker_array[0]['id'], $marker_array[0]['name']);
        $id = $marker_array[0]['id'];
        echo "functions.load: processing {$id}<br/>\n";
        $count = count($marker_array);
        for ($i = 1; $i < $count; $i++) {
            $line_array = $marker_array[$i];
            $line = new Line($line_array[0]['img'], $marker_array[0]['url'], $marker_array[0]['name']);
            $count1 = count($line_array);
            for ($j = 1; $j < $count1; $j++) {
                $connection_array = $line_array[$j];
                $connection = new Connection($connection_array[0]['id'], $connection_array[0]['type'], $connection_array[0]['start'], $connection_array[0]['end'], $connection_array[0]['duration']);
                $line->addConnection($connection);
            }
            $marker->addLine($line);
        }
        $markers[$id] = $marker;
    }
    return $markers;
}
开发者ID:abc2mit,项目名称:abc2mit.github.io,代码行数:27,代码来源:functions.php

示例2: retrieveMarkers

/**
    Retrieves the markers from the DB and loads them into an array. It creates full
    Marker objects with Line and Connection objects.
    
    @return an array of Markers
*/
function retrieveMarkers()
{
    $debug = false;
    $markers = array();
    $query = 'SELECT * FROM markers';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    while ($line = mysql_fetch_array($result, MYSQL_BOTH)) {
        $id = $line['id'];
        $lat = $line['lat'];
        $lng = $line['lng'];
        $name = $line['name'];
        $url = $line['url'];
        if ($debug) {
            echo "building marker: {$name} ({$id})<br/>";
        }
        $marker = new Marker($lat, $lng, $id, $name);
        $marker->setURL($url);
        // grab all connections
        $conn_query = "SELECT * FROM connections WHERE id='" . $id . "'";
        $conn_result = mysql_query($conn_query) or die('Query failed: ' . mysql_error());
        $lines = array();
        $line_names = array();
        while ($conn = mysql_fetch_array($conn_result, MYSQL_BOTH)) {
            // grab all variables from DB
            $marker_id = $conn['marker_id'];
            $day = $conn['day'];
            $duration = $conn['duration'];
            $line = $conn['line'];
            $type = $conn['type'];
            $start = $conn['start'];
            $end = $conn['end'];
            if ($debug) {
                echo "-&gt;found connection: {$marker_id}<br/>";
            }
            // create a new connection
            $connection = new Connection($marker_id, $type, $start, $end, $day, $duration);
            $marker_line = $lines["{$line}"];
            if (is_null($marker_line)) {
                $marker_line = array();
            }
            $marker_line[] = $connection;
            // add it to an array. we need it later.
            if ($debug) {
                echo "-&gt;found line: {$line}<br/>";
            }
            $lines["{$line}"] = $marker_line;
            if (!in_array($line, $line_names)) {
                if ($debug) {
                    echo "adding {$line} to line_names<br/>";
                }
                $line_names[] = $line;
            }
        }
        // connection loop
        if ($debug) {
            echo "line_names count: " . count($line_names) . "<br/>";
        }
        // retrieved all connections and set them in their appropriate lines.
        // now we need to create the lines
        foreach ($line_names as $line_name) {
            if ($debug) {
                echo "-&gt;looking at line: {$line_name}<br/>";
            }
            // for each line, grab the data from the database
            $line_query = "SELECT * FROM `lines` WHERE name='" . $line_name . "'";
            $line_result = mysql_query($line_query) or die('Query failed: ' . mysql_error());
            // the line_name is the unique key for that table, so we only need to get the first one
            $line_array = mysql_fetch_array($line_result, MYSQL_BOTH);
            $lname = $line_array['name'];
            $lurl = $line_array['url'];
            $limg = $line_array['img'];
            $line = new Line($limg, $lurl, $lname);
            if ($debug) {
                echo "--&gt;found line: " . $lname . "<br/>";
            }
            // now add all the connections
            $connections = $lines["{$line_name}"];
            foreach ($connections as $connection) {
                // each one is a connection object from above. add it
                $line->addConnection($connection);
                if ($debug) {
                    echo "---&gt;adding " . $connection->id . " to {$line_name}<br/>";
                }
            }
            // now add the line to the marker
            $marker->addLine($line);
            if ($debug) {
                echo "--&gt;adding {$line_name} to {$name}<br/>";
            }
        }
        // line loop
        // the marker object is created and populated. add to the markers array.
        $markers["{$id}"] = $marker;
        if ($debug) {
//.........这里部分代码省略.........
开发者ID:abc2mit,项目名称:abc2mit.github.io,代码行数:101,代码来源:db.php


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