Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Kohana] Zapytanie w ORM.
Pytajka
post 25.04.2012, 16:42:18
Post #1





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 6.09.2011

Ostrzeżenie: (0%)
-----


Witam,

może ktoś mnie uświadczyć jak przerobić to zapytanie -

  1. SELECT * FROM `bricks` INNER JOIN `users` ON `bricks`.author = `users`.id WHERE `bricks`.id = '$id'


na ORM?
Go to the top of the page
+Quote Post
lukasz_os
post 25.04.2012, 16:57:39
Post #2





Grupa: Zarejestrowani
Postów: 203
Pomógł: 55
Dołączył: 23.11.2008
Skąd: UKF

Ostrzeżenie: (0%)
-----


  1. $entry = ORM::factory('bricks')
  2. ->select('users.*')
  3. ->join('users','inner')
  4. ->on('bricks.author', '=', 'users.id')
  5. ->where('bricks.id', '=', $id)
  6. ->find();


nie testowane gdyż nie mam odpowiednich danych smile.gif


--------------------
Pomagam jeśli mam czas oraz jak się na tym znam :D
Go to the top of the page
+Quote Post
Pytajka
post 25.04.2012, 17:14:42
Post #3





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 6.09.2011

Ostrzeżenie: (0%)
-----


Cytat
Unknown column 'bricks.id' in 'where clause' [ SELECT `brick`.* FROM `bricks` AS `brick` INNER JOIN `users` ON (`bricks`.`author` = `users`.`id`) WHERE `bricks`.`id` = '20' ]
Go to the top of the page
+Quote Post
lukasz_os
post 25.04.2012, 17:18:36
Post #4





Grupa: Zarejestrowani
Postów: 203
Pomógł: 55
Dołączył: 23.11.2008
Skąd: UKF

Ostrzeżenie: (0%)
-----


  1. $entry = ORM::factory('bricks')
  2. ->select('users.*')
  3. ->join('users','inner')
  4. ->on('brick.author', '=', 'users.id')
  5. ->where('brick.id', '=', $id)
  6. ->find();


Bo ORM zmieniło ci nazwy kolumn z bricks na brick smile.gif

Ten post edytował lukasz_os 25.04.2012, 17:21:18


--------------------
Pomagam jeśli mam czas oraz jak się na tym znam :D
Go to the top of the page
+Quote Post
pedro84
post 25.04.2012, 17:19:01
Post #5





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

Ostrzeżenie: (0%)
-----


Nie masz kolumny id w tej tabeli.


--------------------
Google knows the answer...
Go to the top of the page
+Quote Post
Pytajka
post 25.04.2012, 17:20:24
Post #6





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 6.09.2011

Ostrzeżenie: (0%)
-----


Oczywiście, że mam :- )
Go to the top of the page
+Quote Post
pedro84
post 25.04.2012, 17:38:05
Post #7





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

Ostrzeżenie: (0%)
-----


Pokaż strukturę tabel.


--------------------
Google knows the answer...
Go to the top of the page
+Quote Post
Pytajka
post 25.04.2012, 18:01:18
Post #8





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 6.09.2011

Ostrzeżenie: (0%)
-----


Cytat
Kolumna Typ Null Domyślnie Komentarze MIME
id int(11) Nie
title varchar(45) Nie
link varchar(55) Nie
description varchar(255) Nie
type varchar(15) Nie
date datetime Nie
author int(11) Nie


Ten post edytował Pytajka 25.04.2012, 18:01:49
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 20.06.2025 - 01:58