rendered paste body<?php
class Projets_model extends Model {
var $titre = '';
var $reference = '';
function Projets_model()
{
// Call the Model constructor
parent::Model();
}
function getProjetShort()
{
$this->db->select('titre, reference');
$this->db->orderby('poids', 'asc');
$query = $this->db->get('projet');
return $query->result();
}
function getProjetLong($projet)
{
$this->db->select('*');
$this->db->from('projet');
$this->db->where('reference', $projet);
$query = $this->db->get();
return $query->result();
}
function getImages($projet)
{
$this->db->select('*');
$this->db->from('image');
$this->db->where('reference', $projet);
$this->db->orderby('poids','asc');
$query = $this->db->get();
return $query->result();
}
function insert_entry()
{
$this->titre = $_POST['titre'];
$this->reference = $_POST['reference'];
$this->db->insert('projet', $this);
}
function updateProjet($projet)
{
$data_update = array(
'titre' => $_POST['titre'],
'description' => $_POST['description'],
'info' => $_POST['info'],
'type' => $_POST['type'],
'client' => $_POST['client']
);
$this->titre = $_POST['titre'];
$this->description = $_POST['description'];
$this->info = $_POST['info'];
$this->type = $_POST['type'];
$this->client = $_POST['client'];
$this->db->where('reference', $projet);
$this->db->update('projet', $data_update);
}
function incImagePoids($image_id)
{
print($image_id." ");
$this ->db->select('poids');
$this->db->from('image');
$this->db->where('image_id', $image_id);
$query = $this->db->get();
$this->poidsActuel = $query->result();
$this->poidsActuel = $this->poidsActuel[0]->poids;
//print($this->poidsActuel);
$this ->db->select('image_id');
$this->db->from('image');
$this->db->where('poids >', $this->poidsActuel);
$this->db->limit(1);
$query = $this->db->get();
$this->image_idSup = $query->result();
$this->image_idSup = $this->image_idSup[0]->image_id;
print($this->image_idSup." ");
$this ->db->select('poids');
$this->db->from('image');
$this->db->where('image_id', $this->image_idSup);
$query = $this->db->get();
$this->poidsSup = $query->result();
$this->poidsSup = $this->poidsSup[0]->poids;
$this->db->where('image_id', $image_id);
$this->db->set('poids', $this->poidsSup);
$this->db->limit(1);
$this->db->update('image');
print_r($this->db->queries);
/*
$data = array(
'poids' => $this->poidsActuel
);
$this->db->where('image_id', $this->image_idSup);
//$this->db->update('image', $data);
*/
}
}
?>