Home > CUSTOMIZED

CUSTOMIZED Archive

[wp×SQLite]ページ送り『SELECT FOUND_ROWS()』対応

categoryとかarchiveとか一覧表示すると次のページとかのリンクが出ない。
そんな条件がなければ出るのに…

つまりページ数認識ではないか?

調べてみたところ、結構な記事数があるカテゴリでも
『$wp_query->max_num_pages』が『1ページ』となってしまっている。

つまりSQL文がオカシイ

こんな単純なミスが修正されないハズがないので、
またSQLiteとMySQLとの仕様差異と皆気づくところ。

WP_Queryはwp-includes/query.phpにあるので確認したところ、そりゃ当然アタリ。

Continue reading

[wp×SQLite]Warning: array_merge()

コメントを編集する際にエラーが出てきた。

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/qooga/public_html/wp/wp-includes/comment.php on line 1097

array_mergeに入れるのは両方配列でないといけない。
つまりどっちかが『配列じゃねぇ!!』てことみたいだ。

みてみたら$commentが『Array()』ではなくて『Array』。
確かに配列ではない。でもArray。
どゆこと!?
て思いながらとりあえずの修正。

/wp-includes/comment.phpを修正

以下の13行目を追記

function wp_update_comment($commentarr) {
	global $wpdb;

	// First, get all of the original fields
	$comment = get_comment($commentarr['comment_ID'], ARRAY_A);

	// Escape data pulled from DB.
	$comment = $wpdb->escape($comment);

	$old_status = $comment['comment_approved'];

	// Merge old and new fields with new fields overwriting old ones.
	if(count($comment) > 1)	// @to
	$commentarr = array_merge($comment, $commentarr);

	$commentarr = wp_filter_comment( $commentarr );

コメント出来た。

こんなん繰り返してたら、アップデートしづらくなるなぁ…

[wp×SQLite]Simple Tagsとか使う

色々変わって読みづらくなったので、いっそ書き換え

例えば
SELECT p.post_title FROM テーブル AS p
というSQLがあるとする。

MySQLなら配列は『$うんつら["post_title"]』として返してもらえるんだけど、
SQLiteだと『$うんつら["q.post_title"]』として返される。

そのせいでSimple Tagsとか巧く動かないプラグインが多数ある。

前回同様SQL文を書き換えようと思ったのだけど、
『q.post_title as post_title』みたいに
『AS うんつら』と既に宣言されているものもあるのだから、なかなか巧くいかない。
※q.post_title as post_title AS post_title as post_title てなる

そこで『配列の添字を書き換えて作り直す』修正をする。

Continue reading

[wp×SQLite]ページ編集が巧くいかない

ページの編集が巧く使えない。
あくまでページ編集。
原因は$hierarchical_post_types[0]がうまく取得出来ないとこにあった。

修正は以下。

/wp-includes/post.php修正

function wp_unique_post_slug(~)内

 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode("', '", $wpdb->escape($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";

if (defined("DB_TYPE") && DB_TYPE == "sqlite") {
	$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . $wpdb->escape($hierarchical_post_types[0]) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
}else{
	$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode("', '", $wpdb->escape($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
}

まだまだ他にも問題もありそうだ。
相性悪いプラグインもあるしね。

その内まとめて、SQLite対応マニュアル的なページでも作ろう…

更新@2009.07.19 02:52
公開@2009.06.19 01:29

[wp×SQLite]日付から記事取得

WordPressでSQLiteを使うと、年・月・日 つまりは日付から記事を読み出すのがうまくいかない。
これはMySQLとSQLiteとでSQL文が違うために起きている。

言わば、『MySQLとは違うのだよ MySQLとは!!!』ということ

『YEAR(wp_posts.post_date)=2009』は
 『wp_posts.post_date like "2009-%"』か
 『strftime('%Y',wp_posts.post_date)='2009'』

『MONTH(wp_posts.post_date)=04』は
 『wp_posts.post_date like "%-04-%"』か
 『strftime('%m',wp_posts.post_date)='04'』

『DAYOFMONTH(wp_posts.post_date)=04』は
 『wp_posts.post_date like "%-04-%"』か
 『strftime('%d',wp_posts.post_date)='04'』
に修正が必要

Continue reading

ホーム > CUSTOMIZED

Search
Option
  • Twitter
  • 絵板
Feeds
commercial
Mobile
Meta
Tag Cloud
TOP10
commercial

Return to page top