我需要一些幫助一個檸檬水的PHP代碼是在https://github.com/sofadesign/limonadePHP函數包括
我遇到的問題是,當我嘗試運行
class syscore {
public function hello(){
set('post_url', params(0));
include("./templates/{$this->temp}/fullwidth.tpl");
return render('fullwidth');
}
}
,然後加載fullwidth.tpl並運行功能全角
fullwidth.tpl
<?php
global $post;
function fullwidth($vars){
extract($vars);
$post = h($post_url);
}
print_r($this->post($post));
?>
似乎傳遞$post_url
但我不能當我再次嘗試運行print_r($this->post($post))
的全角功能,它說裏面把它傳遞給print_r($this->post($post));
但是它無法找到post()
功能
我已經嘗試了數事情像下面
function fullwidth($vars){
extract($vars);
$post = h($post_url);
print_r(post($post));
}
試圖重新通過
連接到syscore$redi = new syscore();
$redi->connection() <-- this works
$redi->post($post) <-- this does not
這裏是我的滿級syscore
class syscore {
// connect
public function connect($siteDBUserName,$siteDBPass,$siteDBURL,$siteDBPort, $siteDB,$siteTemp){
for ($i=0; $i<1000; $i++) {
$m = new Mongo("mongodb://{$siteDBUserName}:{$siteDBPass}@{$siteDBURL}:{$siteDBPort}", array("persist" => "x", "db"=>$siteDB));
}
// select a database
$this->db = $m->$siteDB;
$this->temp = $siteTemp;
}
public function hello(){
set('post_url', params(0));
include("./templates/{$this->temp}/fullwidth.tpl");
return render('fullwidth');
}
public function menu($data)
{
$this->data = $data;
$collection = $this->db->redi_link;
// find everything in the collection
//print $PASSWORD;
$cursor = $collection->find(array("link_active"=> "1"));
if ($cursor->count() > 0)
{
$fetchmenu = array();
// iterate through the results
while($cursor->hasNext()) {
$fetchmenu[] = ($cursor->getNext());
}
return $fetchmenu;
}
else
{
var_dump($this->db->lastError());
}
}
public function post($data)
{
$this->data = $data;
$collection = $this->db->redi_posts;
// find everything in the collection
//print $PASSWORD;
$cursor = $collection->find(array("post_link"=> $data));
if ($cursor->count() > 0)
{
$posts = array();
// iterate through the results
while($cursor->hasNext()) {
$posts[] = ($cursor->getNext());
}
return $posts;
}
else
{
var_dump($this->db->lastError());
}
}
}
你搖滾!我不知道爲什麼,但你的回答是直截了當的,寫得很好。它做我所需要的,並幫助我在未來做相同的事情。謝謝 – RussellHarrower