Skip to content
Snippets Groups Projects
Commit 7aee0037 authored by HUET Guillaume's avatar HUET Guillaume
Browse files

préparation TD2

parent 414183d7
Branches
No related tags found
No related merge requests found
driver=mysql
host=localhost
database=annonce
username=root
password=
charset=utf8
prefix=
\ No newline at end of file
<?php
require 'vendor/autoload.php';
use PrepTD2\model\annonce;
use PrepTD2\model\categorie;
use PrepTD2\model\photo;
use PrepTD2\model\cateannonce;
$config = ['settings' => [
'displayErrorDetails' => true
]];
$db = new \Illuminate\Database\Capsule\Manager();
$db->addConnection(parse_ini_file('src/conf/conf.ini'));
$db->setAsGlobal();
$db->bootEloquent();
$container = new \Slim\Container($config);
$app = new \Slim\App($container);
$photos =photo::all()->where("idannonce","=",22)->get();
$photos2 =photo::all()->where("idannonce","=",22,"taille_octet",">=",100000)->get();
$annonces = annonce::join("photo","annonce.id","=","photo.idannonce")
->groupBy('annonce.id','titre','date','texte')
->having('count(annonce.id)', '>=', 4)
->select('annonce.id','titre','date','texte')
->get();
$annonces = annonce::join("photo","annonce.id","=","photo.idannonce")
->where('taille_octet','>',100000)
->distinct()
->get();
$photo = new photo();
$photo->file ="";
$photo->date=date('d/m/y',time());
$photo->idannonce=22;
$photo->taille_octet=0;
$photo->save();
$cateannonce = new cateannonce();
$cateannonce->idannonce=22;
$cateannonce->idcategorie=42;
$cateannonce->save();
$cateannonce2 = new cateannonce();
$cateannonce2->idannonce=22;
$cateannonce2->idcategorie=73;
$cateannonce2->save();
<?php
namespace PrepTD2\model;
class annonce extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'annonce';
protected $primaryKey = 'id';
public $timestamps = false;
public function photos()
{
return $this->hasMany('photo');
}
}
\ No newline at end of file
<?php
namespace PrepTD2\model;
class cateannonce extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'idannonce';
protected $primaryKey = 'id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace PrepTD2\model;
class categorie extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'categorie';
protected $primaryKey = 'id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace PrepTD2\model;
class photo extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'photo';
protected $primaryKey = 'id';
public $timestamps = false;
public function annonce()
{
return $this->belongsTo('annonce');
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment