Loading ...
Sorry, an error occurred while loading the content.
 

Re: [id-ruby] Re: optimasi query di rails

Expand Messages
  • Arie Kusuma Atmaja
    ... Bisa. Baca lagi kelas Pagination. Lihat di source code dari manual Rails. Nanti bisa pakai AR find biasa ataupun kustomisasi pakai sql (sesuai kebutuhan).
    Message 1 of 7 , Jan 19, 2007
      aditya_jamop wrote:
      > --- In id-ruby@yahoogroups.com, Arie Kusuma Atmaja
      > <ariekusumaatmaja@...> wrote:
      >> Sekolah.find_by_sql('SELECT * FROM sekolahs')
      >>
      >>
      >
      > kalo pake find_by_sql entar gak bisa di paginate donk pak

      Bisa. Baca lagi kelas Pagination. Lihat di source code dari manual
      Rails. Nanti bisa pakai AR find biasa ataupun kustomisasi pakai sql
      (sesuai kebutuhan).

      --
      Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren / YM! = riyari3
      http://ariekusumaatmaja.wordpress.com http://groups.yahoo.com/groups/id-ruby
      http://groups-beta.google.com/group/id-jp # nihongo o benkyoshimashou
      http://groups-beta.google.com/group/id-fr # parlons francais
    • ~inung;
      Sekolah.find(:all) = ngambil data sekolah aja, Kelas.find(:all, :include[:sekolah, :siswa]) = ngambil smua data, join semua table, ... = kalo cara gini apa
      Message 2 of 7 , Jan 19, 2007
        Sekolah.find(:all) => ngambil data sekolah aja,
        Kelas.find(:all, :include[:sekolah, :siswa]) =>
        ngambil smua data, join semua table,

        --- Arie Kusuma Atmaja <ariekusumaatmaja@...>
        wrote:
        > Sekolah.find_by_sql('SELECT * FROM sekolahs')
        => kalo cara gini apa engga kurang "elegan"?


        >
        > aditya_jamop wrote:
        > > ada 3 model
        > > -sekolah
        > > -kelas
        > > -siswa
        > >
        > > scriptnya :
        > > class Sekolah < ActiveRecord::Base
        >
        > >
        >
        > >
        > > has_many :kelass
        >
        > >
        >
        > >
        >
        > >
        >
        > >
        >
        > >
        >
        > >
        >
        > > end
        > >
        > > class Kelas < ActiveRecord::Base
        >
        > >
        >
        > >
        > > belongs_to :sekolah
        >
        > >
        >
        > >
        > >
        >
        > >
        >
        > >
        >
        > >
        >
        > > has_many
        > :siswas
        > > end
        > >
        > > class Siswa < ActiveRecord::Base
        >
        > >
        >
        > >
        > > belongs_to :Kelas
        >
        > >
        >
        > >
        > >
        >
        > >
        >
        > >
        >
        > >
        >
        > > end
        > >
        > > pertanyaannya bila saya hanya ingin menampilkan
        > data sekolah saja,
        > > bagaimana caranya supaya data kelas dan siswa
        > tidak ikut ter-join,
        > > sehingga saya bisa menampilkan data dengan lebih
        > efisien ?
        > >
        > > makasih sebelumnya
        > >
        >
        > --
        > Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren / YM!
        > = riyari3
        > http://ariekusumaatmaja.wordpress.com
        > http://groups.yahoo.com/groups/id-ruby
        > http://groups-beta.google.com/group/id-jp # nihongo
        > o benkyoshimashou
        > http://groups-beta.google.com/group/id-fr # parlons
        > francais
        >
        >




        ____________________________________________________________________________________
        No need to miss a message. Get email on-the-go
        with Yahoo! Mail for Mobile. Get started.
        http://mobile.yahoo.com/mail
      • ~inung;
        Setau saya, fungsi2 paginate yang ada di rails 1.1.6 itu kurang memuaskan, (lupa lagi deh link2nya...). Nah, engga tau deh klo yang di rails 1.2 udh ada
        Message 3 of 7 , Jan 19, 2007
          Setau saya, fungsi2 paginate yang ada di rails 1.1.6
          itu kurang memuaskan, (lupa lagi deh link2nya...).
          Nah, engga tau deh klo yang di rails 1.2 udh ada
          pembaruan lagi blom tuh di paginate. Klo pertanyaan:
          klo pake find_by_sql ngga bisa di-paging dong?
          Jawabnya: Bisa! coba pake ini:
          Sekolah.find_by_sql("the_query LIMIT ?,?",
          params[:num], params[:ofset])

          ~inung;

          --- Arie Kusuma Atmaja <ariekusumaatmaja@...>
          wrote:

          > aditya_jamop wrote:
          > > --- In id-ruby@yahoogroups.com, Arie Kusuma Atmaja
          > > <ariekusumaatmaja@...> wrote:
          > >> Sekolah.find_by_sql('SELECT * FROM sekolahs')
          > >>
          > >>
          > >
          > > kalo pake find_by_sql entar gak bisa di paginate
          > donk pak
          >
          > Bisa. Baca lagi kelas Pagination. Lihat di source
          > code dari manual
          > Rails. Nanti bisa pakai AR find biasa ataupun
          > kustomisasi pakai sql
          > (sesuai kebutuhan).
          >
          > --
          > Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren / YM!
          > = riyari3
          > http://ariekusumaatmaja.wordpress.com
          > http://groups.yahoo.com/groups/id-ruby
          > http://groups-beta.google.com/group/id-jp # nihongo
          > o benkyoshimashou
          > http://groups-beta.google.com/group/id-fr # parlons
          > francais
          >
          >




          ____________________________________________________________________________________
          Sucker-punch spam with award-winning protection.
          Try the free Yahoo! Mail Beta.
          http://advision.webevents.yahoo.com/mailbeta/features_spam.html
        • ~inung;
          Ralat: Kelas.find(: all, :include[:sekolah, :siswa]) = harusnya: Kelas.find(:all, :include= [:sekolah, :siswa]) ...
          Message 4 of 7 , Jan 19, 2007
            Ralat:
            Kelas.find(: all, :include[:sekolah, :siswa])
            => harusnya:
            Kelas.find(:all, :include=>[:sekolah, :siswa])

            --- "~inung;" <inoeng_satriani@...> wrote:

            > Sekolah.find(:all) => ngambil data sekolah aja,
            > Kelas.find(:all, :include[:sekolah, :siswa]) =>
            > ngambil smua data, join semua table,
            >
            > --- Arie Kusuma Atmaja <ariekusumaatmaja@...>
            > wrote:
            > > Sekolah.find_by_sql('SELECT * FROM sekolahs')
            > => kalo cara gini apa engga kurang "elegan"?
            >
            >
            > >
            > > aditya_jamop wrote:
            > > > ada 3 model
            > > > -sekolah
            > > > -kelas
            > > > -siswa
            > > >
            > > > scriptnya :
            > > > class Sekolah < ActiveRecord::Base
            >
            > >
            > > >
            >
            > >
            > > >
            > > > has_many :kelass
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > > end
            > > >
            > > > class Kelas < ActiveRecord::Base
            >
            > >
            > > >
            >
            > >
            > > >
            > > > belongs_to :sekolah
            >
            > >
            > > >
            >
            > >
            > > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > > has_many
            > > :siswas
            > > > end
            > > >
            > > > class Siswa < ActiveRecord::Base
            >
            > >
            > > >
            >
            > >
            > > >
            > > > belongs_to :Kelas
            >
            > >
            > > >
            >
            > >
            > > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > >
            >
            > >
            > > > end
            > > >
            > > > pertanyaannya bila saya hanya ingin menampilkan
            > > data sekolah saja,
            > > > bagaimana caranya supaya data kelas dan siswa
            > > tidak ikut ter-join,
            > > > sehingga saya bisa menampilkan data dengan lebih
            > > efisien ?
            > > >
            > > > makasih sebelumnya
            > > >
            > >
            > > --
            > > Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren /
            > YM!
            > > = riyari3
            > > http://ariekusumaatmaja.wordpress.com
            > > http://groups.yahoo.com/groups/id-ruby
            > > http://groups-beta.google.com/group/id-jp #
            > nihongo
            > > o benkyoshimashou
            > > http://groups-beta.google.com/group/id-fr #
            > parlons
            > > francais
            > >
            > >
            >
            >
            >
            >
            >
            ____________________________________________________________________________________
            > No need to miss a message. Get email on-the-go
            > with Yahoo! Mail for Mobile. Get started.
            > http://mobile.yahoo.com/mail
            >




            ____________________________________________________________________________________
            Don't get soaked. Take a quick peak at the forecast
            with the Yahoo! Search weather shortcut.
            http://tools.search.yahoo.com/shortcuts/#loc_weather
          Your message has been successfully submitted and would be delivered to recipients shortly.