[SOLVED] Form Detail Tempate | Update query | Get id of dropdown database join element + Solution

That should work.

Try var_dump()'ing the $query before you execute it, see what the query winds up being.

-- hugh
 
That should work.

Try var_dump()'ing the $query before you execute it, see what the query winds up being.

-- hugh

Hi Hugh,

I tried again your code (see 8#), which I have already dumped :

Code:
$blocationcrew = $data['fab_booking___boarding_location_crew_raw'];
$blocationcrew = is_array($blocationcrew) ? $blocationcrew[0] : $blocationcrew;
var_dump($blocationcrew);exit;

Result is : string(1) "b"


See video : http://www.screencast.com/t/myhka4YmoZLo

var_dump of the query :

Code:
object(JDatabaseDriverMysqli)#15 (23) { ["name"]=> string(6) "mysqli" ["serverType"]=> string(5) "mysql" ["connection"protected]=> object(mysqli)#16 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $" ["client_version"]=> int(50011) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(17) "sql175 via TCP/IP" ["info"]=> string(40) "Rows matched: 1 Changed: 0 Warnings: 0" ["insert_id"]=> int(0) ["server_info"]=> string(30) "5.5.5-10.0.25-MariaDB-1~jessie" ["server_version"]=> int(50505) ["stat"]=> string(144) "Uptime: 1202263 Threads: 2 Questions: 1578481 Slow queries: 1 Opens: 18537 Flush tables: 1 Open tables: 400 Queries per second avg: 1.312" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(59512) ["warning_count"]=> int(0) } ["nameQuote"protected]=> string(1) "`" ["nullDate"protected]=> string(19) "0000-00-00 00:00:00" ["_database":"JDatabaseDriver"private]=> string(22) "webamazingapps_neptune" ["count"protected]=> int(35) ["cursor"protected]=> bool(true) ["debug"protected]=> bool(false) ["limit"protected]=> int(0) ["log"protected]=> array(0) { } ["timings"protected]=> array(0) { } ["callStacks"protected]=> array(0) { } ["offset"protected]=> int(0) ["options"protected]=> array(9) { ["driver"]=> string(6) "mysqli" ["host"]=> string(6) "sql175" ["user"]=> string(14) "webamazingapps" ["password"]=> string(10) "q4nhv.+0NQ" ["database"]=> string(22) "webamazingapps_neptune" ["prefix"]=> string(4) "nep_" ["select"]=> bool(true) ["port"]=> int(3306) ["socket"]=> NULL } ["sql"protected]=> string(197) "UPDATE fab_booking LEFT JOIN fab_boarding_location_crew ON fab_booking.boarding_location_crew = fab_boarding_location_crew.id SET fab_booking.boarding_location_crew = 'b' WHERE fab_booking.id ='36'" ["tablePrefix"protected]=> string(4) "nep_" ["utf"protected]=> bool(true) ["utf8mb4"protected]=> bool(true) ["errorNum"protected]=> int(0) ["errorMsg"protected]=> string(0) "" ["transactionDepth"protected]=> int(0) ["disconnectHandlers"protected]=> array(0) { } }

show that the value returned is "b" in "SET fab_booking.boarding_location_crew = 'b'".



The only code which returns an array is :

Code:
$blocationcrew = $data['fab_booking___boarding_location_crew_raw'];
var_dump($blocationcrew);exit;

Result is : array(1) { [0]=> string(1) "1" }

See video : http://www.screencast.com/t/UaFfW03DmxNo

But the var_dump of the query :

Code:
object(JDatabaseDriverMysqli)#15 (23) { ["name"]=> string(6) "mysqli" ["serverType"]=> string(5) "mysql" ["connection":protected]=> object(mysqli)#16 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $" ["client_version"]=> int(50011) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(17) "sql175 via TCP/IP" ["info"]=> string(40) "Rows matched: 1 Changed: 0 Warnings: 0" ["insert_id"]=> int(0) ["server_info"]=> string(30) "5.5.5-10.0.25-MariaDB-1~jessie" ["server_version"]=> int(50505) ["stat"]=> string(144) "Uptime: 1202385 Threads: 2 Questions: 1579315 Slow queries: 1 Opens: 18537 Flush tables: 1 Open tables: 400 Queries per second avg: 1.313" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(59532) ["warning_count"]=> int(0) } ["nameQuote":protected]=> string(1) "`" ["nullDate":protected]=> string(19) "0000-00-00 00:00:00" ["_database":"JDatabaseDriver":private]=> string(22) "webamazingapps_neptune" ["count":protected]=> int(34) ["cursor":protected]=> bool(true) ["debug":protected]=> bool(false) ["limit":protected]=> int(0) ["log":protected]=> array(0) { } ["timings":protected]=> array(0) { } ["callStacks":protected]=> array(0) { } ["offset":protected]=> int(0) ["options":protected]=> array(9) { ["driver"]=> string(6) "mysqli" ["host"]=> string(6) "sql175" ["user"]=> string(14) "webamazingapps" ["password"]=> string(10) "q4nhv.+0NQ" ["database"]=> string(22) "webamazingapps_neptune" ["prefix"]=> string(4) "nep_" ["select"]=> bool(true) ["port"]=> int(3306) ["socket"]=> NULL } ["sql":protected]=> string(201) "UPDATE fab_booking LEFT JOIN fab_boarding_location_crew ON fab_booking.boarding_location_crew = fab_boarding_location_crew.id SET fab_booking.boarding_location_crew = 'Array' WHERE fab_booking.id ='36'" ["tablePrefix":protected]=> string(4) "nep_" ["utf":protected]=> bool(true) ["utf8mb4":protected]=> bool(true) ["errorNum":protected]=> int(0) ["errorMsg":protected]=> string(0) "" ["transactionDepth":protected]=> int(0) ["disconnectHandlers":protected]=> array(0) { } }

show that the value returned is "Array" in "SET fab_booking.boarding_location_crew = 'Array'".

What can we do here ? I certainly missed something ?

Thank you in advance for your support, cheers, marc
 
Last edited:
I've done everything I can to help out with this through normal support. The only avenue left is for me to do the coding for you, as a custom task on an hourly rate.

-- hugh
 
Hi Hugh,

I found the error :

Code:
$llocationcrew = is_array($llocationcrew) ? llocationcrew[0] : $llocationcrew;

I 've made a syntax error, I forgot the '$' in 'llocationcrew[0]'.

Code:
$llocationcrew = is_array($llocationcrew) ? $llocationcrew[0] : $llocationcrew;

Of course your solution was the solution ! Everything works fine now. Values are updated in the database.

Apologize, I oversaw this during days... And thank you for your patience.

Cheers,

Marc

Solution

Code:
// Crew boarding location
$blocationcrew=$this->data['fab_booking___boarding_location_crew_raw'];
$blocationcrew = is_array($blocationcrew) ? $blocationcrew[0] : $blocationcrew;
// var_dump($blocationcrew);exit;

// Crew landing location
$llocationcrew=$this->data['fab_booking___landing_location_crew_raw'];
$llocationcrew = is_array($llocationcrew) ? $llocationcrew[0] : $llocationcrew;

Code:
// Update crew boarding location
$query = $db->getQuery(true);
$query = "UPDATE fab_booking LEFT JOIN fab_boarding_location_crew ON fab_booking.boarding_location_crew = fab_boarding_location_crew.id SET fab_booking.boarding_location_crew = '$blocationcrew' WHERE fab_booking.id ='$bookingid'";
$db->setQuery($query);
$boardinglocationcrew = $db->execute();

// Update crew landing location
$query = $db->getQuery(true);
$query = "UPDATE fab_booking LEFT JOIN fab_landing_location_crew ON fab_booking.landing_location_crew = fab_landing_location_crew.id SET fab_booking.landing_location_crew = '$llocationcrew' WHERE fab_booking.id = '$bookingid'";
$db->setQuery($query);
$landinglocationcrew = $db->execute();
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top