Welcome Guest, Not a member yet? Register   Sign In
  Set select problem after form validation
Posted by: El Forum - 06-09-2008, 01:51 PM - Replies (7)

[eluser]Dave S[/eluser]
I have a form on which I ask people to enter their birthdate by choosing from a select menu. I am having a problem getting the set_select to work so that the year they have chosen is still selected in case the validation fails. The problem is occurring because I have the years loading in a loop like so:

Code:
<select name="BirthYear">
        <option value="">Year</option>
        &lt;?PHP
            $CurrentYear = date("Y");
            $StartYear = $CurrentYear - 100;
            while ($CurrentYear >= $StartYear) {
                echo "<option value=\"$CurrentYear\"".$this->validation->set_select('BirthYear', '$CurrentYear').">$CurrentYear</option>";
                $CurrentYear--;
            }
        ?&gt;
        </select>

rather than having 100 lines of <option>'s.

I was able to get set_select to work fine for the month values because they are not in a loop. I'm sure it's just something silly that I've done, but the above code does not keep the selected value when the form is submitted and fails validation.

Does anyone have any suggestions? Thanks in advance!


  Using Multiple Database Groups at Once? [SOLVED!!]
Posted by: El Forum - 06-09-2008, 01:50 PM - Replies (4)

[eluser]fancms[/eluser]
I am working on something that uses 2 databases. However, it's pretty tedious having to copy/paste

Code:
$one = $this->load->database('dbone',TRUE);
$two = $this->load->database('dbtwo',TRUE);

in every function (and there's a lot of 'em!). I can't put the two lines in an external function because then I'm unable to use $one->select, $two->query, etc format. Tried putting them in the constructor function, and that doesn't work either.

Is there any shortcut to copy/pasting those two lines hundreds of times?


  MSSQL Pagination Holly Grial?
Posted by: El Forum - 06-09-2008, 12:11 PM - Replies (20)

[eluser]gusa[/eluser]
hi everybody!
tired of implementing an ad-hoc solution every time i want to paginate under mssql i've decided to overwrite codeigniter's mssql driver. with this solution it's possible to use such an impossible thing as active record plus pagination with mssql server.

the steps are:

1) edit database/drivers/mssql_driver.php and add these methods:

Code:
function _get_pkeys($table) {
    $stmt = @mssql_init('SP_PKEYS', $this->conn_id);
    @mssql_bind($stmt, '@table_name', $table, SQLVARCHAR, false);
    $rs = @mssql_execute($stmt);
    $n = @mssql_num_rows($rs);
    if ($n == 0) {
        return $this->display_error('db_unsuported_feature');
    }
    $result = array();
    while ($p = mssql_fetch_assoc($rs)) {
        $result[] = $p['COLUMN_NAME'];
    }
    return $result;
}

function _compile_select()
{
    if (is_numeric($this->ar_limit)) {
        $limit = $this->ar_limit;
        $offset = $this->ar_offset;
        
        $pkeys = $this->_get_pkeys($this->ar_from[0]);
        $keys = implode(', ', $pkeys);
        if (count($pkeys) > 1) {
            // convert many keys into a unique pk
            foreach ($pkeys as &$pk) {
                $pk = 'convert(varchar, '.$pk.')';
            }
            $key = implode("+':'+", $pkeys);
        } else {
            $key = $pkeys[0];
        }
        
        // select clause
        
        $select = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';
        $select .= $key.', ';
        $select .= (count($this->ar_select) == 0) ? '*' : implode(', ', $this->ar_select);
        
        // from clause
        
        if (count($this->ar_from) > 0)
        {
            $from = "FROM ".implode(', ', $this->ar_from);
        }
        
        // join clause
        
        if (count($this->ar_join) > 0)
        {        
            $join = implode("\n", $this->ar_join);
        }

        // where clause
        
        if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
        {
            $where = "WHERE ";
        } else {
            $where = "WHERE 1=1 ";
        }

        $where .= implode("\n", $this->ar_where);
        
        if (count($this->ar_like) > 0)
        {
            if (count($this->ar_where) > 0)
            {
                $where .= " AND ";
            }

            $where .= implode("\n", $this->ar_like);
        }

        // order by clause
        
        if (count($this->ar_orderby) > 0)
        {
            $orderby = "ORDER BY ".implode(', ', $this->ar_orderby);
            
            if ($this->ar_order !== FALSE)
            {
                $orderby .= ($this->ar_order == 'desc') ? ' DESC' : ' ASC';
            }
        } else {
            $orderby = 'ORDER BY '.$keys.' ASC';
        }
        
        // the hack
        
        $offset--;
        $top = $limit + $offset;

        $sql = "
            $select
            $from
            $join
            WHERE $key IN (
                SELECT TOP $limit $key
                $from
                $join
                $where AND $key NOT IN (
                    SELECT TOP $offset $key
                    $from
                    $join
                    $where
                    ORDER BY $keys
                )
                ORDER BY $keys ASC
            )
            $orderby";
    } else {
        $sql = parent::_compile_select();
    }
    return $sql;
}

ready! now you can make your active record query as always (with some limitations):

Code:
$this->db->select('blah');
$this->db->from('yara');
...
$this->db->limit(10, 20);

limitations:

1) the first table in the from clause must have a primary key defined.
2) group by clause and having clause are discarded, so if you want pagination with group by and having go back to the traditional way.

good luck!


  Error 1054
Posted by: El Forum - 06-09-2008, 11:12 AM - Replies (1)

[eluser]ealonw[/eluser]
Can anyone tell me what this means?



Error Number: 1054

Unknown column '_ci_scaffolding' in 'field list'

UPDATE usercomment SET _ci_scaffolding = 1, _ci_scaff_table = 'usercomment', id = NULL, fname = NULL, lname = NULL, email = NULL, comment = NULL WHERE 0 = 'id' AND 1


  Getting same info with diferent queries
Posted by: El Forum - 06-09-2008, 10:21 AM - Replies (12)

[eluser]tjmthome[/eluser]
Hi, I need some help, with a strange behaivour of CI or maybe im too novice.

Code:
//in a MODEL i have some funcions with queries
function getUsers(){
$qryUsrs = $this->db>query('select * from users');
return $qryUsrs->result_array();
}
function getDocs(){
$qryDocs = $this->db>query('select * from documents');
return $qryDocs->result_array();
}

//in my CONTROLLER i call both
$this->load->model('qry_model');
$data['users'] = $this->qry_model->getUsers();
$data['docs'] = $this->qry_model->getDocs();
$this->load->view('my_view',$data);

//in my VIEW I display both queries each in a table
echo $this->table->generate($users);
echo $this->table->generate($docs);

The problem is that in both tables I see exactly the same data, i suppose i need to 'clear' the info in the array before getting another, someone knows how i must to proceed to get the correct data in each table?

Thanks in advance


  helpe, uploading problem!
Posted by: El Forum - 06-09-2008, 10:15 AM - Replies (2)

[eluser]benyu[/eluser]
When i using upload library got a error:
The temporary folder is missing.

In fact i have set up "upload_tmp_dir" to 'C:\windows\temp' directory which has EveryOne full control permission!

Although i have tried setting "upload_tmp_dir" manual with ini_set function in upload.php file,but get no effective still!

runing env:
windows2003 + iis6 + rewrite_isap2 + php5.2.6

thanks!


  Accessing $_FILES without having to upload a file
Posted by: El Forum - 06-09-2008, 08:54 AM - Replies (4)

[eluser]garbetjie[/eluser]
Hi all.

I'm a real n00b when it comes to CodeIgniter, as I've just started my first project in it a few days ago.

There is an issue that I can't seem resolve when it comes to uploading files, and reading the data of the uploaded file.

For this specific project, I'm storing my images as a LONGBLOB in a database. Because of this, I don't really need to store the file in a permanent location on the server when uploading it. All I need is access to the uploaded file's details, and I'll then insert the raw data into the LONGBLOB field.

Now my real question is, is there functionality native to CI that will allow for this, or am I going to have to write my own class to handle these types of uploads?

Any help whatsoever would really be appreciated.

Thanks,
G.


  Google indexing problem on a godaddy/CI-based website
Posted by: El Forum - 06-09-2008, 08:34 AM - Replies (5)

[eluser]treworld[/eluser]
Hi,

There seems to be a problem with Google and other search engines not being able to index a CI-based website which is being hosted by Godaddy. I'm not sure what is causing it. I've tried to look for answers on google, but no luck.

Here is the current htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|icons|robots\.txt|style|tmp|public|xajax_js|js|listings|maintenance|favicon\.ico|stats)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]


Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php index.htm
AddHandler x-httpd-php5 .php

Any help is greatly appreciated.

Thank you.


  About layout rendering
Posted by: El Forum - 06-09-2008, 08:27 AM - Replies (13)

[eluser]José Mota[/eluser]
I have a question for the developers of CI. As some other friends spoke, layout rendering is a major plus in good application design / development. I'm to ask when is layout rendering going to be integrated in CI, if it's not already integrated? If it is, please please tell me where that is!
I come from a Rails world like some if not most friends here and they sure loved Rails for that! (as well as some other things, of course xD)

Thanks. Cheers!


  Announcing Baobab Code Ignited website framework
Posted by: El Forum - 06-09-2008, 07:24 AM - Replies (6)

[eluser]Dready[/eluser]
Dear all,

I'm happy to introduce to you the project I'm working on for 6 months now : Baobab. It uses Code Igniter and allows you to easily code the "good" part of a website. Baobab includes so far :

* basic user management system, with privileges.

You can also easily code a wrapper to allow authentication on another database

* tree-like website

In Baobab, every "page" of the website is a "node" of the tree. Node handlers allows you to customize node display. Baobab comes bundled with simple handlers, as "story","blog","image","book".

* jquery integration

To simplify development, ease user controls ala web2.0 , Baobab comes with the jquery javascript library.

* integrated theming support

Every bit of Baobab render happens through templates (via a tweaked code igniter Parser library). You can assign a theme to a whole hierarchy of the website.

It's still an early development, but as you know opensource, "release soon, release often".

Please note that some jquery stuffed javascript don't work on Internet Explorer...

[2009 04 23] : Version 0.0.2 is available

You can find it on Baobab's website


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

Username
  

Password
  





Latest Threads
Modify users data as an a...
by padam
2 hours ago
Asset Minification Packag...
by tarcisiodev1
2 hours ago
Is it possible to go back...
by ejimenezo
4 hours ago
Error / Shield 1.0.3 + Ci...
by kcs
8 hours ago
SQL server connection not...
by davis.lasis
9 hours ago
Validation | trim causes ...
by Gary
11 hours ago
Problem with session hand...
by Julesb
11 hours ago
External script access to...
by PomaryLinea
Today, 03:58 AM
VIRUS reported after Chro...
by InsiteFX
Yesterday, 11:34 PM
Codeigniter4 version 4.5....
by kenjis
Yesterday, 04:10 PM

Forum Statistics
» Members: 85,494
» Latest member: daimonezeca7
» Forum threads: 77,585
» Forum posts: 376,020

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB