$stmt->bind_result($hash, $name, $target);
        if ($stmt->fetch()) {
            $arr = array('url' => $target, 'hex' => $hash, 'str' => $name);
        }
        $stmt->close();
        return $arr;
    }
    /**
      This is the entry point method of ShortLink.
      It is called at the bottom of this file,
      but will exit asap if ShortLink required POST parameters are missing.
    */
    public static function handlePost()
    {
        if (!array_key_exists('createShortLink', $_POST)) {
            return;
        }
        //Creating ShortLink:
        $arr = self::insert($_POST['createShortLink']);
        //Making sure $arr is an array:
        if ($arr instanceof Exception) {
            $arr = array('error' => $arr->getMessage());
        }
        //Producing output:
        Config::setResponseJSON();
        echo Config::toJSON($arr);
    }
}
//Calling handlePost:
ShortLink::handlePost();
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      ShortLink $value A ShortLink object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(ShortLink $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
示例#3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      ShortLink $value A ShortLink object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(ShortLink $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('ShortLinkPeer');
         }
     }
 }