ziedinjsh Posted March 22, 2015 Report Share Posted March 22, 2015 Sveiki, nesaprotu ko daru nepareizi, pec pamācības no šīs lapas bet neiet! session_start(); require_once '../../vendor/autoload.php'; require_once '../../private/db_config.php'; $uid = $_SESSION['uid']; $user = ORM::for_table('users')->find_one($uid); $user->username = $_POST['username']; $user->location = $_POST['location']; $user->email = $_POST['email']; $user->gender = $_POST['gender']; $user->save(); Pēc formas submitošanas man atgriež:Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'' in D:\Server\xampp\htdocs\vendor\j4mie\idiorm\idiorm.php:429 Stack trace: #0 D:\Server\xampp\htdocs\vendor\j4mie\idiorm\idiorm.php(429): PDOStatement->execute() #1 D:\Server\xampp\htdocs\vendor\j4mie\idiorm\idiorm.php(1828): ORM::_execute('SELECT * FROM `...', Array, 'default') #2 D:\Server\xampp\htdocs\vendor\j4mie\idiorm\idiorm.php(607): ORM->_run() #3 D:\Server\xampp\htdocs\public\process\updateProfile.php(13): ORM->find_one('3') #4 {main} thrown in D:\Server\xampp\htdocs\vendor\j4mie\idiorm\idiorm.php on line 429Es tikai nesaprotu kur viņam ir unknown column id, jo lietotāja id viņš atpazīst find_one(3); Quote Link to comment Share on other sites More sharing options...
F3llony Posted March 22, 2015 Report Share Posted March 22, 2015 Tu lasīt proti? Column not found: 1054 Unknown column 'id' Tev priekšā pasaka, nav datubāzē tev kolonnas `id`. Viss. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted March 22, 2015 Author Report Share Posted March 22, 2015 Jā, jo man ir uid (user id) Quote Link to comment Share on other sites More sharing options...
waplet Posted March 22, 2015 Report Share Posted March 22, 2015 (edited) Izskatās, ka ja "findOne" funkcijai nepadod string'u, tad kā arguments tiek ņemts skaitlis un tiek izpildīts WHERE condition's "WHERE id = $uid". Attiecīgi jāpaskatās dokumentācija kā būtu jābūt, lai "findOne" strādātu pēc tavas "u_id" kolonnas, nevis "id". Iespēhans "->findOne('uid = '. $uid)" vai tml. Edited March 22, 2015 by waplet Quote Link to comment Share on other sites More sharing options...
Kasspars Posted March 22, 2015 Report Share Posted March 22, 2015 (edited) Pēc loģikas, ja tas ir ORM, tad skaties tabulas klasē, tur jābūt iespējai nodefinēt id (primary_key) lauka vārdu Edited March 22, 2015 by Kasspars Quote Link to comment Share on other sites More sharing options...
codez Posted March 22, 2015 Report Share Posted March 22, 2015 Kāpēc likt uid, ja tabula jau ir users? Sanāk to id divreiz apzīmēt kā "userim" piederošu, vienreiz ar tabulas nosaukumu, otrreiz ar kolonnas nosaukumu. Quote Link to comment Share on other sites More sharing options...
F3llony Posted March 22, 2015 Report Share Posted March 22, 2015 Jā, jo man ir uid (user id) Un Idiorm pamatā neinteresē, kas tev ir, Idiorm par ID uzskata ID. Kā tu domā, ar kādas maģijas palīdzību tagad libam vajadzētu uzminēt, ka tu kā ID izmanto citādi nosauktu kolonnu? Plus vēl, viedoklis, kā bonusam - id kolonna ir jāsauc id. Ne uid, šmuid, druid, fagid, bet id. Perpetrators should be shot on sight. Quote Link to comment Share on other sites More sharing options...
Kemito Posted March 22, 2015 Report Share Posted March 22, 2015 (edited) $user = ORM::for_table('users')->where('uid', $uid)->find_one(); Edited March 22, 2015 by Kemito Quote Link to comment Share on other sites More sharing options...
qwerty Posted March 23, 2015 Report Share Posted March 23, 2015 Apsveicu ka esi pārgājis no wild sql muļķībām iepriekšējos postos uz ORM, bet ja tu kaut ko tādu lieto, tad tomēr ir jāmāk arī lasīt doķi. Re kur links. idiormam ir "viedoklis" (opinionated software) ka identifikators ir jāsauc par `id`. Ja tu domā citādi, tad doķos paskaidrots kā to izmainīt. https://idiorm.readthedocs.org/en/latest/configuration.html#id-column Quote Link to comment Share on other sites More sharing options...
Kasspars Posted March 23, 2015 Report Share Posted March 23, 2015 ORM::configure('id_column', 'uid'); Quote Link to comment Share on other sites More sharing options...
Kavacky Posted March 23, 2015 Report Share Posted March 23, 2015 druidKad pirmo reizi ieraudzīju šādu kolonnas nosaukumu, gaidīju, ka vērtības būs 0/1. :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.