6 |
# |
# |
7 |
# Niels Rogalla <niro@magellan-linux.de> |
# Niels Rogalla <niro@magellan-linux.de> |
8 |
# |
# |
9 |
# $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/mysqlfunctions,v 1.3 2008-06-05 18:01:41 niro Exp $ |
# $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/mysqlfunctions,v 1.4 2008-06-05 18:04:41 niro Exp $ |
10 |
|
|
11 |
mysql_command() |
mysql_command() |
12 |
{ |
{ |
158 |
local all_items |
local all_items |
159 |
local i |
local i |
160 |
local COUNT |
local COUNT |
161 |
local serial |
local where_statement |
162 |
|
|
163 |
local table="$1" |
local table="$1" |
164 |
|
|
165 |
if [[ -z $2 ]] |
if [[ -z $2 ]] |
166 |
then |
then |
167 |
serial="${ALX_SERIAL}" |
where_statement="where serial='${ALX_SERIAL}'" |
168 |
else |
else |
169 |
serial="$2" |
where_statement="$2" |
170 |
fi |
fi |
171 |
|
|
172 |
# setup arrays |
# setup arrays |
173 |
all_vars=( $(mysql_enum_colums ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} ${table} show) ) |
all_vars=( $(mysql_enum_colums ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} ${table} show) ) |
174 |
all_items=( $(mysqldo "select * from ${table}") ) |
all_items=( $(mysqldo "select * from ${table} ${where_statement}") ) |
175 |
|
|
176 |
# sanity check |
# sanity check |
177 |
if [[ ${#all_vars[*]} = ${#all_items[*]} ]] |
if [[ ${#all_vars[*]} = ${#all_items[*]} ]] |