2
나는 wordpress 기능을 사용하려고하고 $wbdb
은 wordpress 외부의 스크립트에서 사용하고 있지만 어떻게해야하는지 알 수 없다.클래스를 확장하여 Wordpress 4.0 외부에서 사용 하시겠습니까?
내가 시도 :
require_once('./wp-load.php'); // this is the correct path is tested.
class cron extends wpdb {
public function results(){
$sql = 'SELECT sub_id,email,cate_id FROM co_subsriber WHERE status = 0 ORDER BY sub_id ASC LIMIT '.$start.',750'; // $start =0
$records = $wpdb->get_results($sql);
}
}
내가 얻을 오류
Warning: Missing argument 1 for wpdb::__construct(), called in wp-db.php on line 578
Warning: Missing argument 2 for wpdb::__construct() called in wp-db.php on line 578
Warning: Missing argument 3 for wpdb::__construct() called in wp-db.php on line 578
Warning: Missing argument 4 for wpdb::__construct() called in wp-db.php on line 578
Notice: Undefined variable: dbuser wp-db.php on line 602 and all other pass, hostname...
내가 언급 할 필요가 .... 데이터베이스
를 선택할 수 없습니다와
require_once('./wp-load.php');
그 간단한 PHP를 사용하여 OOP wi 그것은 잘 작동합니다.
그래서 실제로 어떤 수업을 연장해야합니까?
여기를 읽으십시오. http://codex.wordpress.org/Integrating_WordPress_with_Your_Website – Napolux
왜 어쨌든 클래스를 확장 하시겠습니까? 그것을 생성자의 클래스에 저장하고 사용하십시오. –
@Napolux가'require ('./ wp-blog-header.php');'같은 오류를 추가했습니다. 또한 그것은 당신이 만든 수업에서 어떻게하는지 말하지 않습니다. – user3467855