Welcome Guest, Not a member yet? Register   Sign In
  SQL Statement Problem - Combine several rows in a join
Posted by: El Forum - 11-06-2008, 05:20 AM - Replies (2)

[eluser]wiZe[/eluser]
hey there,

i got stuck with one of my SQL statements and need some help. the thing i want to achieve is the following:

there is one groups table which stores all the basic data, which is independant from the language, and one groups_data table which contains the language specific data of each group.

now i want to select my group from the groups table and join it with all available languages from the groups_data table in one statement, so i have all my groups like "laptop, pc, phone" associated with their available languages.

i would like to end up with an array like this:

Code:
Array
(
    [group1_index] => Array
        (
            [group_id] => 1
            [group_unspecific_data] => My Data
            [group_languages] => Array
                (
                    [0] => "de"
                    [1] => "en"
                )
        )

    [group1_index] => Array
        (
            [group_id] => 2
            [group_unspecific_data] => My other Data
            [group_languages] => Array
                (
                    [0] => "de"
                    [1] => "en"
                    [2] => "fr"
                )
        )
    [group...] => ...
)

is it possible to combine several rows with a particular attribute (e.g. the group_id which reffers to the non specific group table) in a join statement? i really appreciate any hints and help, thanks in advance!

p.s.: i will use the active record pattern, but i dont even know the sql syntax for such an opertaion.

edit: i attached an image with a demo of how these tables could look like.


  active record, find numbers of rows
Posted by: El Forum - 11-06-2008, 05:18 AM - Replies (1)

[eluser]dimis[/eluser]
Is there a way to find the number or rows at a select query using the Active Record Class?
Dimis


  Database connectivity error
Posted by: El Forum - 11-06-2008, 04:47 AM - Replies (1)

[eluser]bhakti.thakkar[/eluser]
Hi all,
i am using mssql as my DB and all is fine. but at times i see this error :


Code:
A Database Error Occurred
Unable to select the specified database: MyDB


I am unable to figure it out why is this connectivity problem occuring. Below is my code in config/database.php:

Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "IPDAADRESS : 4233";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "DBName";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

i refresh the page multiple times and things work. what could be the problem.

Please help me

Thanks in anticipation


  Form validation using xajax
Posted by: El Forum - 11-06-2008, 04:35 AM - Replies (8)

[eluser]Unknown[/eluser]
Hello,

I'm pretty new to CI.

I've a form and the validation without xajax works. Now I try to integrate xajax to validate the form. But the validation will not work. If I understand right, the CI validation uses the $_Post variables, but xajax submit the values in another way.

Does anyone has a solution for this?


  SOLVED: Dynamic database connections inheritance
Posted by: El Forum - 11-06-2008, 03:34 AM - Replies (1)

[eluser]rogierb[/eluser]
This one got me puzzled, hopefully someone can offer me a solution;-)

I have a number of database servers I have to connect to, for every company there can be a server or several companies reside on the same server
I do not now how many servers I have to connect to AND I might have to connect to the same server a couple of times depending on a lot of variables.
So here is what I did:

On the master server I stored all possible connections with a connection_name and a company_id
Together they form a unique connection name eg "ADCB123" where connection_name is "ADCB" and the company_id is "123".

Depending on page-needs I create a variable variable "ADCB123" in which I load the connection. If the variable variable already exists I use the connection rather then loadig it again.

Now here the problem, if I check id the connection exists in the controller, it works like a charm. When it doen't exist, it creates it, otherwise is doesn't do anything.

But when I try to do the same in a model, it always creates a new connection. How can I let the model inherit already created connections from the controller? Is this even possible?

If I call the same function from a model twice in a row, it creates the conenctions twice. How can I prevent this?

Hope this makes any sence;-)


Thanx for taking the time,

Rogier


  Submitting form using ajax and validation
Posted by: El Forum - 11-06-2008, 02:18 AM - Replies (1)

[eluser]edwin87[/eluser]
Hello CI.

I've been struggling for a while with this problem.


I want to validate my form after i submitted it.

So when the field name is required and it's empty he has to show a error for me.

Without Ajax it goes like it should. But with Ajax it's a hell.


Here are some examples.

This is the form to submit.

Code:
<?php $this->validation->showError(); ?>
<div id="formContainer">
    &lt;?php echo form_open('aftakkasten/add',array("id"=> 'form'));?&gt;
        &lt;input type="hidden" name="editID" value="&lt;?php echo $hiddenID; ?&gt;"&gt;
        <fieldset class="fieldForm">
            <legend>Aftakkast parameters invoeren</legend>
                &lt;?php foreach($query->result() as $row): ?&gt;
                
                    <table id="invoerscherm" cellspacing="0">
                        <tr>
                            <td>Modbus adres</td>
                            <td>&lt;input type="text" name="modAdres" value="&lt;?php echo $row-&gt;Address;?&gt;" maxlength="3" /></td>
                        </tr>
                        <tr>
                            <td>Proces code</td>
                            <td>&lt;input type="text" name="ProcesCode" value="&lt;?php echo $row-&gt;ProcesCode;?&gt;" maxlength="50" /></td>
                        </tr>
                        
                    </table>
        </fieldset>
</div>

<div class="pos_button">
    &lt;input type="submit" name="submit" value="Opslaan" /&gt;
</div>    

&lt;/form&gt;    
&lt;?php endforeach; ?&gt;

You see i got a other validation function. I've extended the original one.

Here's my code:

Code:
&lt;?php


class MY_Validation extends CI_Validation {

    function MY_Validation()
    {
        parent::CI_Validation();
        
            $this->ci =& get_instance();
    }
    
    function showError()
    {
        if($this->ci->validation->error_string){
        echo '<div id="hiddenBody">';
        echo '</div>';
            echo '<div id="error">';
            echo '<h5>Fout</h5>';
        echo '<div class="errorBody">';
        
        echo $this->ci->validation->error_string;  // Wanneer een error is gecreerd word dit getoond.
        echo '<div class="actionError">';
        echo '&lt;input type="button" value="Doorgaan"&gt;';
        echo '</div>';
        echo '</div>';
        echo '</div>';
        
    }
    
    }
    
}

?&gt;


And here is my ajax function that escape the submit and try to make it a ajax call.


Code:
$(document).ready(function() {
    var options = {
        target:        '#content',   // target element(s) to be updated with server response
           method:    'post'    //beforeSubmit:  showRequest,  // pre-submit callback
           //success:       showResponse  // post-submit callback
    };

    // bind to the form's submit event
    $('#form').submit(function() {
        $(this).ajaxSubmit(options);

        return false;
    });
});


And my controller looks something like this:


Code:
$rules['modAdres']    = "required";
        $this->validation->set_rules($rules);
        $fields['modAdres']    = 'Modbus adres';
        $this->validation->set_fields($fields);
            
        if ($this->validation->run() == FALSE)
        {
            if($this->ajax->isAjax() === false)
            {            
                $data['view']    =    'aftakkasten_view';
                $data['space']    =    $this->fillSpace();
                $data['query']    =    $this->aftakkast_model->getAftak();
                $this->template->load('main',$data);    
            }
            else{
                $data['query']    =    $this->aftakkast_model->getAftak();
                $this->template->load('aftakkasten_view',$data);    
                    
            }

        }else
        {
                $this->save();
        }


Every time i submit the page. Without the value of modAdres the form dont show a error message. Without Ajax it is working.

But customer is king, so i want this to work.

After submit my page try to reload and there's no error message and i can't click anymore on the submit button.

Maybe my ajax call is wrong?

Can somebody please help me with this?


Thanks


  Cache delete after update
Posted by: El Forum - 11-06-2008, 01:31 AM - Replies (4)

[eluser]hykoh[/eluser]
Hello,

i had a few questions about the cache class.

I want to cache a page (e.g. an userprofile) ... but if the user changes his userdata i want delete the old cached page and make a new one.

I think some of you already has solved this ? :-)

Thanks for help


  How do I start Codeigniter?
Posted by: El Forum - 11-06-2008, 01:22 AM - Replies (33)

[eluser]WebSiteGuru[/eluser]
I am a newbie on this subject. OK I am confused on what to do. I had installed CI. Where do I go and start codeigniter? :red: When I go to mysite/ci it show

Quote:Welcome to CodeIgniter!

The page you are looking at is being generated dynamically by CodeIgniter.

If you would like to edit this page you'll find it located at:
system/application/views/welcome_message.php

The corresponding controller for this page is found at:
system/application/controllers/welcome.php

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.


Page rendered in 0.2155 seconds

I am at a lost on this one. Please help explain. How do I start learning how to use this?

Thanks!


  JavaScript INVERT Select form
Posted by: El Forum - 11-05-2008, 07:28 PM - Replies (6)

[eluser]Mitus[/eluser]
Hi, I have a script that I want to submit but the unselected values. But there is a Bug. How can that be corrected then? Here is the code:

Code:
function loopSelected(frm)
{
  var txtSelectedValuesObj = document.getElementById('txtSelectedValues');
  var selectedArray = new Array();
  var selObj = document.getElementById('selSeaShells');
  var i;
  var count = 0;
  for (i=0; i<selObj.options.length; i++) {
    if (selObj.options[i].selected==false) {
      selectedArray[count] = selObj.options[i].value;
      count++;
    }
  }
  txtSelectedValuesObj.value = selectedArray;
  frm.submit(txtSelectedValuesObj.value);
}
This has to run like a normal submit of a form but sending the unselected values.
Code:
&lt;form action="tutorial004_nw.html" method="get"&gt;
  <table border="1" cellpadding="10" cellspacing="0">
  <tr>
    <td valign="top">
      &lt;input type="button" value="Submit"&gt;
      &lt;input type="button" value="Loop Selected"&gt;
      <br />
      <select name="selSea" id="selSeaShells" size="15" multiple="multiple">
        <option value="val0" selected>sea zero</option>
        <option value="val1">sea one</option>
        <option value="val2">sea two</option>
        <option value="val3">sea three</option>
        <option value="val4">sea four</option>
        <option value="val5">adsea one</option>
        <option value="val6">dasea two</option>
        <option value="val7">dasea three</option>
        <option value="val8">dasea four</option>
      </select>
    </td>
    <td valign="top">
      &lt;input type="text" id="txtSelectedValues" /&gt;
      selected array
    </td>
  </tr>
  </table>
&lt;/form&gt;
Has anyone got an Idea on that?
Mitus


  Trouble with unlink and Cache
Posted by: El Forum - 11-05-2008, 06:27 PM - Replies (1)

[eluser]troy_mccormick[/eluser]
Alright...here's the warning that is showing up in the log:

Code:
ERROR - 2008-11-05 16:24:02 --&gt; Severity: Warning --&gt; unlink(C:\wamp\www/system/cache/1c383cd30b7c298ab50293abdfecb7b18) [<a href='function.unlink'>function.unlink</a>]: Permission denied C:\wamp\www\system\codeigniter\Common.php 63

I'm running Windows (XP SP3...) and have made sure the cache folder is not checked as read only (it isn't), yet I still get the error. Why?

Thanks in advance,

Troy


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Redirect with error vali...
by pippuccio76
5 minutes ago
Pass custom variables to ...
by InsiteFX
22 minutes ago
problem with textarea
by InsiteFX
28 minutes ago
Showing pdf on browser
by InsiteFX
33 minutes ago
How to run a single seede...
by kenjis
5 hours ago
directory structure
by kenjis
6 hours ago
Codeigniter 4 extend core...
by kenjis
6 hours ago
blocked by CORS policy
by kenjis
6 hours ago
[CodeIgniter 4 on IIS 10]...
by Bosborne
11 hours ago
[4.5.1] Disabling the deb...
by ozornick
Today, 08:02 AM

Forum Statistics
» Members: 84,214
» Latest member: nhacaiuytinne
» Forum threads: 77,553
» Forum posts: 375,866

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB