php – PDO: Pass LAST_INSERT_ID from an INSERT method to another SELECT method

My intention is to insert a record at the same time and get its id (AUTO_INCREMENT) in order to use it as an FK to insert several records using it into another table. First, I want to make a selection, then create a third method with the second insert, but I need to know how to pass this ID from one method to the other.

// **
// INSERT

public service inserT () {
$ connection = new Connection ();
$ query = $ connection-> prepare (INSERT INTO & # 39; .self :: TABLE. & # 39; (store name) VALUES (: id_tipotienda,: tienda_number) & # 39;);
$ query-> bindParam (: store_name & # 39 ;, $ this-> store_name);
$ query-> execute ();
$ this-> id = $ connection-> lastInsertId ();

}

In the same class, I intend to use another method that collects the last inserted ID resulting from the lastInsertId

// **
// SELECT

public service selecT () {
$ connection = new connection ();
$ query = $ connection-> prepare ("SELECT * FROM". self :: TABLE. "where store_id =: store_id");
$ query-> execute (array (: id_store => LAST_INSERT_ID));
$ register = $ query-> fetch ();
if ($ record) {
return a new me ($ registration['tienda_nombre'], $ id_store);
} else {
returns false;
}
}    

What I will then take with another call from another file.
I need to know how to pass this identifier from one method to the other

php – How to pass a table to work in C ++

marked as pending as is not clear enough by Maniero 4 minutes ago

Clarify your specific problem or add other details to highlight exactly what you need. As it is written here, it is difficult to know exactly what you are asking for. Refer to the How to Ask Questions page for help clarifying this question. Learn the rules of the Help Center and modify the question so that it is appropriate.

How to pass 2 parameters via a link with html and php

then my doubt is as follows; I wish to transmit 2 parameters via a link, but I have doubts about it. Can someone explain me how I can achieve it? I'm going to give you an example.

<a href = "Shopping cart PT-BR.php? action = add & id ="class =" btn btn-danger ">    Buy now

This is the link I want to send 2 parameters, as you can only see one that is action = add & id =. I want to send another 1 which would be the idusuario, how can I do? obg of attention.

visas – To try to return with a tourist pass after being rejected

Has been refused to enter Singapore today. Need some advice on how to get back.

I was in Singapore for about 80 days with a tourist pass and then I went to Johor Bahru in Malaysia for about 5 days. I wanted to return to Singapore less than 90 days and I registered 90 days on my immigration card. At immigration to Woodlands, I was asked about what I was doing in Singapore, about the species I had, credit cards, and so on. I told them that I intended to stay at SG again to relax a sabbatical year. career break and I wanted to stay longer to consider moving there. Unfortunately, they said that I could not enter Singapore and that I had to return to Johor Bahru. They did not give me any particular reason and would not divulge.

I would like to return to Singapore soon and stay there for another two or three months before returning to the United States (and possibly applying to companies here). I've heard a lot of people do this for about 3 to 5 times, which has kind of surprised me because it's about my first back-to-school attempt, but I'm aware that all of this is left to the discretion of the immigration officer.

Am I having a bad luck? Is it possible for me to come back soon? Anything else I should try?

html – How to pass an arrangement of checkboxes with a specific class (assets) by Ajax to a PhP file

I work with a product catalog, what happens is that I need to collect paging and filtering to be dynamic (with Ajax).

So far, I managed to make the page dynamic is that my pagination file (which I call with Ajax) is where I tell you that the query is based on products in this category but I would obviously like to add it. the filters.

I have one side that is where all the input check boxes are generated, which already have a specific value (for the query) and all belong to the same array (name = subcategories).

What happens is that I've already added a javascript function that adds an asset class to all the checkboxes that have been enabled. That's why I want in the Ajax script data, I can send you the class checkbox table (filter only by the ones you clicked).

What I have already tried is to send a serialized array of all those with class = "active-checkbox" to Json, and in the php paging file to make a json_decode of the GET of this attribute I sent, but unfortunately it did not work well (no I know if I did it correctly).

Script and Ajax functions

getresult function (url, data) {
$ .ajax ({
url: url,
type: "GET",
data: {
rowcount: $ ("# rowcount"). val (),
"mobileSubCat": data,
"pagination_setting": $ ("# pagination-setting"). val (),
"subcategories": JSON.stringify ($ (& # 39;[class="active-checkbox"]& # 39;) .serializeArray ())
}
beforeSend: function () {
$ ("#imposition"). show ();
}
success: function (data) {
$ ("# pagination-result"). html (data);
$ ("#imposition"). hide ();
}
error: function () {}
});
}

changePagination function (option) {
if (option! = "") {
getresult ("catalog / getResult.php ");
}
}

$ (& # 39 ;. selectSubCat & # 39;). change (function () {
var data = $ (this) .val ();
getresult ("catalog / getResult.php ", data);
});

checkCheckBox function (element) {
var isChecked = element.checked;
if (is checked) {
element.classList.add (& # 39; checkbox);
} else {
element.classList.remove (& # 39; check box active & # 39;);
}
// We call Ajax to update with the new selection
var data = & # 39;
getresult ("catalog / getResult.php ", data);
}

PhP search code

= 1) {
echo "Enter if 1";
}
}

if (isset ($ _GET["subcategorias"])) {
if (is_array (json_decode ($ _ POST["subcategorias"], TRUE)) {
$ selected = & # 39;
$ num_subcategories = count ($ _ POST["subcategorias"])
$ current = 0;
foreach ($ _POST["subcategorias"] like $ key => $ value) {
if ($ current! = $ num_countries-1)
$ selected. = $ value. & # 39; & # 39 ;;
d & # 39; other
$ selected. = $ value. & # 39;. & # 39 ;;
$ current ++;
}
}
if not {
$ selected = & # 39; You have not selected any subcategories & # 39 ;;
}
}

$ pag_category_id = $ _SESSION["id_categoria"];
$ sql = "SELECT * from ws_product where category_id = & # 39 ;. $ pag_category_id. & # 39; and status_product = 1";

$ page = 1;
if (! empty ($ _GET["page"])) {
$ page = $ _GET["page"];
}

$ start = ($ page-1) * $ perPage-> per page;
if ($ start < 0){
        $start = 0;   
    }

    $query =  $sql . " limit " . $start . "," . $perPage->per page;
$ faq = $ db_handle-> runQuery ($ query);

if (empty ($ _GET["rowcount"])) {
$ _GET["rowcount"] = $ db_handle-> numRows ($ sql);
}

if ($ pagination_setting == "prev-next") {
$ perpageresult = $ perPage-> getPrevNext ($ _GET["rowcount"], $ paginationlink, $ pagination_setting);
} else {
$ perpageresult = $ perPage-> getAllPageLinks ($ _GET["rowcount"], $ paginationlink, $ pagination_setting);
}

$ output = & # 39;

if (is_array ($ faq) || is_object ($ faq)) {
foreach ($ faq as $ k => $ v) {
$ query = $ galleries-> table_view ($ db_handle-> connectDB (), $ faq[$k]["id_producto"])
$ var = mysqli_fetch_array ($ query);

$ output. = & # 39;
Representative product image

& # 39; .utf8_encode ($ faq[$k]["nombre_producto"]). & # 39;

& # 39; .utf8_encode ($ faq[$k]["descripcion_producto"]). & # 39;

& # 39 ;; } } if (! empty ($ perpageresult)) { $ output. = & # 39;
& # 39 ;; } print $ output; ?>

The current status of the site can be viewed at the following address: https://demos.posicionart.com/silleri/catalogo/mesas-y-escritorios.php

How to pass parameters to the endpoint 'Services & # 39; in drupal7

I have installed Drupal 7 and enabled the services it contains. I've also created an endpoint / api / v2 / and in the resources, I allowed the nodes to be listed as JSON.

I sent a GET request using browser or POSTMAN to / api / v2 / node then I get the following results.

 [
 {
 nid: "3143",
 vid: "3932",
 type: "event_calendar",
 language: "en",
 title: "EVENTS STILL APPEAR ON FRONT PAGE WHEN EVENT HAS ENDED - with or w     ithout an END DATE ",
 uid: "139",
 status: "1",
 created: "1560282811",
 changed: "1560282922",
 comment: "1",
 promote: "0",
 sticky: "0",
 tnid: "0",
 translate: "0",
 uuid: "",
 uri: "http://..../api/v2/node/3143"
 },
...
 ]`

If I send a request to http: //..../api/v2/node/[nid] then I get an individual record of this node.
Now, I want to get publishing settings on the endpoint. For example, I want to get all nodes with type = event_calendar.

I've tried to post parameters like http: //..../api/v2/node? type = calendar_events but unfortunately, it always displays the list of all the nodes. I've tried something using POSTMAN and the browser.

python – pass the input data to the mysql database table

Galera help me out there, I create a user manager with a system of levels.
but I am not able to pass a value of the variable defined by Entrance () for the INSERT.
help me please.

code

def register_user ():
print ("id:")
id_bd = input ()

print ("level:")
level_bd = input ()

print ("user:")
user_bd = input ()

print ("password:")
dbpassword = entry ()

(% s,% s,% s) (db_id, level_bd, db_user, db_password) "=" username "," username "," username "
bank_of_data.execute (create_users)

network – hosts file: does it pass the domain name? I am always redirected to the main site configured on the host

My IP address of the server is 123.456.789.123.

Pointing my browser on 123.456.789.123 (http://123.456.789.123) the server serves me as a site alpha.

Now I've set up a second site: beta.

Site beta is still online from my old IP server 321987654321.

So, to reinstall and reconfigure it on the new server, I edited my hosts drop this way, so he calls the new server when I go to the domain beta.com:

##
# Host database
#
# localhost is used to configure the loopback interface
# when the system starts. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
:: 1 localhost
123.456.789.123 beta.com www.beta.com

The problem is that when I point my browser to http://www.beta.com, I see alpha.com, the same site that I see if I go to http://123.456.789.123.

Sure 123.456.789.123I have two different vhosts file: one for alpha and one for beta.

They are like this:


    
    
    
    # The ServerName directive defines the query schema, hostname, and port that
# the server uses to identify itself. This is used during creation
# Redirect URL. In the context of virtual hosts, the ServerName
# specifies the host name that should appear in the Host header: of the request
# corresponds to this virtual host. For the default virtual host (this file), this
The # value is not critical because it is used at all times as a last resort host.
# However, you must explicitly set it for any other virtual host.
Alpha.com_server_name
ServerAlias ​​www.alpha.com

ServerAdmin my.email@gmail.com
DocumentRoot /var/www/alpha.com/public_html

# Available connection levels: trace8, ..., trace1, debug, info, notification, warn,
# error, crit, alert, emergent.
# It is also possible to configure the logging level for
# modules, for example
#LogLevel info ssl: warn

ErrorLog /var/www/alpha.com/log/error.log
Combined CustomLog /var/www/alpha.com/log/access.log

# For most conf-available / configuration files, which are
# enabled or disabled globally, it is possible to
# include a line for a single virtual host. For example,
The following line enables CGI configuration for this host only
# after being globally disabled with "a2disconf".
#Include conf-available / serve-cgi-bin.conf

# This will allow the use of .htaccess files to configure a single folder
    
        AllowOverride All
    

Ideas on how can I see the site beta?
It seems that the hosts the file simply calls 123.456.789.123, but without passing the domain that I ask and the server responds by this one by default and not by the site that I ask: beta.com.

c – How to pass values ​​in the shell program?

To pass data to your program via the command line, you will need to use arguments argc(Number of arguments) and argv(Vector argument).

Argc is responsible for counting the arguments passed by the command line.

Argv is an array of pointers containing all the arguments passed.

By default, an argument is always passed, which is the name of the executed program. These arguments must be present in the main call.

#include 

main int (int argc, char * argv[])
{
int counter;
// first argument the name
printf ("Program name:% s", argv[0])

// if you added an argument, it means that it was not passed
// setting
if (argc == 1)
printf (" nNo past argument");

if (argc> = 2)
{
printf (" nNumber of past arguments:% d", argc);
printf (" n  n  n ");
for (counter = 0; counter <argc; counter ++)
printf (" nargv[%d]:% s ", counter, argv[counter])
} 

session – How to pass information from one page to another with php $ _SESSION[]

I have this table that shows all registered users:

ID name Last name E-mail Password Birth date Country Date of registration operations
Edit Remove

The table is loaded by this php file:
listUsers.php

    0) {

$ users = array ();

while ($ row = $ result-> fetch_assoc ()) {
array_push ($ users, $ row);
}


// foreach ($ users as $ user) {
// echo $ user['id'] . "
"; // echo $ user['nombre'] . "
"; // echo $ user['apellidos'] . "
"; // echo $ user['email'] . "
"; // echo $ user['password'] . "
"; // echo $ user['fecha_registro'] . "
"; // echo $ user['fecha_nacimiento'] . "
"; //} } ?>

Then I have this other file sessions.php to manage sessions:


What I want is that when I click on Upgrade in the table list-php I want to keep the identifier in a session to be able to use it, but I do not know how I could do it from that store in the session this: $ _SESSION['id'] and finally redirect me to the file save.php act as follows:

If there is session $ _SESSION['id'] save.php what will be done UPDATE to load the entries corresponding to the BD in advance and if NO there is the session $ _SESSION['id'] Then treat it as a normal, up-to-date record. Then I leave my file save.php:




    
    Register users
    





    

    

Save the user

And the file.php associated with this view is: saveUser.php


So, to summarize a bit, what I want is that in the table list.php if you click to edit or delete what is going on one way or another, the user ID will do what you want. Basically, we pass the id from one side to the other, of course.