errors with my query
Archived from the Xataface Users forum.
Jean — Mon Jun 23, 2008 1:53 am
Hi Steve,
When I add a new entry with the new form, I have these errors :
- Code: Select all
- `Notice: Object to string conversion in /var/www/html/dataface-0.7.1/Dataface/QueryBuilder.php on line 482
Notice: Uninitialized string offset: 0 in /var/www/html/dataface-0.7.1/Dataface/QuickForm.php on line 286
Notice: Object to string conversion in /var/www/html/dataface-0.7.1/Dataface/QueryBuilder.php on line 482`
When I look at the possible cause, my array contains the username.
When I connect as an administrator I don’t have the first error!!??!!
Do you have an idea, ? Do you need more precisions ?
Jean
shannah — Mon Jun 23, 2008 8:26 am
What code is on those lines (my versions of dataface are slightly different)?
If you can put some debugging code just before those warnings to print out what value is causing the problems that would help.
-Steve
Jean — Tue Jun 24, 2008 12:36 am
Hi Steve,
Yes sure.
May be it comes from my checkbox groups :
- Code: Select all
- `[glpi_type_computers]
widget:label = ordinateurs
widget:type = checkbox
vocabulary = computer
widget:separator=”
“[glpi_type_monitors]
widget:label = écrans
widget:type = checkbox
vocabulary = ecran
widget:separator=”
“[glpi_type_peripherals]
widget:label = périphériques
widget:type = checkbox
vocabulary = peripherique
widget:separator=”
“[glpi_type_printers]
widget:label = imprimantes
widget:type = checkbox
vocabulary = imprimante
widget:separator=”
“`
and in the valuelists
- Code: Select all
- `[computer]
sql = “SELECT DISTINCT ID, name from glpi_type_computers GROUP BY name”
[ecran]
sql = “SELECT DISTINCT ID, name from glpi_type_monitors GROUP BY name”[peripherique]
sql = “SELECT DISTINCT ID, name from glpi_type_peripherals where name not like ‘<%’ GROUP BY name”[imprimante]
sql = “SELECT DISTINCT ID, name from glpi_type_printers GROUP BY name”`
I hope this code will give some insights. The authentification is through active directory with an ldap authentification type. May be the errors come from it because when I use a print it is the username that is displayed in an array.
The first error is located in the QueryBuilder.php in the line
$words = explode(‘ OR ‘, $value);
- Code: Select all
- `function _where($query=array(), $merge=true){
if ( $merge ){
$query = array_merge( $this->_query, $query);
}
foreach ($query as $key=>$value) {
if ( $value === null ){
unset($query[$key]);
}
}
$where = “WHERE “;
$missing_key = false;
$limit = ‘’;
$use_where = false;
$fields = array();foreach ($query as $key=>$value){
if ( strpos($key,’-‘) !== 0 ) $fields[$key] = $value;
}
//echo ‘<pre>‘;print_r($fields);echo ‘</pre>‘;exit;
foreach ($fields as $key=>$value){
if ( isset($this->_fields[$key]) ){
$field =& $this->_fields[$key];$words = explode(‘ OR ‘, $value);
if ( count($words) > 1){
$where .= ‘(‘;
$conj = ‘OR’;
} else {
$conj = ‘AND’;
}`
Thank you for your help!
Jean
shannah — Tue Jun 24, 2008 9:56 am
So it sounds like your username field has some problems. It might be wise to look at the ldap auth module more closely to make sure that when it returns a username it is actually a string and not an array.
Some more debugging code you can add to help might be to add some checking right before the error:
if ( is_array($value) ){
print_r($value);
echo Dataface_Error::printStackTrace();
}