I make this associative array with PHP. $colors = [‘a’ => ‘red’, ‘b’ => ‘green’, ‘c’ => ‘blue’, ‘d’ => ‘yellow’, ‘e’ => ‘pink’]; Now by using array_rand() function => $newArray = array_rand($colors, 2); The Output is: [0] => a [1] => b This output shows me only the key of the array. But I ..

Read more

I’m programming a small CRUD interface with js, PHP and MYSQL. To avoid SQL injection, my javascript is separately POSTing a prepared SQL statement form._source and an array containing the parameters form._param _post = {action:’read’, source:form._source}; if (form._param !== null) _post[‘param’]=form._param; $.post("/ajax/crud.php",_post, function(result){ if (!result.error) { form._record = result.data; form._totrec = result.data.length; form.gotoRecord(setrec); } else ..

Read more

I have a script (working) for a prestashop 1.7 to add product in my db require_once(‘config/config.inc.php’); require_once(‘init.php’); $default_lang = Configuration::get("PS_LANG_DEFAULT"); $product = new Product(); $product->name = [$default_lang => "Acquisto cumulativo diretta online"]; $product->link_rewrite = "acquisto_online"; $product->price = 95.90; $product->quantity = 10; $product->id_category = [10]; $product->id_category_default = 10; $bool = $product->add(); if ($bool) { $product->updateCategories($product->id_category); StockAvailable::setQuantity((int)$product->id, ..

Read more

I am using PHP and PDO to read a large amount of data from SQL Server database and write to MySQL. The process is like this: $sqlsrv_pdo = new PDO("sqlsrv:…",…); $select_sql = ‘SELECT a,b,c FROM sqlsrv_mytable’; $rows = $sqlsrv_pdo->prepare($select_sql)->execute(); //required row processing $mysql_pdo = new PDO("mysql:…",…); $insert_sql = ‘INSERT INTO mysql_mytable (a,b,c) VALUES ‘; $insert_values ..

Read more