| 1 |
<?php |
<?php |
| 2 |
// $Id: photos.install,v 1.1.2.4 2008/09/10 03:08:38 eastcn Exp $ |
// $Id: photos.install,v 1.1.2.5 2009/03/06 08:18:44 eastcn Exp $ |
| 3 |
function photos_schema() { |
function photos_schema() { |
| 4 |
$schema['x_album'] = array( |
$schema['x_album'] = array( |
| 5 |
'fields' => array( |
'fields' => array( |
| 6 |
'pid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
'pid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
| 7 |
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
| 8 |
'count' => array('type' => 'int', 'not null' => TRUE), |
'count' => array('type' => 'int', 'not null' => TRUE), |
| 9 |
'data' => array('type' => 'text', 'default' => '', 'size' => 'big') |
'data' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big') |
| 10 |
), |
), |
| 11 |
'indexes' => array( |
'indexes' => array( |
| 12 |
'fid' => array('fid'), |
'fid' => array('fid'), |
| 18 |
'fields' => array( |
'fields' => array( |
| 19 |
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
'fid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
| 20 |
'pid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
'pid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), |
| 21 |
'des' => array('type' => 'text', 'not null' => TRUE,'size' => 'big'), |
'des' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), |
| 22 |
'wid' => array('type' => 'int', 'size' => 'tiny', 'length' => 4, 'not null' => TRUE), |
'wid' => array('type' => 'int', 'size' => 'tiny', 'length' => 4, 'not null' => TRUE), |
| 23 |
'count' => array('type' => 'int', 'not null' => TRUE), |
'count' => array('type' => 'int', 'not null' => TRUE), |
| 24 |
'comcount' => array('type' => 'int', 'not null' => TRUE), |
'comcount' => array('type' => 'int', 'not null' => TRUE), |
| 143 |
db_drop_index($ret, 'x_album', 'uid'); |
db_drop_index($ret, 'x_album', 'uid'); |
| 144 |
db_change_field($ret, 'x_album', 'uid', 'count', array('type' => 'int', 'not null' => TRUE)); |
db_change_field($ret, 'x_album', 'uid', 'count', array('type' => 'int', 'not null' => TRUE)); |
| 145 |
db_add_index($ret, 'x_album', 'count', array('count')); |
db_add_index($ret, 'x_album', 'count', array('count')); |
| 146 |
db_add_field($ret, 'x_album', 'data', array('type' => 'text', 'default' => '', 'size' => 'big')); |
db_add_field($ret, 'x_album', 'data', array('type' => 'text', 'not null' => TRUE, 'size' => 'big')); |
| 147 |
$result = db_query('SELECT pid FROM {x_album} ORDER BY pid ASC'); |
$result = db_query('SELECT pid FROM {x_album} ORDER BY pid ASC'); |
| 148 |
while($image = db_fetch_object($result)){ |
while($image = db_fetch_object($result)){ |
| 149 |
db_query('UPDATE {x_album} SET count = (SELECT count(pid) FROM {x_image} WHERE pid = %d) WHERE pid = %d', $image->pid, $image->pid); |
db_query('UPDATE {x_album} SET count = (SELECT count(pid) FROM {x_image} WHERE pid = %d) WHERE pid = %d', $image->pid, $image->pid); |