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


PHP School::fromDatabase方法代碼示例

本文整理匯總了PHP中School::fromDatabase方法的典型用法代碼示例。如果您正苦於以下問題:PHP School::fromDatabase方法的具體用法?PHP School::fromDatabase怎麽用?PHP School::fromDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在School的用法示例。


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

示例1: json_encode

   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
***/
require_once 'master.php';
header('Content-type: application/json');
if ($invalidparameters) {
    die(json_encode(array('success' => 0, 'message' => 'Invalid parameters.')));
}
if (!isset($_REQUEST['college']) || !is_numeric($_REQUEST['college'])) {
    die(json_encode(array('success' => 0, 'message' => 'Invalid college.')));
}
$collegeid = $_REQUEST['college'];
$school = new School($collegeid);
if (!$school->fromDatabase($db)) {
    die(json_encode(array('success' => 0, 'message' => 'Cannot find college.')));
}
$students = $db->getStudentsAttending($school, $curhs, $curyear);
$data = array('success' => 1, 'students' => array());
// return a JSON list of students given the college's id
foreach ($students as $student) {
    $concentrations = arraytocsv($db->getConcentrations($student));
    $data['students'][] = array('id' => $student->id, 'name' => $student->name, 'image' => $student->imageurl, 'rank' => $student->rank, 'isFriend' => (bool) $myself->isFriends($facebook, $student), 'concentrations' => $concentrations);
}
echo json_encode($data);
開發者ID:hadesain,項目名稱:CollegesMap,代碼行數:31,代碼來源:ajax_getAttending.php

示例2: School

}
// get my high school data
$hs_associds = $db->getAssociations($myself->id, AssociationTypes::HighSchool);
$myhs = $hs_associds[0];
if (!$myhs) {
    if (!isset($myfb['education'])) {
        $myhs = new School(0);
    } else {
        foreach ($myfb['education'] as $education) {
            if ($education['type'] == "High School") {
                $hsid = $education['school']['id'];
                break;
            }
        }
        $myhs = new School($hsid);
        if (!$myhs->fromDatabase($db)) {
            $myhs->fromFacebook($facebook);
        }
    }
}
// get current page data
$schoolid = $_REQUEST['school'];
$curyear = $_REQUEST['year'];
$curhs = new School($schoolid);
$invalidparameters = false;
if (!isset($_REQUEST['school']) || !isset($_REQUEST['year']) || !$curhs->fromFacebook($facebook) || !is_numeric($curyear) || $curyear < 1900 || $curyear > 2900) {
    $invalidparameters = true;
    $curyear = $myself->year;
    $curhs = $myhs;
}
// writable if we are in the current hs
開發者ID:hadesain,項目名稱:CollegesMap,代碼行數:31,代碼來源:master.php

示例3: die

        $concentrations = $education['concentration'];
    } else {
        if ($education['school']['id'] == $curhs->id) {
            $incurschool = true;
        }
    }
}
if (!$incurschool) {
    // not in this school
    die(json_encode(array('success' => 0, 'message' => 'Friend not in same school.', 'request' => $request_message_generic)));
}
if (!$college) {
    // no college added
    die(json_encode(array('success' => 0, 'message' => 'Friend has no college defined.', 'request' => $request_message_specific)));
}
if (!$college->fromDatabase($db)) {
    if (!$college->fromFacebook($facebook)) {
        die(json_encode(array('success' => 0, 'message' => 'Cannot load school.', 'request' => $request_message_specific)));
    }
    if ($college->latitude == 0 || $college->longitude == 0) {
        die(json_encode(array('success' => 0, 'message' => 'Cannot locate school.', 'request' => $request_message_specific)));
    }
    // new school, add to database
    $college->updateDatabase($db);
}
// add friend to hs
$db->addAssociation($friend, $curhs->id, AssociationTypes::HighSchool);
// add friend to college
$db->addAssociation($friend, $college->id, AssociationTypes::College);
// add concentrations
if (!$concentrations) {
開發者ID:hadesain,項目名稱:CollegesMap,代碼行數:31,代碼來源:ajax_addFriend.php


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