chyba, ktera se vyskytne jen obcas a nevim proc

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
wallkysek
Člen | 52
+
0
-

zdravim, mam v template

{var $temp = $nabidka->fetch()}
a potom
<div>{$temp->neco}</div>
Obcas mi to hodi chybu Trying to get property of non-object
pritom nabidka =

rows protected => array(2) ▼ {
     9 => Nette\Database\Table\ActiveRow(4) ▼ {
        table private => Nette\Database\Table\Selection(18) { *RECURSION* }
        data private => array(16) { ... }
        dataRefreshed private => TRUE
        modified private => array(1) { ... }
     }
     id => 12
  }
  data protected => array(1) ▼ {
     9 => Nette\Database\Table\ActiveRow(4) ▼ {
        table private => Nette\Database\Table\Selection(18) { *RECURSION* }
        data private => array(16) { ... }
        dataRefreshed private => TRUE
        modified private => array(1) { ... }
     }
  }

ale $temp se pak rovna FALSE. pritom FALSE to ma vratit jen kdyz to nema zadne ROWs.
Poradte mi prosim.

wallkysek
Člen | 52
+
0
-

Zeptám se tedy jinak, mám objekt Selection s jedním řádkem(zjištění pomocí count()), ale fetch/current/get(0) my stále vraci FALSE, proc? Vzdyt tam ten radek JE.

Dekuji

David Matějka
Moderator | 6445
+
0
-

nedelal jsi pred tim s tim selection neco? foreach, fetch..?

get(0) fungovat nemuze, to se pokusi provest dotaz s id=0. ale fetch() by fungoval melo

wallkysek
Člen | 52
+
0
-

projizdim to ve foreach abych jednotlive SELECTIONS priradil ke KLICUM v poli, a mam v tom foreach
$temp = $selection->fetch()
a pak neco ve stylu
$array[$temp->user->username] = $selection.
$this->selected = $array;

a nekde jinde potrebuju potom pouzit

$this->selected[$username]->fetch()

ale jakmile se v databazi objevi i druhy radek uz je vse v pohode.

Editoval wallkysek (12. 12. 2013 19:35)

romiix.org
Člen | 343
+
0
-

Celé je to nejaké divné.

$temp = $selection->fetch(); // $temp = $selection = ActiveRow
$array[$temp->user->username] = $selection; // $array[$temp->user->username] = ActiveRow
$this->selected = $array; // pole položiek typu ActiveRow
$this->selected[$username]->fetch() // voláš fetch() nad ActiveRow a nie nad Selection

Čo očakávaš od posledného riadka?

Nevyriešilo by tvoj problém použitie

$array = $table->fetchPairs($key, $value);

?

wallkysek
Člen | 52
+
0
-

takze neukladam do $temp activerow s nezmenenou promenou $selection? ucela ma byt takovy, ze $selection promenna se nezmeni, ale $temp bude typu active row.
navic potom bych nemogl volat fetch ani kdyby tam bylo vice radku nez jeden ne?

Editoval wallkysek (12. 12. 2013 19:57)

romiix.org
Člen | 343
+
0
-

Neviem ako je možné že ti to v prípade viacerých záznamov nepadá. Každopádne nad premennou inštancie Selection nemôžeš volať viac krát fetch(). V podstate by malo stačiť to druhé volanie vynechať.

wallkysek
Člen | 52
+
0
-

v $selection je toto:

Nette\Database\Table\Selection(18) ▼ {
   connection protected => Nette\Database\Connection(6) ▼ {
      dsn private => "mysql:host=127.0.0.1;dbname=dan_gumy" (36)
      driver private => Nette\Database\Drivers\MySqlDriver(1) ▼ {
         connection private => Nette\Database\Connection(6) { *RECURSION* }
      }
      preprocessor private => Nette\Database\SqlPreprocessor(6) ▼ {
         connection private => Nette\Database\Connection(6) { *RECURSION* }
         driver private => Nette\Database\Drivers\MySqlDriver(1) { ... }
         params private => array(1) [ ... ]
         remaining private => array(0)
         counter private => 1
         arrayMode private => "assoc" (5)
      }
      databaseReflection private => Nette\Database\Reflection\DiscoveredReflection(5) ▼ {
         cache protected => Nette\Caching\Cache(4) { ... }
         cacheStorage protected => Nette\Caching\Storages\FileStorage(4) { ... }
         connection protected => Nette\Database\Connection(6) { *RECURSION* }
         structure protected => array(3) { ... }
         loadedStructure protected => array(3) { ... }
      }
      cache private => Nette\Caching\Cache(4) ▼ {
         storage private => Nette\Caching\Storages\FileStorage(4) { ... }
         namespace private => "Nette.Database.729cb84920d5293def7d3689b0cbd6ea\x00" (48)
         key private => NULL
         data private => NULL
      }
      onQuery => array(1) ▼ [
         0 => array(2) [ ... ]
      ]
   }
   cache protected => Nette\Caching\Cache(4) ▼ {
      storage private => Nette\Caching\Storages\FileStorage(4) ▼ {
         dir private => "/srv/www/htdocs/DAN/Pneu/temp/cache" (35)
         useDirs private => TRUE
         journal private => Nette\Caching\Storages\FileJournal(9) { ... }
         locks private => NULL
      }
      namespace private => "Nette.Database.729cb84920d5293def7d3689b0cbd6ea\x00" (48)
      key private => NULL
      data private => NULL
   }
   sqlBuilder protected => Nette\Database\Table\SqlBuilder(14) ►
   name protected => "nabidky" (7)
   primary protected => "id" (2)
   primarySequence protected => FALSE
   rows protected => array(1) ▼ {
      10 => Nette\Database\Table\ActiveRow(4) ▼ {
         table private => Nette\Database\Table\Selection(18) { *RECURSION* }
         data private => array(11) { ... }
         dataRefreshed private => FALSE
         modified private => array(1) { ... }
      }
   }
   data protected => array(1) ▼ {
      10 => Nette\Database\Table\ActiveRow(4) ▼ {
         table private => Nette\Database\Table\Selection(18) { *RECURSION* }
         data private => array(11) { ... }
         dataRefreshed private => FALSE
         modified private => array(1) { ... }
      }
   }
   dataRefreshed protected => FALSE
   referenced protected => array(1) ▼ {
      "users.users_id" => Nette\Database\Table\Selection(18) ►
   }
   referencing protected => array(0)
   referencingPrototype protected => array(0)
   aggregation protected => array(0)
   accessedColumns protected => array(11) ►
   previousAccessedColumns protected => array(11) ►
   observeCache protected => Nette\Database\Table\Selection(18) { *RECURSION* }
   checkReferenced protected => FALSE
   keys protected => array(1) ▼ [
      0 => 10
   ]
}

a na to kdyz pouziju metodu fetch() tak mi to vrati false.

romiix.org
Člen | 343
+
0
-

Čo je v „sqlBuilder protected ⇒ Nette\Database\Table\SqlBuilder(14) ►“ ?

wallkysek
Člen | 52
+
0
-
sqlBuilder protected => Nette\Database\Table\SqlBuilder(14) ▼ {
   driver private => Nette\Database\Drivers\MySqlDriver(1) ►
   driverName private => "mysql" (5)
   tableName protected => "nabidky" (7)
   databaseReflection protected => Nette\Database\Reflection\DiscoveredReflection(5) ▼ {
      cache protected => Nette\Caching\Cache(4) { ... }
      cacheStorage protected => Nette\Caching\Storages\FileStorage(4) { ... }
      connection protected => Nette\Database\Connection(6) { ... }
      structure protected => array(3) { ... }
      loadedStructure protected => array(3) { ... }
   }
   delimitedTable protected => "`nabidky`" (9)
   select protected => array(0)
   where protected => array(1) ▼ [
      0 => "`users_id` = 13" (15)
   ]
   conditions protected => array(1) ▼ {
      257f7d9003ce49259ee1f38ea0c29f93 => "users_id = 13" (13)
   }
   parameters protected => array(0)
   order protected => array(1) ▼ [
      0 => "stav" (4)
   ]
   limit protected => NULL
   offset protected => NULL
   group protected => ""
   having protected => ""
}