drupal遇到cache資料毀損或是無法以uid=1的帳號登入之處理方式

因為學校的server常常因為檔案太多(備份),硬碟太小而無法寫入cache檔案或是重新開機後會出現資料庫的故障。

今天發現cache檔案毀損,無法進入。然後最高權限使用者也無法進入(users 資料表也出現問題)

1.需將原來的cache.*三個檔案備份後,從其他相同版本的資料庫中copy好的cache.*過來(記得修改使用者權限為mysql   因為用vi複製後,會是屬於:root)

2.這時候可以進入資料庫了!所以就執行SQL命令修復

repair table 你要修復的資料表(例如users, cache)

搞定!!

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
發表於 Drupal | 發表迴響

新增資料到mysql資料庫(drupal 7)

<?php
// For the following query:
// INSERT INTO {node} (title, uid, created) VALUES (‘Example’, 1, 1221717405)

$add = db_insert(‘test’) // Table name no longer needs { }
->fields(array(
‘name’ => ‘Allen’,

))
->execute();

/*
// Above Example is Equivalent to the Following in D6
$result = db_query("INSERT INTO {node} (title, uid, created) VALUES (%s, %d, %d)", ‘Example’, 1, time());

// OR using drupal_write_record…
$data = array(
‘title’ => ‘Example’,
‘uid’ => 1,
‘created’ => REQUEST_TIME,
);
drupal_write_record(‘node’, $data);
*/
?>

**db_select() 取出資料   (資料表名稱:test, 欄位名稱:name)

<?php
$str = db_select(‘test’,'n’)
->fields(‘n’,array(‘name’))
->execute()
->fetchField();
print $str;
?>

**取出作者發表的文章title

<?php
$query = db_select(‘node’, ‘n’);

$query->join(‘users’, ‘u’, ‘n.uid = u.uid’); //JOIN node with users

//$query->groupBy(‘u.uid’);//GROUP BY user ID

$query->fields(‘n’,array(‘title’,'created’))//SELECT the fields from node
->fields(‘u’,array(‘name’))//SELECT the fields from user
->orderBy(‘created’, ‘DESC’)//ORDER BY created
->range(0,60);//LIMIT to 2 records

$result = $query->execute();

while($record = $result->fetchField()) {
print_r($record);
echo "<hr>";
}
?>

ps.

while($record = $result->fetchField()) {  **可用下列表示,但是就不是fetchField()的形式了,而是 fetchAssoc()的形式:

foreach ($result as $record) {

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
發表於 Api, Drupal | 發表迴響

今天是數位日 1010101 (101年1月1日)

1010101
這是101年一月一日的簡寫(跟二進碼表示法一模一樣):剛剛突然發現的。

難怪今天超想買數位產品,連寫程式都超有FU。

因為昨天將兒子的滑鼠給摔壞了,所以今天到燦坤買了一支新鼠給他。亞太電信客服提醒好幾次可以續約了,所以就在附近的亞太電信特約店辦了快兩萬元的續約手續,買了Samsung i909 + HTC wildfire S…兩個門號都辦了無限上網,一舉將GSM, CDMA兩種規格都升級到智慧型手機。

上午寫了一段程式也很順利,果然今天1010101是個數位日!!

有趣的數字組合,也為2012年的元旦增添樂趣!

期待今年一切順利成功!

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
發表於 生活雜記 | 發表迴響

Panels 7.x-3.0-alpha3 Property of non-object error with Stylizer preview

in Dp7 the Panels 7.x-3.0-alpha3 using Add a new style-> Panel Pane 出現的錯誤

bug report: http://drupal.org/node/1115610

Patch file: non-object-stylizer-preview-1115610-7.patch

 

panels_1

panels_2

 

patch方法:

ftp non-object-stylizer-preview-1115610-7.patch to /modules/panels/**

patch –p1 < non-object-stylizer-preview-1115610-7.patch

OK  as below:

sshot-1

sshot-2

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
發表於 bugs_patch, Drupal | 發表迴響

升級views7 rc1–>rc3 出現的Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column ..

這是發生在11/25將Drupal 核心由7.8升級到7.9

並將views模組由rc1升級到rc3所發生的references模組(node_reference/node_reference.module)之問題

問題如下:

Debug:

‘Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column \’field_data_field_course.nid\’ in \’on clause\"

於 views_plugin_query_default->execute() (/var/www/html/show-win/sites/all/modules/views-rc3/plugins/views_plugin_query_default.inc 中的第 1386 行)。

發生錯誤畫面

發生錯誤畫面

===========以下這篇大作#11的回覆patch檔案搞定======

Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column ..
參考:http://drupal.org/node/1275096#comment-4981442

The patch in #11 fixed my issue. Thanks!

=========Patch file=======

http://drupal.org/files/issues/column_not_found_1054_unkonw_column-1275096-11.patch

=======

解決辦法:by Gigo 2011/11/26

  1. 將上面的檔案更名為new.patch,並下載上傳到 /sites/all/modules/new.patch
  2. 利用linux的patch指令:(在哪邊執行以下的指令呢?答案是:modules/  )
    patch -p1 < new.patch
  3. 到drupal的後台管理->設定->效能   清除所有的catch
  4. 搞定

————————

參考如下:

http://drupal.org/patch

What is a patch?

http://drupal.org/node/367392

Making a Drupal patch with Git

製作patch, 使用patch的方法

http://childblue.blogspot.com/2006/12/patch-patch_22.html

製作patch, 使用patch的方法

原文出處

製作patch

diff -Naur olddir newdir > new-patch

製作patch要注意的事項

記得要讓前置的目錄階層數有相同的深度,例如:

— old/modules/pcitable Mon Sep 27 11:03:56 1999

+++ new/modules/pcitable Tue Dec 19 20:05:41 2000

上面用diff產生的結果,可以給patch使用

— old/try1/other/modules/pcitable Mon Sep 27 11:03:56 1999

+++ new/modules/pcitable Tue Dec 19 20:05:41 2000

但是上面產生的結果在使用上可能會發生問題,第一行目錄的深度有四層,而第二行只有兩層. 這裡建議直接修改 —和+++後面的內容讓目錄結構有相同的深度.

使用Patch命令

patch -p0 < new-patch

patch -p1 < new-patch

這兩個命令的差異在於目前工作目錄的不同

另外一種用法是讓patch 從標準輸入讀取資料:

cat new-patch | patch -p0

還有一種用法是讓patch 讀取 "here document"的方式

( 省略此種方法之舉例 )

Patch指令的階層 ( -p0 和 -p1 的差別 )

假設patch的表頭如下

— old/modules/pcitable Mon Sep 27 11:03:56 1999

+++ new/modules/pcitable Tue Dec 19 20:05:41 2000

使用 -p0 , patch會期待在你目前的工作目錄下有一個名為new的目錄, 接著會有modules目錄, 然後是pictable目錄

使用 -p1 , 路徑的第一層會被拿掉, 也就是patch期待工作目錄下有 modules目錄, 然後是pictable目錄

-p2, -p3, …. 以此類推

Patch使用方法

Patch表頭

開頭是 —, +++, 並且接著被比較的檔案

同個patch檔包含多個patch

瀏覽patch檔的方法

less /tmp/file-patch

/—

n

n

n

 

( /— 會搜尋—,而n會搜尋下個出現的— )

Hunk

每個patch的段落稱作 Hunk,每個段落皆以兩個老鼠記號 ( @@ ) 開始, 直至下個段落開始,或者下個patch header為止

Howto apply a patch file to my Linux / UNIX source code

http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/

Q.I know that I can patch binary package using up2date or yum command in Linux but what I’m wondering is if there’s a way to apply a patch file to downloaded source code under Linux / UNIX like operating system source tree?

A. Linux and UNIX source software often comes with security and other patches. You can download them from Internet or project home page. There is a command called patch that apply a diff file or patch to an original source tree.

patch takes a patch file patchfile containing a difference listing produced by the diff program and applies those differences to one or more original files, producing patched versions. Normally the patched versions are put in place of the originals.

The following usage is most commonly used:

$ patch -p1 < {/path/to/patch/file}

To apply a patch, one could run the following command in a shell:

$ patch < /path/to/file

Patches can be undone, or reversed, with the ‘-R’ option:

$ patch -R < /path/to/file

Above 3 are basic usage read the man page of patch command for more information and usage:

% man patch

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • MySpace
  • Plurk
  • RSS
  • Google Buzz
  • Live
發表於 Drupal, modules | 發表迴響