Set local timezone in wordpress programatically:
Happy coding!
Set local timezone in wordpress programatically:
Happy coding!
Get completed orders count for a specific user with a specific product in Woocommerce:
Code:
Happy coding...
Laravel - raw query with pagination:
class InventoryController extends Controller
{
public function index(Request $request)
{
$sql = "SELECT *,products.name as product_name, product_categories.name as category_name, products.id as productid,
( SELECT SUM(buy_products.qty) as purcahse_qty
FROM buy_products
WHERE buy_products.product_id=products.id GROUP BY buy_products.product_id ) as bqty,
( SELECT SUM(sell_products.qty) as order_qty
FROM sell_products
WHERE sell_products.product_id=products.id GROUP BY sell_products.product_id ) as sqty
FROM products LEFT JOIN product_categories ON products.product_category_id=product_categories.id
";
$results = DB::select($sql);
$productInventoryData = $this->arrayPaginator($results, $request);
return view('auth.inventory.inventory_list')->with('productInventoryData', $productInventoryData);
}
public function arrayPaginator($array, $request)
{
$page = is_null($request->get('page')) ? 1 : $request->get('page');
$perPage = 2;
$offset = ($page * $perPage) - $perPage;
return new LengthAwarePaginator(array_slice($array, $offset, $perPage, true), count($array), $perPage, $page,
['path' => $request->url(), 'query' => $request->query()]);
}
}
And in views you can use links as like DB query build we use.
Thanks and happy coding.
Fix Mysql crash in XAMPP:
1. Go to xampp -> mysql folder
2. Copy data folder and paste and rename it to data_old
3. Go to data folder, and delete these 4 folders: mysql, performance_schema, phpmyadmin and test. Then delete all the files except ibdata1
4. Copy all files from mysql/backup folder, except ibdata1
5. Paste them to data folder
Start your Mysql server in Xampp.
YOU ARE DONE! 👏
Since this morning I get this below error:
Warning: mysqli_query(): (HY000/1194): Table 'wp_postmeta' is marked as crashed and should be repaired in C:\xampp\htdocs\wp_project\wp-includes\wp-db.php on line 2056
After that I logged into mysql terminal:
mysql -uroot -p
Then select database:
use wp_project
Then run the below command to fix the target table:
REPAIR TABLE wp_project.wp_postmeta;
And it solves the issue 👍
Create Laravel project with a specific Laravel version:
composer create-project laravel/laravel=8.* your-project-name --prefer-dist
Here put your version number laravel/laravel=HERE.
Wordpress error log code: if ( ! function_exists ( 'write_log' ) ) { function write_log ( $data ) { if ( defined ( '...