<?php

/**
 * inoERP
 *
 * @copyright   2014 Nishit R. Das
 * @license     https://www.mozilla.org/MPL/2.0/
 * @link        http://inoideas.org
 * @source code https://github.com/inoerp/inoERP
 */

/**
 * 
 *
 */
class ext_url_alias extends dbObject {

 public static $table_name = "ext_url_alias";
 public static $primary_column = "ext_url_alias_id";
 public static $key_column = 'alias';
 public static $module = "ext";
 public static $system_info = [
    'name' => 'URL Alias',
    'number' => '10032',
    'description' => 'View & Update URL Aliases',
    'version' => '0.1.1',
    'db_version' => '1001',
    'mod_version' => '1.1.1',
    'primary_entity_cb' => '',
    'module_name' => 'extn',
    'weight' => 32
 ];
 public $field_a = [
    "ext_url_alias_id",
    "original_url",
    'content_id',
    "alias",
    "created_by",
    "creation_date",
    "last_update_by",
    "last_update_date"
 ];
 public $initial_search = [
    "ext_url_alias_id",
    "original_url",
    "alias",
 ];
 public $column = [
    "ext_url_alias_id",
    "original_url",
    "alias",
 ];
 public $requiredField = [
    'content_id',
    "original_url",
    "alias",
 ];
 public $search = [
    '_show_update_path' => 1,
    '_show_view_path' => 1,
 ];
 public $pageTitle = " URL Alias"; //page Title
 public $ext_url_alias_id;
 public $original_url;
 public $alias;
 public $content_id;
 public $created_by;
 public $creation_date;
 public $last_update_by;
 public $last_update_date;

 public function findBy_urlAlias() {
  $sql = " SELECT * FROM ";
  $sql .= self::$table_name;
  $sql .= " WHERE alias = :alias";
  $value_a = ['alias' => $this->alias];

  $result = $this->findBySql($sql, $value_a);
  return !empty($result) ? array_pop($result) : false;
 }

 public function findBy_originalUrl() {
  $sql = " SELECT * FROM ";
  $sql .= self::$table_name;
  $sql .= " WHERE alias = :original_url";
  $value_a = ['original_url' => $this->original_url];

  $result = $this->findBySql($sql, $value_a);
  return !empty($result) ? array_pop($result) : false;
 }

 public static function find_by_urlAlias($alias) {
  $sql = " SELECT * FROM ";
  $sql .= self::$table_name;
  $sql .= " WHERE alias = :alias ";

  global $db;
  $value_a = ['alias' => $alias];
  $result = $db->findBySql($sql, $value_a);

  return !empty($result) ? array_pop($result) : false;
 }

 public static function find_by_contentId($contentId) {
  $sql = " SELECT * FROM ";
  $sql .= self::$table_name;
  $sql .= " WHERE content_id = :content_id ";

  global $db;
  $value_a = ['content_id' => $contentId];
  $result = $db->findBySql($sql, $value_a);

  return !empty($result) ? array_pop($result) : false;
 }

 public static function find_by_originalUrl($original_url) {
  $sql = " SELECT * FROM ";
  $sql .= self::$table_name;
  $sql .= " WHERE original_url = :original_url ";

  global $db;
  $value_a = ['original_url' => $original_url];
  $result = $db->findBySql($sql, $value_a);

  return !empty($result) ? array_pop($result) : false;
 }

}

//end of path class
?>