Welcome Guest, Not a member yet? Register   Sign In
  sortable divs jquery and codeigniter
Posted by: El Forum - 10-13-2008, 06:06 AM - Replies (2)

[eluser]flashingback[/eluser]
Hello,

I am trying to make a sortable image list with jquery and CI. I've got the jquery part working but the php part doesn't want to work. It seems to update the mysql table but not right

This is wat I have:

first of al jquery gets the positioning of the divs I have sorted on update.

Code:
$("#sortable").sortable({
        handle: ".h_ico",
        update: function(){
        
                    stringDiv = "";
                    $("#sortable").children().each(function(i) {
                      var li = $(this);
                     if(li.attr("class") == "project"){
                      stringDiv += " "+li.attr("id") + '=' + i + '&';
                      }
                    });
    
                     $.ajax({
                       type: "POST",
                       url: "<?=base_url().'index.php/admin/updatelist'?>",
                       data: stringDiv,
                       success: function(msg){
                         alert( "Data Saved: " + msg );
                            [removed].reload( true );
                       }
                     });

                }
            
    });

So in the updatelist I receive something like this:

$_POST[0] = 1
$_POST[1] = 0
$_POST[2] = 2

updatelist method :

Code:
function updatelist () {
        
        $data =  $this->Projects->getList() ;
    
        foreach ( $_POST as $key => $value )
        {
            
            $newrank = $data[$key]->rank;
            $rank = $data[$value]->rank;
            if($rank != $newrank){
                $this->Projects->switchProject($rank,$newrank);
            }
            
        }
                
    }

and the switchProject method contains this (this probably contains the fault):

Code:
function switchProject ($rank,$newrank){
        
        $this->db->query("UPDATE gallery SET rank='".$newrank."' WHERE rank='".$rank."' ");
        
    }


  active record database query using order_by
Posted by: El Forum - 10-13-2008, 06:05 AM - Replies (2)

[eluser]blasto333[/eluser]
This Works

Code:
$modules=array();
$query = $this->db->query('SELECT * FROM modules ORDER BY `sort` asc');

foreach($query->result() as $row)
{
    $modules[]=$row->id;
}



This doesn't work (Fatal error: Call to undefined method CI_DB_mysql_driver::result() )
Code:
$modules=array();
$this->db->get('modules');
$query = $this->db->order_by("sort", "asc");

foreach($query->result() as $row)
{
    $modules[]=$row->id;
}
return $modules;

Any ideas? I am using CI 1.6.3


  Object of class CI_DB_mysql_result could not be converted to string
Posted by: El Forum - 10-13-2008, 05:52 AM - Replies (6)

[eluser]Mitja B.[/eluser]

Code:
$data['title'] = ":: BlueTraker :: Home ::";
$data['query'] = $this->db->query("SELECT * FROM news WHERE Status > 0 ORDER BY id DESC LIMIT 4");

and i get

Quote:A PHP Error was encountered

Severity: 4096

Message: Object of class CI_DB_mysql_result could not be converted to string

Filename: libraries/Parser.php

Line Number: 63

What is wrong here?


  Barclays EPDQ Integration
Posted by: El Forum - 10-13-2008, 04:37 AM - Replies (2)

[eluser]Billy Khan[/eluser]
Does anyone know if there is a plugin available for integrating barclays epdq payment gateway? (I am guessing this is a uk only system, could be wrong though)

Trawling through the documentation and wondered if there was a free/commercially available script that handles all this.

Thanks


  Remapping
Posted by: El Forum - 10-13-2008, 04:11 AM - No Replies

[eluser]Unknown[/eluser]
Hi!
How to apply _remap function in the controller? The explanation of the remaping in CodeIgniter1.6.3 is incomplete..,is there any one can help me to use this function _remap?thanks...


  Question about multiple databases
Posted by: El Forum - 10-13-2008, 03:57 AM - Replies (2)

[eluser]St0neyx[/eluser]
hi all

i'm building a project where i'm using 2 databases, both are on the same server as the website.
now i read a lot of topics and the userguide, and what i find is this.

Code:
$DB1 = $this->load->darabase('dbname 1', true);
$DB2 = $this->load->darabase('dbname 2', true);

now i tryd this, but it isn't working as i hoped..
Im using a lot of DHTML and ajax in my project, wich means that i use a lot of calls to functions.

now when i call a function that needs to gether data from both databases i did this:

Code:
$DB1 = $this->load->darabase('dbname 1', true);
$DB2 = $this->load->darabase('dbname 2', true);

$query1 = "SELECT * FROM bla";
$query2 = "SELECT * FROM blaat";

$result1 = $DB1->query($query1);
$result2 = $DB2->query($query2);

$data['result1'] = $result1;
$data['result2'] = $result2;

return $data;

This will not work because when the first query is send, it usses the second db connection.
Kinda wierd because i put them in different variables.

To make it work i have to do this (in every function)

Code:
$DB1          = $this->load->darabase('dbname 1', true);
$query1      = "SELECT * FROM bla";
$result1      = $DB1->query($query1);
$data['result1'] = $result1;

// not nessessery, but do it anyhow
$DB1->close();

$DB2          = $this->load->darabase('dbname 2', true);
$query2      = "SELECT * FROM blaat";
$result2      = $DB2->query($query2);
$data['result2'] = $result2;

So my solution is, i made a model (db_model):

Code:
function query($query, $db)
{
    switch ($db)
    {
        case 'db1':
            // select db
            $DB1 = $this->load->database('db1', TRUE);
                
            // send query
            $result = $DB1->query($query);
                
            // close the db
            $DB1->close();
                
            // return the resultset
            return $result;
            break;
        case 'db2':
            // select the right db
            $DB2 = $this->load->database('db2', TRUE);
                
            // send query
            $result = $DB2->query($query);
                
            // close the db
            $DB2->close();
                
            // return the resultset
            return $result;
            break;
        default:
            // generate error
            break;
    }
}

Call from function:

Code:
$query1 = "SELECT * FROM bla";
$query2 = "SELECT * FROM blaat";

$data['result1'] = $this->db_model->query($query1, 'db1');
$data['result2'] = $this->db_model->query($query2, 'db2');

return $data

This will work, but im not sure if this is the way to fix it.
Can i get some feedback on this??

Kind regards


  authentication, redirect and security
Posted by: El Forum - 10-13-2008, 03:22 AM - Replies (4)

[eluser]vanzl[/eluser]
Is redirecting secure way to prevent non logged in users to acces parts of your page?

In most examples i've seen something like this:

Code:
class Admin extends Controller{
function admin(){
  parent::controller();
  if (!$this->auth->logged_in()){
   redirect('somewhere');
  }
}
}

I guess my question is: can a potential hacker somehow avoid the redirect and still access admin functions?


  formatting query results
Posted by: El Forum - 10-13-2008, 03:15 AM - Replies (6)

[eluser]gafro[/eluser]
Hey Guys and Gals,

Looking for some info with the results received from a query.

overview example:

DB (table name = items)

id name
1 titleone
2 titletwo
3 titlethree
4 titlefour

Controller

$this->db-get('items');

view

<ul>
&lt;?php foreach($items-result() as $item):?&gt;

<li>&lt;?=$item->titleon?&gt;</li>
&lt;?php endforeach;?&gt;
</ul>


What I'd like to do is add a class to the li on every 3rd row.

<ul>
<li>itemone</li>
<li>itemtwo</li>
<li class="classname">itemthree</li>
<li>itemfour</li>
</ul>

I'm not sure how to get access to the keys from the array the active record has returned.

Can anyone shed some light or point me in the right direction.

Cheers all
Gafroninja


  Using Models within Models
Posted by: El Forum - 10-13-2008, 02:53 AM - Replies (2)

[eluser]Moon 111[/eluser]
I have a Model that has common functions to be used throughout the entire website. How can I load/use it in other Models?

Thanks,
- Moshe


  Screen renders differently
Posted by: El Forum - 10-13-2008, 02:06 AM - Replies (2)

[eluser]EthanSP[/eluser]
Why does the screen of the program I made in CI displays correctly in my PC but displays differently on other PC's connecting to my PC? I wonder if you can access it: http://192.168.4.235/jsp/scms. Kindly comment. THanks.


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

Username
  

Password
  





Latest Threads
SQL server connection not...
by davis.lasis
7 minutes ago
Validation | trim causes ...
by Gary
2 hours ago
Problem with session hand...
by Julesb
3 hours ago
External script access to...
by PomaryLinea
3 hours ago
Is it possible to go back...
by Bosborne
4 hours ago
VIRUS reported after Chro...
by InsiteFX
7 hours ago
Codeigniter4 version 4.5....
by kenjis
Yesterday, 04:10 PM
Cannot access protected p...
by xsPurX
Yesterday, 02:10 PM
Update to v4.5.1, same us...
by xsPurX
Yesterday, 08:31 AM
How to use Codeigniter wi...
by kenjis
Yesterday, 05:06 AM

Forum Statistics
» Members: 85,467
» Latest member: trankhuyhashbet
» Forum threads: 77,582
» Forum posts: 376,015

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB