I make a request from JS like:
$.post("<?php echo ossn_site_url("action/optiontrips/getmaptrips", true); ?>", function(trips){
Server:
public function getMapTrips() {
if(empty($this->entity_guid)) {
return false;
}
$params = array();
$params['from'] = 'ossn_trips';
$params['params'] = array(
"e.guid ='{$this->entity_guid}'"
);
$data = $this->select($params);
if($data) {
$entity = arrayObject($data, get_class($this));
return $entity;
}
return $this->select($params, true);
But return "false" from 3rd line
Can you help me?
Many thanks
You're the best!!
I will make a new git push ;)
Thanksss a lot
The code you posted is wrong, the correct one is :
public function getMapTrips() {
$user = ossn_loggedin_user()->guid;
if(empty($user)) {
return false;
}
$params = array();
$params["from"] = "ossn_trips";
$params["wheres"] = array(
"guid='{$user}'"
);
return $this->select($params, true);
}
The diference is it only the name of the column in db?
I try with "guid" but i can get it $user = ossnloggedinuser()->guid;
public function getMapTrips() {
$user = ossn_loggedin_user()->guid; //This is working
//if(empty($this->entity_guid)) {
if(empty($user)) { //This is working
return false;
}
$params = array();
$params['from'] = 'ossn_trips';
$params['params'] = array(
//"guid ='{$this->entity_guid}'"
"guid ='{$user}'" //This is working
);
$data = $this->select($params);
if($data) {
$entity = arrayObject($data, get_class($this));
return $entity;
}
return $this->select($params, true);
Now only have a problem, only return 1 object no 4!!??
There is no e.guid in your table, it should be guid
$params["params"] = array(
"guid ="{$this->entity_guid}""
);
CREATE TABLE IF NOT EXISTS ossn_trips
(
id_trip
int(11) NOT NULL AUTOINCREMENT,
guid
int(11) NOT NULL,
title
text COLLATE utf8spanishci NOT NULL,
description
text COLLATE utf8spanishci NOT NULL,
longitude
float(10,6) NOT NULL,
latitude
float(10,6) NOT NULL,
PRIMARY KEY (id_trip
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8spanishci AUTOINCREMENT=5 ;
INSERT INTO ossn_trips
(id_trip
, guid
, title
, description
, longitude
, latitude
) VALUES
(1, 1, 'First trip to San Francisco', 'Few days in San Francisco City', 37.774929, -122.419418),
(2, 1, 'Visit to GooglePlex in Mountain View', 'Summit with others Google top contributors and communiy managers.', 37.386051, -122.083855),
(3, 1, 'First trip by bus to Rome in Italy', 'A week with friends', 53.349804, -6.260310),
(4, 1, 'Visit Google Dublín', 'Only 4 days in Dublin, nice experience.', 41.902782, 12.496366);
Thanks Again
Why do you need entity_guid in your custom table? if you shows us table structure we might can help you.
Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.
$199 (Life Time)