PHP code example of cerki / simple_prestashop_persistence
1. Go to this page and download the library: Download cerki/simple_prestashop_persistence library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cerki / simple_prestashop_persistence example snippets
php
use SimpleTables\Db\PrestaTable;
class MyExampleTable extends PrestaTable{
function getTableName(){
return "mytablename";
}
function getTableColumns(){
return [
"id" => "INTEGER NOT NULL PRIMARY KEY",
"myfield1" => "VARCHAR(255)",
"myfield2" => "INTEGER NOT NULL"
];
}
}
function my_function(){
$mytable = new MyExampleTable(); // NOTE you should have prestashop Db class loaded
// so either do it in module/controller or import config.inc.php
$mytable->saveExistingColumns([
"myfield1" => "somedata1"
"myfield2" => 2
]);
$mytable->getBy(["myfield1" => "somedata1"]
// ["myfield2" => "ASC"] second argument - sorting
); // should return [["id" => 1,"myfield1" => "somedata1","myfield2"=>"somedata2"]]
}
php
function updateTableWithColumns($columns);
function dropTable();
function deleteBy($data); // Similar to getBy
function getBy($data,$order=NULL);
function saveExistingColumns($assoc_array); // NOTE saves a new instance if primary key is not
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.