nusoap wsdl connection error but in telnet test everything is OK - php

I use nusoap to connect to an URL,
But I cannot connect and I didn't get any error in $soapclient->getError() .
I can connect to that URL via SSH commant and telnet, that URL show an XML data on browser and everything seems to be OK but PHP cannot connect!
I think I have problem in php.ini configuration !
can you help me to solve this problem ?
when I trying to echo $soapclient; I get content :
object(nusoap_client)#25 (50) {
["username"]=>
string(0) ""
["password"]=>
string(0) ""
["authtype"]=>
string(0) ""
["certRequest"]=>
array(0) {
}
["requestHeaders"]=>
bool(false)
["responseHeaders"]=>
string(0) ""
["responseHeader"]=>
NULL
["document"]=>
string(0) ""
["endpoint"]=>
string(60) "https://******?wsdl"
["forceEndpoint"]=>
string(0) ""
["proxyhost"]=>
bool(false)
["proxyport"]=>
bool(false)
["proxyusername"]=>
bool(false)
["proxypassword"]=>
bool(false)
["portName"]=>
string(0) ""
["xml_encoding"]=>
string(0) ""
["http_encoding"]=>
bool(false)
["timeout"]=>
int(0)
["response_timeout"]=>
int(30)
["endpointType"]=>
string(4) "wsdl"
["persistentConnection"]=>
bool(false)
["defaultRpcParams"]=>
bool(false)
["request"]=>
string(0) ""
["response"]=>
string(0) ""
["responseData"]=>
string(0) ""
["cookies"]=>
array(0) {
}
["decode_utf8"]=>
bool(true)
["operations"]=>
array(0) {
}
["curl_options"]=>
array(0) {
}
["bindingType"]=>
string(0) ""
["use_curl"]=>
bool(false)
["fault"]=>
NULL
["faultcode"]=>
NULL
["faultstring"]=>
NULL
["faultdetail"]=>
NULL
["title"]=>
string(6) "NuSOAP"
["version"]=>
string(5) "0.9.5"
["revision"]=>
string(18) "$Revision: 1.123 $"
["error_str"]=>
string(0) ""
["debug_str"]=>
string(311) "2013-05-13 10:35:52.670129 nusoap_client: ctor wsdl=wsdl timeout=0 response_timeout=30
endpoint=string(60) "https://******?wsdl"
2013-05-13 10:35:52.670242 nusoap_client: will use lazy evaluation of wsdl from https://******?wsdl
"
["charencoding"]=>
bool(true)
["debugLevel"]=>
int(9)
["XMLSchemaVersion"]=>
string(32) "http://www.w3.org/2001/XMLSchema"
["soap_defencoding"]=>
string(10) "ISO-8859-1"
["namespaces"]=>
array(4) {
["SOAP-ENV"]=>
string(41) "http://schemas.xmlsoap.org/soap/envelope/"
["xsd"]=>
string(32) "http://www.w3.org/2001/XMLSchema"
["xsi"]=>
string(41) "http://www.w3.org/2001/XMLSchema-instance"
["SOAP-ENC"]=>
string(41) "http://schemas.xmlsoap.org/soap/encoding/"
}
["usedNamespaces"]=>
array(0) {
}
["typemap"]=>
array(6) {
["http://www.w3.org/2001/XMLSchema"]=>
array(43) {
["string"]=>
string(6) "string"
["boolean"]=>
string(7) "boolean"
["float"]=>
string(6) "double"
["double"]=>
string(6) "double"
["decimal"]=>
string(6) "double"
["duration"]=>
string(0) ""
["dateTime"]=>
string(6) "string"
["time"]=>
string(6) "string"
["date"]=>
string(6) "string"
["gYearMonth"]=>
string(0) ""
["gYear"]=>
string(0) ""
["gMonthDay"]=>
string(0) ""
["gDay"]=>
string(0) ""
["gMonth"]=>
string(0) ""
["hexBinary"]=>
string(6) "string"
["base64Binary"]=>
string(6) "string"
["anyType"]=>
string(6) "string"
["anySimpleType"]=>
string(6) "string"
["normalizedString"]=>
string(6) "string"
["token"]=>
string(6) "string"
["language"]=>
string(0) ""
["NMTOKEN"]=>
string(0) ""
["NMTOKENS"]=>
string(0) ""
["Name"]=>
string(0) ""
["NCName"]=>
string(0) ""
["ID"]=>
string(0) ""
["IDREF"]=>
string(0) ""
["IDREFS"]=>
string(0) ""
["ENTITY"]=>
string(0) ""
["ENTITIES"]=>
string(0) ""
["integer"]=>
string(7) "integer"
["nonPositiveInteger"]=>
string(7) "integer"
["negativeInteger"]=>
string(7) "integer"
["long"]=>
string(7) "integer"
["int"]=>
string(7) "integer"
["short"]=>
string(7) "integer"
["byte"]=>
string(7) "integer"
["nonNegativeInteger"]=>
string(7) "integer"
["unsignedLong"]=>
string(0) ""
["unsignedInt"]=>
string(0) ""
["unsignedShort"]=>
string(0) ""
["unsignedByte"]=>
string(0) ""
["positiveInteger"]=>
string(0) ""
}
["http://www.w3.org/2000/10/XMLSchema"]=>
array(11) {
["i4"]=>
string(0) ""
["int"]=>
string(7) "integer"
["boolean"]=>
string(7) "boolean"
["string"]=>
string(6) "string"
["double"]=>
string(6) "double"
["float"]=>
string(6) "double"
["dateTime"]=>
string(6) "string"
["timeInstant"]=>
string(6) "string"
["base64Binary"]=>
string(6) "string"
["base64"]=>
string(6) "string"
["ur-type"]=>
string(5) "array"
}
["http://www.w3.org/1999/XMLSchema"]=>
array(11) {
["i4"]=>
string(0) ""
["int"]=>
string(7) "integer"
["boolean"]=>
string(7) "boolean"
["string"]=>
string(6) "string"
["double"]=>
string(6) "double"
["float"]=>
string(6) "double"
["dateTime"]=>
string(6) "string"
["timeInstant"]=>
string(6) "string"
["base64Binary"]=>
string(6) "string"
["base64"]=>
string(6) "string"
["ur-type"]=>
string(5) "array"
}
["http://soapinterop.org/xsd"]=>
array(1) {
["SOAPStruct"]=>
string(6) "struct"
}
["http://schemas.xmlsoap.org/soap/encoding/"]=>
array(3) {
["base64"]=>
string(6) "string"
["array"]=>
string(5) "array"
["Array"]=>
string(5) "array"
}
["http://xml.apache.org/xml-soap"]=>
array(1) {
[0]=>
string(3) "Map"
}
}
["xmlEntities"]=>
array(5) {
["quot"]=>
string(1) """
["amp"]=>
string(1) "&"
["lt"]=>
string(1) "<"
["gt"]=>
string(1) ">"
["apos"]=>
string(1) "'"
}
["wsdlFile"]=>
string(60) "https://******?wsdl"
["wsdl"]=>
NULL
}
this is my code :
require_once('libs/nusoap/nusoap.php');
$soapclient = new nusoap_client('https://*****?wsdl','wsdl');
echo $soapclient->getError() ;
echo $soapclient;

Related

Extract $item code from array in k2store

I try to extract and to show on the page with echo product code field in K2store cart page (store extension for K2 for Joomla) but without success. The right value is "product_code" or "code" (is the same value): 26910.
Both "echo $item->product_name" and "echo $item->product_id" works, but "echo $item->code" and "echo $item->product_code" return NULL.
var_dump($item) show me this:
object(stdClass)#381 (13) {
["key"]=>
int(9928417)
["product_id"]=>
string(7) "9928417"
["product_name"]=>
string(71) "some title"
["product_model"]=>
NULL
["product_total"]=>
int(1)
["product_options"]=>
object(stdClass)#382 (0) {
}
["quantity"]=>
int(1)
["stock"]=>
object(JObject)#378 (18) {
["_errors":protected]=>
array(0) {
}
["item_enabled"]=>
string(1) "1"
["item_sku"]=>
NULL
["item_price"]=>
NULL
["special_price"]=>
NULL
["item_tax_id"]=>
NULL
["item_shipping"]=>
NULL
["item_qty"]=>
NULL
["item_cart_text"]=>
NULL
["product_id"]=>
string(7) "9928417"
["product_name"]=>
string(71) "some title"
["product_code"]=>
string(5) "26910"
["price"]=>
NULL
["product_sku"]=>
NULL
["tax_profile_id"]=>
NULL
["item_minimum"]=>
string(1) "1"
["stock"]=>
*RECURSION*
["product"]=>
object(stdClass)#354 (38) {
["id"]=>
string(7) "9928417"
["code"]=>
string(5) "26910"
["title"]=>
string(71) "some title"
["alias"]=>
string(71) "some title"
["catid"]=>
string(3) "694"
["published"]=>
string(1) "1"
["introtext"]=>
string(0) ""
["fulltext"]=>
string(0) ""
["video"]=>
NULL
["gallery"]=>
NULL
["extra_fields"]=>
string(29) "[{"id":"1","value":"25\/40"}]"
["extra_fields_search"]=>
string(6) "25/40 "
["created"]=>
string(19) "2012-09-14 10:20:09"
["created_by"]=>
string(2) "52"
["created_by_alias"]=>
string(0) ""
["checked_out"]=>
string(1) "0"
["checked_out_time"]=>
string(19) "0000-00-00 00:00:00"
["modified"]=>
string(19) "2012-09-14 10:30:46"
["modified_by"]=>
string(2) "52"
["publish_up"]=>
string(19) "2012-09-14 10:20:09"
["publish_down"]=>
string(19) "0000-00-00 00:00:00"
["trash"]=>
string(1) "0"
["access"]=>
string(1) "1"
["ordering"]=>
string(1) "1"
["featured"]=>
string(1) "0"
["featured_ordering"]=>
string(1) "0"
["image_caption"]=>
string(0) ""
["image_credits"]=>
string(0) ""
["video_caption"]=>
string(0) ""
["video_credits"]=>
string(0) ""
["hits"]=>
string(5) "17852"
["params"]=>
string(1190) "catItemTitle=
catItemTitleLinked=
catItemFeaturedNotice=
catItemAuthor=
catItemDateCreated=
catItemRating=
catItemImage=
catItemIntroText=
catItemExtraFields=
catItemHits=
catItemCategory=
catItemTags=
catItemAttachments=
catItemAttachmentsCounter=
catItemVideo=
catItemVideoWidth=
catItemVideoHeight=
catItemVideoAutoPlay=
catItemImageGallery=
catItemDateModified=
catItemReadMore=
catItemCommentsAnchor=
catItemK2Plugins=
itemDateCreated=
itemTitle=
itemFeaturedNotice=
itemAuthor=
itemFontResizer=
itemPrintButton=
itemEmailButton=
itemSocialButton=
itemVideoAnchor=
itemImageGalleryAnchor=
itemCommentsAnchor=
itemRating=
itemImage=
itemImgSize=
itemImageMainCaption=
itemImageMainCredits=
itemIntroText=
itemFullText=
itemExtraFields=
itemDateModified=
itemHits=
itemTwitterLink=
itemCategory=
itemTags=
itemShareLinks=
itemAttachments=
itemAttachmentsCounter=
itemRelated=
itemRelatedLimit=
itemVideo=
itemVideoWidth=
itemVideoHeight=
itemVideoAutoPlay=
itemVideoCaption=
itemVideoCredits=
itemImageGallery=
itemNavigation=
itemComments=
itemAuthorBlock=
itemAuthorImage=
itemAuthorDescription=
itemAuthorURL=
itemAuthorEmail=
itemAuthorLatest=
itemAuthorLatestLimit=
itemK2Plugins=
"
["metadesc"]=>
string(0) ""
["metadata"]=>
string(15) "robots=
author="
["metakey"]=>
string(0) ""
["plugins"]=>
string(27) "{"k2storeitem_enabled":"1"}"
["code_search"]=>
string(0) ""
["language"]=>
string(0) ""
}
}
["tax_amount"]=>
int(0)
["price"]=>
int(0)
["price_without_tax"]=>
int(0)
["total"]=>
int(0)
["total_without_tax"]=>
int(0)
}
The solution is: $item->stock->product_code

Can't access desired attributes from Eloquent Collection

$result = User::where('email_add', '=', $username)->first();
Here's what shows up when I use var_dump on $result
object(User)#22 (30) { ["user_id"]=> int(0) ["fname"]=> string(0) "" ["lname"]=> string(0) "" ["mname"]=> string(0) "" ["bdate"]=> string(0) "" ["contact"]=> string(0) "" ["email_add"]=> string(0) "" ["fillable":protected]=> array(6) { [0]=> string(5) "fname" [1]=> string(5) "mname" [2]=> string(5) "lname" [3]=> string(5) "bdate" [4]=> string(7) "contact" [5]=> string(9) "email_add" } ["connection":protected]=> NULL ["table":protected]=> NULL ["primaryKey":protected]=> string(2) "id" ["keyType":protected]=> string(3) "int" ["perPage":protected]=> int(15) ["incrementing"]=> bool(true) ["timestamps"]=> bool(true) ["attributes":protected]=> array(10) { ["user_id"]=> int(33) ["fname"]=> string(6) "Robert" ["lname"]=> string(6) "Marley" ["mname"]=> string(5) "Nesta" ["bdate"]=> string(10) "0000-00-00" ["contact"]=> string(11) "09123847599" ["email_add"]=> string(40) "7c9ac9ca8543dd84f71aa541d422e2a95d3e7450" ["photo"]=> NULL ["created_at"]=> string(19) "2017-01-25 01:03:06" ["updated_at"]=> string(19) "0000-00-00 00:00:00" } ["original":protected]=> array(10) { ["user_id"]=> int(33) ["fname"]=> string(6) "Robert" ["lname"]=> string(6) "Marley" ["mname"]=> string(5) "Nesta" ["bdate"]=> string(10) "0000-00-00" ["contact"]=> string(11) "09123847599" ["email_add"]=> string(40) "7c9ac9ca8543dd84f71aa541d422e2a95d3e7450" ["photo"]=> NULL ["created_at"]=> string(19) "2017-01-25 01:03:06" ["updated_at"]=> string(19) "0000-00-00 00:00:00" } ["relations":protected]=> array(0) { } ["hidden":protected]=> array(0) { } ["visible":protected]=> array(0) { } ["appends":protected]=> array(0) { } ["guarded":protected]=> array(1) { [0]=> string(1) "*" } ["dates":protected]=> array(0) { } ["dateFormat":protected]=> NULL ["casts":protected]=> array(0) { } ["touches":protected]=> array(0) { } ["observables":protected]=> array(0) { } ["with":protected]=> array(0) { } ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false) }
Here's what happens when I use foreach to var_dump each $user on the $result
int(0) string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" bool(true) bool(true) bool(true) bool(false)
I've been looking for a solution to this but I don't seem to find one, I was using get() at first but I read somewhere that if I'm expecting only 1 result, I should be using first() but it doesn't change anything. I can't access the Collection..
I've found a solution
This one helped me.
adding ->toArray on my ->first() was the magic, it only returns an array with the exact attributes without the unnecessary object properties.

PHP current() returns false when passing a valid array to it

i have an array with size=1 and when i try to get the current array its returns false but the array has values.
$article=getArticle($id);
if(is_array($article))
{ $article=current($article); }
the getArticle returns multidimensional array and when var_dump before current i can see the array.
If var_dump after current i get false.
if i use the code above (because the array size=1)
if(is_array($article))
{
foreach($article as $k=>$v)
{
$article=$v;
}
}
It works without any problem
Whats wrong with current?
Please help
===============EDIT========================
This is the var_dump before current
I have remove the content and summary because are large texts
array(1) {
[529]=>
array(14) {
["articles_id"]=>
string(3) "529"
["issue"]=>
string(3) "161"
["membership_type"]=>
string(1) "1"
["el"]=>
array(9) {
["title"]=>
string(23) "AUTOBIANCHI A112 ABARTH"
["url"]=>
string(23) "autobianchi-a112-abarth"
["summary"]=>
string(397) " i have remove it
"
["content"]=>
string(11580) " i have remove it too large
"
["meta_keywords"]=>
string(23) "AUTOBIANCHI,A112,ABARTH"
["meta_description"]=>
string(402) " "
["created"]=>
string(10) "1362076380"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
["categories_id"]=>
string(2) "12"
["authors_id"]=>
string(2) "16"
["brands_id"]=>
string(2) "36"
["models_id"]=>
string(3) "206"
["engines_id"]=>
string(3) "174"
["o-categories"]=>
array(1) {
["values"]=>
array(1) {
[12]=>
array(15) {
["categories_id"]=>
string(2) "12"
["object_id"]=>
string(1) "1"
["parent_id"]=>
string(1) "0"
["path"]=>
string(2) "12"
["handler"]=>
string(0) ""
["icon"]=>
string(0) ""
["tpl"]=>
string(12) "articles.php"
["alias"]=>
string(1) "0"
["is_nav"]=>
string(1) "1"
["pos"]=>
string(2) "10"
["depth"]=>
string(1) "0"
["cts"]=>
string(0) ""
["mts"]=>
string(0) ""
["configuration"]=>
string(0) ""
["el"]=>
array(15) {
["categories_id"]=>
string(2) "12"
["lang"]=>
string(2) "el"
["category_name"]=>
string(13) "Classic"
["sub_title"]=>
string(0) ""
["summary"]=>
string(0) ""
["image"]=>
string(0) ""
["html_code"]=>
string(0) ""
["meta_title"]=>
string(0) ""
["url"]=>
string(13) "classic"
["url_path"]=>
string(13) "classic"
["meta_keywords"]=>
string(0) ""
["meta_description"]=>
string(0) ""
["created"]=>
string(10) "1355235888"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
}
["o-authors"]=>
array(1) {
["values"]=>
array(1) {
[16]=>
array(4) {
["authors_id"]=>
string(2) "16"
["object_id"]=>
string(2) "26"
["image"]=>
string(0) ""
["el"]=>
array(9) {
["authors_id"]=>
string(2) "16"
["lang"]=>
string(2) "el"
["name"]=>
string(31) "Last First"
["last_name"]=>
string(10) "Last"
["first_name"]=>
string(20) "First"
["nick_name"]=>
string(0) ""
["created"]=>
string(10) "1360567827"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
}
["o-brands"]=>
array(1) {
["values"]=>
array(1) {
[36]=>
array(6) {
["brands_id"]=>
string(2) "36"
["object_id"]=>
string(2) "17"
["brand_name"]=>
string(11) "AUTOBIANCHI"
["created"]=>
string(10) "1363179463"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
["o-models"]=>
array(1) {
["values"]=>
array(1) {
[206]=>
array(7) {
["models_id"]=>
string(3) "206"
["object_id"]=>
string(2) "18"
["brands_id"]=>
string(2) "36"
["model_name"]=>
string(11) "A112 ABARTH"
["created"]=>
string(10) "1363179480"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
["o-engines"]=>
array(1) {
["values"]=>
array(1) {
[174]=>
array(6) {
["engines_id"]=>
string(3) "174"
["object_id"]=>
string(2) "19"
["engine"]=>
string(5) "1.050"
["created"]=>
string(10) "1363179448"
["last_updated"]=>
string(1) "0"
["status"]=>
string(1) "1"
}
}
}
}
}
Can you try
$article=getArticle($id);
if (is_array($article)) {
$article = reset($article);
}
or
$article=getArticle($id);
if (is_array($article)) {
$article = array_shift($article);
}
You can look into the documentation about reset and the documentation about array_shift.
If you copy array in getArticle() function then its internal pointer is lost.
I think this is the reason, it returns false.

Retrieve values from view in PHP module development

I have retrieve a view programmaticly in my module with PHP. How can retrieve the values of this view? I'm using drupal 6.
That's the view result in my PHP code:
enter code hereobject(view)#48 (22) {
["db_table"]=>
string(10) "views_view"
["base_table"]=>
string(4) "node"
["args"]=>
array(0) {
}
["use_ajax"]=>
bool(false)
["result"]=>
array(0) {
}
["pager"]=>
array(5) {
["use_pager"]=>
bool(false)
["items_per_page"]=>
int(10)
["element"]=>
int(0)
["offset"]=>
int(0)
["current_page"]=>
int(0)
}
["old_view"]=>
array(0) {
}
["vid"]=>
string(2) "48"
["name"]=>
string(7) "student"
["description"]=>
string(7) "Student"
["tag"]=>
string(0) ""
["view_php"]=>
string(0) ""
["is_cacheable"]=>
string(1) "0"
["display"]=>
array(2) {
["default"]=>
object(views_display)#11 (7) {
["db_table"]=>
string(13) "views_display"
["vid"]=>
string(2) "48"
["id"]=>
string(7) "default"
["display_title"]=>
string(8) "Defaults"
["display_plugin"]=>
string(7) "default"
["position"]=>
string(1) "1"
["display_options"]=>
array(2) {
["fields"]=>
array(5) {
["field_locatie_student_lid"]=>
array(14) {
["label"]=>
string(7) "Locatie"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(25) "field_locatie_student_lid"
["table"]=>
string(31) "node_data_field_locatie_student"
["field"]=>
string(25) "field_locatie_student_lid"
["relationship"]=>
string(4) "none"
}
["field_naam_student_value"]=>
array(14) {
["label"]=>
string(4) "Naam"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(24) "field_naam_student_value"
["table"]=>
string(28) "node_data_field_naam_student"
["field"]=>
string(24) "field_naam_student_value"
["relationship"]=>
string(4) "none"
}
["field_ugentid_student_value"]=>
array(14) {
["label"]=>
string(7) "UGentID"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(27) "field_ugentid_student_value"
["table"]=>
string(31) "node_data_field_ugentid_student"
["field"]=>
string(27) "field_ugentid_student_value"
["relationship"]=>
string(4) "none"
}
["field_voornaam_student_value"]=>
array(14) {
["label"]=>
string(8) "Voornaam"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(28) "field_voornaam_student_value"
["table"]=>
string(32) "node_data_field_voornaam_student"
["field"]=>
string(28) "field_voornaam_student_value"
["relationship"]=>
string(4) "none"
}
["field_voorkeur_student_value"]=>
array(14) {
["label"]=>
string(19) "Voorkeurstageplaats"
["alter"]=>
array(16) {
["alter_text"]=>
int(0)
["text"]=>
string(0) ""
["make_link"]=>
int(0)
["path"]=>
string(0) ""
["link_class"]=>
string(0) ""
["alt"]=>
string(0) ""
["prefix"]=>
string(0) ""
["suffix"]=>
string(0) ""
["target"]=>
string(0) ""
["help"]=>
string(0) ""
["trim"]=>
int(0)
["max_length"]=>
string(0) ""
["word_boundary"]=>
int(1)
["ellipsis"]=>
int(1)
["html"]=>
int(0)
["strip_tags"]=>
int(0)
}
["empty"]=>
string(41) "geen overeenkomstige resultaten gevonden."
["hide_empty"]=>
int(0)
["empty_zero"]=>
int(0)
["link_to_node"]=>
int(0)
["label_type"]=>
string(6) "widget"
["format"]=>
string(7) "default"
["multiple"]=>
array(4) {
["group"]=>
bool(true)
["multiple_number"]=>
string(0) ""
["multiple_from"]=>
string(0) ""
["multiple_reversed"]=>
bool(false)
}
["exclude"]=>
int(0)
["id"]=>
string(28) "field_voorkeur_student_value"
["table"]=>
string(32) "node_data_field_voorkeur_student"
["field"]=>
string(28) "field_voorkeur_student_value"
["relationship"]=>
string(4) "none"
}
}
["filters"]=>
array(2) {
["type"]=>
array(9) {
["operator"]=>
string(2) "in"
["value"]=>
array(1) {
["student"]=>
string(7) "student"
}
["group"]=>
string(1) "0"
["exposed"]=>
bool(false)
["expose"]=>
array(2) {
["operator"]=>
bool(false)
["label"]=>
string(0) ""
}
["id"]=>
string(4) "type"
["table"]=>
string(4) "node"
["field"]=>
string(4) "type"
["relationship"]=>
string(4) "none"
}
["field_ugentid_student_value"]=>
array(9) {
["operator"]=>
string(9) "not empty"
["value"]=>
array(3) {
["value"]=>
string(0) ""
["min"]=>
string(0) ""
["max"]=>
string(0) ""
}
["group"]=>
string(1) "0"
["exposed"]=>
bool(false)
["expose"]=>
array(2) {
["operator"]=>
bool(false)
["label"]=>
string(0) ""
}
["id"]=>
string(27) "field_ugentid_student_value"
["table"]=>
string(31) "node_data_field_ugentid_student"
["field"]=>
string(27) "field_ugentid_student_value"
["relationship"]=>
string(4) "none"
}
}
}
}
["page_1"]=>
object(views_display)#43 (7) {
["db_table"]=>
string(13) "views_display"
["vid"]=>
string(2) "48"
["id"]=>
string(6) "page_1"
["display_title"]=>
string(6) "Pagina"
["display_plugin"]=>
string(4) "page"
["position"]=>
string(1) "2"
["display_options"]=>
array(1) {
["path"]=>
string(17) "studentenLijstCSV"
}
}
}
["type"]=>
string(6) "Normal"
["loaded"]=>
bool(true)
["executed"]=>
bool(false)
["built"]=>
bool(false)
["build_info"]=>
array(0) {
}
["attachment_before"]=>
string(0) ""
["attachment_after"]=>
string(0) ""
["get_total_rows"]=>
bool(true)
}
<div style="display: none" id="drupalforfirebug_general"><fieldset><legend>Drupal for Firebug General Messages</legend>There were no messages sent to the general log. Please use "firep($item, $optional_title)" to output messages to this console.</div><div style="display: none" id="drupalforfirebug_sql"><fieldset><legend>Devel Module is Not Installed</legend>Please install and enable the Devel Module to display the SQL queries.</fieldset></div><div style="display: none" id="drupalforfirebug_hook_form_alter">There was no form altering.</div><div style="display: none" id="drupalforfirebug_hook_user">There was no user processing.</div><div style="display: none" id="drupalforfirebug_hook_nodeapi">There was no node processing.</div><div style="display: none" id="drupalforfirebug_hook_views">There was no views processing.</div><div style="display: none" id="drupalforfirebug_php"><object style="width:100%;frameborder=0;height=100%;margin-bottom:-3px;" type="text/html" data="http://localhost/testplanning/?q=admin/firebug/exec"></object></div><div style="display: none" id="drupalforfirebug_hook_page_alter">This feature is only available in Drupal 7.</div>
why you not using just views?
$view = view_get_view('MY_VIEW_NAME');
$view->set_display('MY_DISPLAY'); // page_1 or block_1 ... block_n, ...page_n
$view->set_items_per_page(0);
$view->execute();
$result = $view->result;
$result will contains array of values of each row
I haven't actually tried this myself. First thing to do would be to execute the views query. This can be done with the execute function.
So doing something like this:
$view->execute('display_id');
Should populate the $view object with at least some data. The data available differs through the different layers of theme functions, so you might not get what you want. But this is the best method I can think of.

Sort object as value with int and text value

I have a object and have a problem, this object here $product have this keys ( product_title, product_price, product_stock ) and more, I need to sort after product_title and if my object have this products in I can't sort it right.
test product 1
test product 11
test product 111
test product 2
test product 20
test product 3
test product 33
test product 333
The right way to sort it its like this:
test product 1
test product 2
test product 3
test product 11
test product 33
test product 20
test product 111
test product 333
I have tried sort and rsort without luck.
If it can help, my object looks like this:
array(8) {
[0]=>
object(stdClass)#12 (49) {
["product_id"]=>
string(3) "335"
["product_guid"]=>
string(36) "F0161D03-33EF-6F40-C816-AEDB33640E36"
["account_id"]=>
string(2) "28"
["category_id"]=>
string(3) "189"
["brand_guid"]=>
NULL
["product_title"]=>
string(10) "Fadestativ"
["push_date"]=>
string(19) "2011-01-18 13:02:11"
["product_price"]=>
string(3) "560"
["product_price_before"]=>
string(1) "0"
["on_stock"]=>
string(1) "0"
["product_weight"]=>
string(1) "0"
["product_int_number"]=>
string(0) ""
["product_ext_number"]=>
string(0) ""
["product_small_info"]=>
string(0) ""
["product_big_info"]=>
string(31) "3 benet fad stativ højde 19 cm"
["active"]=>
string(1) "1"
["meta_title"]=>
string(0) ""
["meta_keyword"]=>
string(0) ""
["meta_description"]=>
string(0) ""
["product_new"]=>
string(1) "0"
["indicative_price"]=>
string(1) "0"
["cost_price"]=>
string(1) "0"
["id"]=>
string(2) "28"
["domain"]=>
string(26) "eventhuset.schemecloud.com"
["password"]=>
string(32) "098f6bcd4621d373cade4e832627b4f6"
["resellerid"]=>
string(1) "2"
["defualt_lang"]=>
string(2) "dk"
["quota"]=>
string(3) "100"
["account_type"]=>
string(3) "cms"
["busniess_name"]=>
string(0) ""
["busniess_street"]=>
string(0) ""
["busniess_city"]=>
string(0) ""
["busniess_zipcode"]=>
string(0) ""
["busniess_contry"]=>
string(0) ""
["busniess_phone"]=>
string(0) ""
["busniess_contact_person"]=>
string(0) ""
["busniess_contact_phone"]=>
string(0) ""
["busniess_email"]=>
string(0) ""
["busniess_cvr"]=>
string(0) ""
["invoice_name"]=>
string(0) ""
["invoice_street"]=>
string(0) ""
["invoice_city"]=>
string(0) ""
["invoice_zipcode"]=>
string(0) ""
["invoice_contry"]=>
string(0) ""
["invoice_contact_person"]=>
string(0) ""
["invoice_cvr"]=>
string(0) ""
["payment_expires"]=>
string(19) "0000-00-00 00:00:00"
["next_order_number"]=>
string(5) "10001"
["order_prefix"]=>
string(0) ""
}
[1]=>
object(stdClass)#14 (49) {
["product_id"]=>
string(3) "306"
["product_guid"]=>
string(36) "8119C253-84C7-73AC-4125-DF4B1728A203"
["account_id"]=>
string(2) "28"
["category_id"]=>
string(3) "189"
["brand_guid"]=>
NULL
["product_title"]=>
string(15) "Kartoffel skål"
["push_date"]=>
string(19) "2011-01-17 13:40:08"
["product_price"]=>
string(3) "680"
["product_price_before"]=>
string(1) "0"
["on_stock"]=>
string(1) "0"
["product_weight"]=>
string(1) "0"
["product_int_number"]=>
string(0) ""
["product_ext_number"]=>
string(0) ""
["product_small_info"]=>
string(0) ""
["product_big_info"]=>
string(31) "Kartoffel skål i rustfri stål"
["active"]=>
string(1) "1"
["meta_title"]=>
string(0) ""
["meta_keyword"]=>
string(0) ""
["meta_description"]=>
string(0) ""
["product_new"]=>
string(1) "0"
["indicative_price"]=>
string(1) "0"
["cost_price"]=>
string(1) "0"
["id"]=>
string(2) "28"
["domain"]=>
string(26) "eventhuset.schemecloud.com"
["password"]=>
string(32) "098f6bcd4621d373cade4e832627b4f6"
["resellerid"]=>
string(1) "2"
["defualt_lang"]=>
string(2) "dk"
["quota"]=>
string(3) "100"
["account_type"]=>
string(3) "cms"
["busniess_name"]=>
string(0) ""
["busniess_street"]=>
string(0) ""
["busniess_city"]=>
string(0) ""
["busniess_zipcode"]=>
string(0) ""
["busniess_contry"]=>
string(0) ""
["busniess_phone"]=>
string(0) ""
["busniess_contact_person"]=>
string(0) ""
["busniess_contact_phone"]=>
string(0) ""
["busniess_email"]=>
string(0) ""
["busniess_cvr"]=>
string(0) ""
["invoice_name"]=>
string(0) ""
["invoice_street"]=>
string(0) ""
["invoice_city"]=>
string(0) ""
["invoice_zipcode"]=>
string(0) ""
["invoice_contry"]=>
string(0) ""
["invoice_contact_person"]=>
string(0) ""
["invoice_cvr"]=>
string(0) ""
["payment_expires"]=>
string(19) "0000-00-00 00:00:00"
["next_order_number"]=>
string(5) "10001"
["order_prefix"]=>
string(0) ""
}
and I need to sort after
array(8) {
[0]=>
object(stdClass)#12 (49) {
["product_title"]=>
string(10) "Fadestativ"
}
Well, assuming that they are objects (which from your description and comments they appear to be), you can use a usort.
PHP 5.3+:
usort(
$array,
function($a, $b) {
return strnatcmp($a->title, $b->title);
}
);
PHP <= 5.2:
usort(
$array;
create_function('$a, $b', 'return strnatcmp($a->title, $b->title);`)
);
Change ->title to whatever property you want to sort by. And if you want case insensitivity, use strnatcasecmp instead of strnatcmp()...
Try sort() again but you will have to use a second parameter:
sort($array, SORT_STRING);

Categories