Welcome Guest, Not a member yet? Register   Sign In
Multiple DB Where
#1

I am setting up my multiple site data in a custom config file and I able able to set data from database on my config file

But when I use multiple where it disables data I have tried or_where but then cancels out the default where

How can I make my default where work but also work with my other id

It can only seem to work with one website_id.

Name of application > config > setting.php


PHP Code:
<?php

require_once( BASEPATH .'database/DB'EXT );

$db =& DB();

$db->select('website_id');
$db->from($db->dbprefix 'websites');
$website_query $db->get();
$row $website_query->row();

$db->select('*');
$db->from($db->dbprefix 'setting');
$db->where('website_id'"0");
$db->or_where('website_id'$row->website_id); // cancels out where()
$db->order_by('website_id''ASC');
$setting_query $db->get();

foreach (
$setting_query->result_array() as $result) {
    if (!
$result['serialized']) {
        
$config[$result['key']] = $result['value'];
    } else {
        
$config[$result['key']] = unserialize($result['value']);
    }

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

To find out what CI's query builder is really doing, insert the following lines after $setting_query $db->get();
PHP Code:
echo $db->last_query();
die(); 

You could also try to leave out the quotes around 0 in this line:
PHP Code:
$db->where('website_id'"0"); 
because website_id is most likely an integer field, not a text string.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB