I'm using Google Drive API (v3) with Google's PHP api client to list and display videos from my Drive, where I'm also displaying thumbnails for said videos. I have difficulties getting thumbnail urls back from the API, although I enabled thumbnailLink in request parameters:
'fields' => 'nextPageToken, files(id, name, thumbnailLink, webContentLink, webViewLink)'
Value for thumbnailLink is still empty, other values are returned successfully. I looked for thumbnail settings in api documentation, without success. API also doesn't return any error. What could it be?
Here's the code I'm using:
$drive_service = new Google_Service_Drive($client);
$optParams = array(
'pageSize' => 4,
'q' => "'0B_nSMgQioOWwNy1ha0tFWEE0QWs' in parents and mimeType contains 'video/'",
'fields' => 'nextPageToken, files(id, name, modifiedTime, mimeType, createdTime, thumbnailLink, webContentLink, webViewLink)'
);
return $files_list = $drive_service->files->listFiles($optParams)->getFiles();
and var_dump of response
array(4) {
[0]=>
object(Google_Service_Drive_DriveFile)#590 (56) {
["collection_key":protected]=>
string(6) "spaces"
["appProperties"]=>
NULL
["capabilitiesType":protected]=>
string(42) "Google_Service_Drive_DriveFileCapabilities"
["capabilitiesDataType":protected]=>
string(0) ""
["contentHintsType":protected]=>
string(42) "Google_Service_Drive_DriveFileContentHints"
["contentHintsDataType":protected]=>
string(0) ""
["createdTime"]=>
string(24) "2016-09-12T19:54:22.000Z"
["description"]=>
NULL
["explicitlyTrashed"]=>
NULL
["fileExtension"]=>
NULL
["folderColorRgb"]=>
NULL
["fullFileExtension"]=>
NULL
["headRevisionId"]=>
NULL
["iconLink"]=>
NULL
["id"]=>
string(35) "1St7nQ3X3-ocrMUC2t-r6NOVc4xIdfhbIgg"
["imageMediaMetadataType":protected]=>
string(48) "Google_Service_Drive_DriveFileImageMediaMetadata"
["imageMediaMetadataDataType":protected]=>
string(0) ""
["isAppAuthorized"]=>
NULL
["kind"]=>
NULL
["lastModifyingUserType":protected]=>
string(25) "Google_Service_Drive_User"
["lastModifyingUserDataType":protected]=>
string(0) ""
["md5Checksum"]=>
NULL
["mimeType"]=>
string(9) "video/mp4"
["modifiedByMeTime"]=>
NULL
["modifiedTime"]=>
string(24) "2016-12-27T11:55:43.958Z"
["name"]=>
string(12) "MOV_1950.mp4"
["originalFilename"]=>
NULL
["ownedByMe"]=>
NULL
["ownersType":protected]=>
string(25) "Google_Service_Drive_User"
["ownersDataType":protected]=>
string(5) "array"
["parents"]=>
NULL
["permissionsType":protected]=>
string(31) "Google_Service_Drive_Permission"
["permissionsDataType":protected]=>
string(5) "array"
["properties"]=>
NULL
["quotaBytesUsed"]=>
NULL
["shared"]=>
NULL
["sharedWithMeTime"]=>
NULL
["sharingUserType":protected]=>
string(25) "Google_Service_Drive_User"
["sharingUserDataType":protected]=>
string(0) ""
["size"]=>
NULL
["spaces"]=>
NULL
["starred"]=>
NULL
["thumbnailLink"]=>
NULL
["trashed"]=>
NULL
["version"]=>
NULL
["videoMediaMetadataType":protected]=>
string(48) "Google_Service_Drive_DriveFileVideoMediaMetadata"
["videoMediaMetadataDataType":protected]=>
string(0) ""
["viewedByMe"]=>
NULL
["viewedByMeTime"]=>
NULL
["viewersCanCopyContent"]=>
NULL
["webContentLink"]=>
string(82) "https://drive.google.com/uc?id=1St7nQ3X3-ocrMUC2t-r6NOVc4xIdfhbIgg&export=download"
["webViewLink"]=>
string(85) "https://drive.google.com/file/d/1St7nQ3X3-ocrMUC2t-r6NOVc4xIdfhbIgg/view?usp=drivesdk"
["writersCanShare"]=>
NULL
["internal_gapi_mappings":protected]=>
array(0) {
}
["modelData":protected]=>
array(0) {
}
["processed":protected]=>
array(0) {
}
}...
Try to double check if you properly use a correct scope. I suggest you to use the https://www.googleapis.com/auth/drive for full permissive scope to access all of a user's files. If it's still not working, then try the suggested solution here.
Try items.thumbnailLink
This is what the response from the Drive API looks like.
{
"kind": "drive#fileList",
"etag": "\"m64ksZC09nG4-fB1IRF3vg/1C1ON4SO5V-To1u55k7dU\"",
"selfLink": "https://www.googleapis.com/drive/v2/files?corpus=DEFAULT",
"nextPageToken": "V1*3|0|ChwwQjdXTWpmWkhhWHllTW1ObtQq",
"nextLink": "https://www.googleapis.com/drive/v2/files?corpus=DEFAULT&pageToken=V1*3%7C0%7CChwwQjdVUnFTR05mZGpREgcQsonGqtQq",
"items": [
{
"kind": "drive#file",
"id": "1DpsZKiII1pOsHxDrJDzBb_aW841Ovhm8pE5FCI",
"etag": "\"m64ksZC09nG4-fB1IRF3vg/1C1ON4SO5V-To1u55k7dU\"",
"selfLink": "https://www.googleapis.com/drive/v2/files/1DpsZKiII1pOsHbrEzvxDrJDzBb_aW841Ovhm8pE5FCI"...
},
"defaultOpenWithLink": "https://docs.google.com/spreadsheets/d/1DpsZKihm8pE5FCI/edit?usp=drivesdk",
"iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_11_spreadsheet_list.png",
"thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=1DpsZKiInoAAAAAWGPVboChWb270pOAY0M5hMr3FNa-IX6G&sz=s220",
"title": "Document Title",
"mimeType": "application/vnd.google-apps.spreadsheet",
"labels": {
"starred": false,
"hidden": false,
"trashed": false,
"restricted": false,
"viewed": true
},...
Hope this helps!
I know you're trying to get a list of files, and this only retrieves a link from one, but this would have helped me a lot, and I think it's similar enough in concept to be potentially helpful to others:
function getThumbnailUrl($fileId)
{
$service = new Google_Service_Drive($this->client());
$params = array('fields' => 'hasThumbnail, thumbnailLink');
$file = $service->files->get($fileId, $params);
$url = $file->getThumbnailLink();
return $url;
}
I am still interested in whether you were able to get thumbnail links for multiple files using getFiles().
Related
I have a multidimensional array. I am retrieving this from UPS RateInTransit API. I am receiving this in an object. Then i convert it into a simple array.
i have received the data into json from UPS. So i converted it into php array by Json_encode and json_decode.
After that from Object array to simple array, so i found this.
object(Ups\Entity\RateResponse)#81 (1) {
["RatedShipment"]=>
array(1) {
[0]=>
object(Ups\Entity\RatedShipment)#82 (12) {
["Service"]=>
object(Ups\Entity\Service)#83 (3) {
["Description"]=>
NULL
["code":"Ups\Entity\Service":private]=>
string(2) "03"
["description":"Ups\Entity\Service":private]=>
NULL
}
["RateShipmentWarning"]=>
string(56) "Your invoice may vary from the displayed reference rates"
["BillingWeight"]=>
object(Ups\Entity\BillingWeight)#89 (2) {
["UnitOfMeasurement"]=>
object(Ups\Entity\UnitOfMeasurement)#91 (4) {
["Code"]=>
string(3) "LBS"
["Description"]=>
NULL
["code":"Ups\Entity\UnitOfMeasurement":private]=>
string(3) "LBS"
["description":"Ups\Entity\UnitOfMeasurement":private]=>
NULL
}
["Weight"]=>
string(4) "32.0"
}
["TransportationCharges"]=>
object(Ups\Entity\Charges)#84 (5) {
["CurrencyCode"]=>
string(3) "USD"
["MonetaryValue"]=>
float(43.17)
["Code"]=>
NULL
["Description"]=>
NULL
["SubType"]=>
NULL
}
["ServiceOptionsCharges"]=>
object(Ups\Entity\Charges)#86 (5) {
["CurrencyCode"]=>
string(3) "USD"
["MonetaryValue"]=>
float(0)
["Code"]=>
NULL
["Description"]=>
NULL
["SubType"]=>
NULL
}
["TotalCharges"]=>
object(Ups\Entity\Charges)#87 (5) {
["CurrencyCode"]=>
string(3) "USD"
["MonetaryValue"]=>
float(43.17)
["Code"]=>
NULL
["Description"]=>
NULL
["SubType"]=>
NULL
}
["GuaranteedDaysToDelivery"]=>
object(stdClass)#72 (0) {
}
["ScheduledDeliveryTime"]=>
object(stdClass)#73 (0) {
}
["RatedPackage"]=>
array(1) {
[0]=>
object(Ups\Entity\RatedPackage)#88 (5) {
["Weight"]=>
string(3) "4.0"
["BillingWeight"]=>
object(Ups\Entity\BillingWeight)#95 (2) {
["UnitOfMeasurement"]=>
object(Ups\Entity\UnitOfMeasurement)#97 (4) {
["Code"]=>
string(3) "LBS"
["Description"]=>
NULL
["code":"Ups\Entity\UnitOfMeasurement":private]=>
string(3) "LBS"
["description":"Ups\Entity\UnitOfMeasurement":private]=>
NULL
}
["Weight"]=>
string(4) "32.0"
}
["TransportationCharges"]=>
object(Ups\Entity\Charges)#85 (5) {
["CurrencyCode"]=>
string(3) "USD"
["MonetaryValue"]=>
float(43.17)
["Code"]=>
NULL
["Description"]=>
NULL
["SubType"]=>
NULL
}
["ServiceOptionsCharges"]=>
object(Ups\Entity\Charges)#92 (5) {
["CurrencyCode"]=>
string(3) "USD"
["MonetaryValue"]=>
float(0)
["Code"]=>
NULL
["Description"]=>
NULL
["SubType"]=>
NULL
}
["TotalCharges"]=>
object(Ups\Entity\Charges)#93 (5) {
["CurrencyCode"]=>
string(3) "USD"
["MonetaryValue"]=>
float(43.17)
["Code"]=>
NULL
["Description"]=>
NULL
["SubType"]=>
NULL
}
}
}
["SurCharges"]=>
array(0) {
}
["TimeInTransit"]=>
NULL
["NegotiatedRates"]=>
NULL
}
}
}
But i am unable to access ['RatedShipment]['BillingWeight']['Weight'].
Where did i write a wrong code???
What do you think to use $arr = (array) $obj;?
Because it still looks like an object.
Or you could access $obj->RatedShipment->BillingWeight->Weight?
Just as the title says, I am able to get the data from the "source" (I guess that would be the $token) but nothing else.
<?php
require_once('stripe/init.php');
\Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxxxx");
$input = #file_get_contents("php://input");
$event_json = json_decode($input);
$name = $event_json->data->object->name;
$cvc_check = $event_json->data->object->cvc_check;
?>
=
I can get the $name (which is the email address) and the $cvc_check, but if I do the same for, let's say, status, there's nothing there:
=
$status = $event_json->data->object->status;
=
Can somebody tell / guide me in the right direction? Why can't I get anything outside of the "source"?
{
"object": {
"id": "ch_1EIdL8IcP22cq9aQpA",
"object": "charge",
"amount": 500,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1EIdL8IcP22cq9",
"source": {
"id": "card_1EIdL3IcP22cq",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"customer": "cus_EmBix3cJ",
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 2,
"exp_year": 2022,
"fingerprint": "zrzwvqXQTWp",
"funding": "credit",
"last4": "4242",
"metadata": {
},
"name": "someemailaddress#yahoo.com",
"tokenization_method": null
},
"source_transfer": null,
"statement_descriptor": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
}
=
Stripe test response:
=
object(stdClass)#1 (9) {
["created"]=>
int(1326853478)
["livemode"]=>
bool(false)
["id"]=>
string(31) "charge.succeeded_00000000000000"
["type"]=>
string(16) "charge.succeeded"
["object"]=>
string(5) "event"
["request"]=>
NULL
["pending_webhooks"]=>
int(1)
["api_version"]=>
string(10) "2018-10-31"
["data"]=>
object(stdClass)#14 (1) {
["object"]=>
object(stdClass)#2 (41) {
["id"]=>
string(17) "ch_00000000000000"
["object"]=>
string(6) "charge"
["amount"]=>
int(500)
["amount_refunded"]=>
int(0)
["application"]=>
NULL
["application_fee"]=>
NULL
["application_fee_amount"]=>
NULL
["balance_transaction"]=>
string(18) "txn_00000000000000"
["billing_details"]=>
object(stdClass)#4 (4) {
["address"]=>
object(stdClass)#3 (6) {
["city"]=>
NULL
["country"]=>
NULL
["line1"]=>
NULL
["line2"]=>
NULL
["postal_code"]=>
NULL
["state"]=>
NULL
}
["email"]=>
NULL
["name"]=>
string(25) "someemail#yahoo.com"
["phone"]=>
NULL
}
["captured"]=>
bool(false)
["created"]=>
int(1553691107)
["currency"]=>
string(3) "usd"
["customer"]=>
string(18) "cus_00000000000000"
["description"]=>
NULL
["destination"]=>
NULL
["dispute"]=>
NULL
["failure_code"]=>
string(13) "card_declined"
["failure_message"]=>
string(23) "Your card was declined."
["fraud_details"]=>
object(stdClass)#5 (1) {
["stripe_report"]=>
string(10) "fraudulent"
}
["invoice"]=>
NULL
["livemode"]=>
bool(false)
["metadata"]=>
object(stdClass)#6 (0) {
}
["on_behalf_of"]=>
NULL
["order"]=>
NULL
["outcome"]=>
object(stdClass)#7 (6) {
["network_status"]=>
string(19) "not_sent_to_network"
["reason"]=>
string(18) "merchant_blacklist"
["risk_level"]=>
string(7) "highest"
["risk_score"]=>
int(98)
["seller_message"]=>
string(28) "Stripe blocked this payment."
["type"]=>
string(7) "blocked"
}
["paid"]=>
bool(true)
["payment_intent"]=>
NULL
["payment_method_details"]=>
object(stdClass)#10 (2) {
["card"]=>
object(stdClass)#8 (10) {
["brand"]=>
string(4) "visa"
["checks"]=>
object(stdClass)#9 (3) {
["address_line1_check"]=>
NULL
["address_postal_code_check"]=>
NULL
["cvc_check"]=>
string(11) "unavailable"
}
["country"]=>
string(2) "US"
["exp_month"]=>
int(1)
["exp_year"]=>
int(2022)
["fingerprint"]=>
string(16) "Gawa768Trrk4fEmb"
["funding"]=>
string(6) "credit"
["last4"]=>
string(4) "0019"
["three_d_secure"]=>
NULL
["wallet"]=>
NULL
}
["type"]=>
string(4) "card"
}
["receipt_email"]=>
NULL
["receipt_number"]=>
NULL
["receipt_url"]=>
string(118) "https://pay.stripe.com/receipts/acct_1DU4J1IcP22cq9aQ/ch_1EIbENIcP22cq9aQk7r9xN3u/rcpt_Em9Xy3Ambv1b8QZISOsIHdbxCn"
["refunded"]=>
bool(false)
["refunds"]=>
object(stdClass)#11 (5) {
["object"]=>
string(4) "list"
["data"]=>
array(0) {
}
["has_more"]=>
bool(false)
["total_count"]=>
int(0)
["url"]=>
string(47) "/v1/charges/ch_1EIbENIcP22cq9aQk7r9xN3u/refunds"
}
["review"]=>
NULL
["shipping"]=>
NULL
["source"]=>
object(stdClass)#12 (23) {
["id"]=>
string(19) "card_00000000000000"
["object"]=>
string(4) "card"
["address_city"]=>
NULL
["address_country"]=>
NULL
["address_line1"]=>
NULL
["address_line1_check"]=>
NULL
["address_line2"]=>
NULL
["address_state"]=>
NULL
["address_zip"]=>
NULL
["address_zip_check"]=>
NULL
["brand"]=>
string(4) "Visa"
["country"]=>
string(2) "US"
["customer"]=>
string(18) "cus_00000000000000"
["cvc_check"]=>
string(11) "unavailable"
["dynamic_last4"]=>
NULL
["exp_month"]=>
int(1)
["exp_year"]=>
int(2022)
["fingerprint"]=>
string(16) "Gawa768Trrk4fEmb"
["funding"]=>
string(6) "credit"
["last4"]=>
string(4) "0019"
["metadata"]=>
object(stdClass)#13 (0) {
}
["name"]=>
string(25) "someemail#yahoo.com"
["tokenization_method"]=>
NULL
}
["source_transfer"]=>
NULL
["statement_descriptor"]=>
NULL
["status"]=>
string(6) "failed"
["transfer_data"]=>
NULL
["transfer_group"]=>
NULL
}
}
}
=
I'd like to get data from ["status"]=>
string(6) "failed" (the last part of the code).
I am trying to retrieve all cards for a particular customer, by supplying a customer ID. Per the documentation, I am expecting the following response:
Stripe\Collection JSON: {
"object" => "list",
"url" => "/v1/customers/cu_16jdAj2eZvKYlo2CbrCP4HRs/sources",
"has_more" => false,
"data" => [
[0] => Stripe\Card JSON: {
"id": "card_14bIFkou9GUI42eZvKYlo2Cs",
"object": "card",
"last4": "4242",
"brand": "Visa",
"funding": "credit",
"exp_month": 11,
"exp_year": 2018,
"country": "US",
"name": "callingsudhanshu#gmail.com",
"address_line1": null,
"address_line2": null,
"address_city": null,
"address_state": null,
"address_zip": null,
"address_country": null,
"cvc_check": null,
"address_line1_check": null,
"address_zip_check": null,
"tokenization_method": null,
"dynamic_last4": null,
"metadata": {
},
"customer": "cus_6Nb0wxYHigk2mX"
}
[1] => <Stripe\Card[...] ...>
[2] => <Stripe\Card[...] ...>
]
}
And here's the request I'm making to Stripe. Trying to pull data (ie, an array of all cards) from the $card_list:
\Stripe\Stripe::setApiKey($this->stripe_sk);
$card_list = \Stripe\Customer::retrieve($customer_id)->sources->all(array(
'object' => 'card'
));
// Return a list of all cards.
$card_list = $card_list->data;
return $card_list;
I would like to know why the Stripe response from $card_list contains additional/unexpected data. Here's what I'm actually getting back:
array(1) {
[0]=>
object(Stripe\Card)#292 (5) {
["_opts":protected]=>
object(Stripe\Util\RequestOptions)#294 (2) {
["headers"]=>
array(0) {
}
["apiKey"]=>
string(32) "sk_test_d3..."
}
["_values":protected]=>
array(23) {
["id"]=>
string(29) "card_16jLIwLBSNgilYpnoEiPhNhA"
["object"]=>
string(4) "card"
["last4"]=>
string(4) "4242"
["brand"]=>
string(4) "Visa"
["funding"]=>
string(6) "credit"
["exp_month"]=>
int(8)
["exp_year"]=>
int(2016)
["fingerprint"]=>
string(16) "T5RzXLIiXrF0nyqH"
["country"]=>
string(2) "US"
["name"]=>
NULL
["address_line1"]=>
NULL
["address_line2"]=>
NULL
["address_city"]=>
NULL
["address_state"]=>
NULL
["address_zip"]=>
NULL
["address_country"]=>
NULL
["cvc_check"]=>
string(4) "pass"
["address_line1_check"]=>
NULL
["address_zip_check"]=>
NULL
["tokenization_method"]=>
NULL
["dynamic_last4"]=>
NULL
["metadata"]=>
object(Stripe\AttachedObject)#261 (5) {
["_opts":protected]=>
object(Stripe\Util\RequestOptions)#294 (2) {
["headers"]=>
array(0) {
}
["apiKey"]=>
string(32) "sk_test_d..."
}
["_values":protected]=>
array(0) {
}
["_unsavedValues":protected]=>
object(Stripe\Util\Set)#262 (1) {
["_elts":"Stripe\Util\Set":private]=>
array(0) {
}
}
["_transientValues":protected]=>
object(Stripe\Util\Set)#306 (1) {
["_elts":"Stripe\Util\Set":private]=>
array(0) {
}
}
["_retrieveOptions":protected]=>
array(0) {
}
}
["customer"]=>
string(18) "cus_6xCtshHPQiYSdI"
}
["_unsavedValues":protected]=>
object(Stripe\Util\Set)#270 (1) {
["_elts":"Stripe\Util\Set":private]=>
array(0) {
}
}
["_transientValues":protected]=>
object(Stripe\Util\Set)#120 (1) {
["_elts":"Stripe\Util\Set":private]=>
array(0) {
}
}
["_retrieveOptions":protected]=>
array(0) {
}
}
}
Hoping that someone can explain the "extended" version of the response, that I'm getting here. Thanks in advance!
I stuck in this problem a couple of days ago and I've managed to solve it using json_encode() API like this (need to export this as a AJAX return on my side).
$cards = \Stripe\Customer::retrieve($_SESSION['stripe_customer_id'])->sources->all(array("object" => "card"));
$list = json_encode($cards->data);
echo($list);
Hope this helps.
BTW : Your response looks alike a var_dump() output.
If you want to normalize data in array form to get value easily then add __toArray(); to get response in array.
Ex: $cards->data->__toArray();
I’m trying to make a purchase request to a Simulator end point (https://test.sagepay.com/Simulator/VSPDirectGateway.asp), with the following data:
array(35) {
["VPSProtocol"]=>
string(4) "2.23"
["TxType"]=>
string(7) "PAYMENT"
["Vendor"]=>
string(9) "MY VENDOR NAME"
["AccountType"]=>
string(1) "E"
["Description"]=>
string(13) "My Test Order"
["Amount"]=>
string(4) "1.50"
["Currency"]=>
string(3) "GBP"
["VendorTxCode"]=>
string(1) "3"
["ClientIPAddress"]=>
NULL
["ApplyAVSCV2"]=>
int(0)
["Apply3DSecure"]=>
int(0)
["BillingFirstnames"]=>
string(3) "Sam"
["BillingSurname"]=>
string(4) "King"
["BillingAddress1"]=>
string(1) "1"
["BillingAddress2"]=>
string(1) "2"
["BillingCity"]=>
string(8) "Brighton"
["BillingPostCode"]=>
string(3) "BN1"
["BillingState"]=>
string(0) ""
["BillingCountry"]=>
string(2) "GB"
["BillingPhone"]=>
NULL
["DeliveryFirstnames"]=>
NULL
["DeliverySurname"]=>
NULL
["DeliveryAddress1"]=>
NULL
["DeliveryAddress2"]=>
NULL
["DeliveryCity"]=>
NULL
["DeliveryPostCode"]=>
NULL
["DeliveryState"]=>
string(0) ""
["DeliveryCountry"]=>
NULL
["DeliveryPhone"]=>
NULL
["CustomerEMail"]=>
NULL
["CardHolder"]=>
string(8) "Sam King"
["CardNumber"]=>
string(16) "4012888888881881"
["CV2"]=>
string(3) "123"
["ExpiryDate"]=>
string(4) "0215"
["CardType"]=>
string(4) "visa"
}
However, all I repeatedly keep getting back from Sagepay is a validation error:
"The CardHolder field should be between 1 and 50 characters long.”
However, as you can see in the above data array, I’m sending a CardHolder value of ‘Sam King’, which is clearly between 1 and 50 characters long.
For reference, I'm using the Omnipay (https://github.com/thephpleague/omnipay) library to make requests.
Any idea what I could be doing wrong here?
I tried using Kohana/ORM on my localhost xampp and i get the following error
ErrorException [ Notice ]: Array to string conversion
MODPATH\orm\classes\kohana\orm.php [ 980 ]
975 }
976 else
977 {
978 // List columns and mirror for performance
979 $this->_table_columns = $this->list_columns();
980 $this->_table_columns = array_combine($this->_table_columns, $this->_table_columns);
981
982 // Load column cache
983 ORM::$_column_cache[$this->_object_name] = $this->_table_columns;
984 }
985 }
It seems to be a common error appearing in different Frameworks/PHP Applications, but I have not found any clue to fix it.
The Model is just the basic ORM
class Model_Product extends ORM {
}
The Mysql Table (InnoDB - UTF-8) has two fields
id - primary int
name - varchar 50
no voodoo anywhere, help is very appreciated
thanks in advance!
edit: the requested vardump
array(2) {
["id"]=>
array(13) {
["type"]=>
string(3) "int"
["min"]=>
string(11) "-2147483648"
["max"]=>
string(10) "2147483647"
["column_name"]=>
string(2) "id"
["column_default"]=>
NULL
["data_type"]=>
string(3) "int"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(1)
["display"]=>
string(2) "11"
["comment"]=>
string(0) ""
["extra"]=>
string(14) "auto_increment"
["key"]=>
string(3) "PRI"
["privileges"]=>
string(31) "select,insert,update,references"
}
["name"]=>
array(12) {
["type"]=>
string(6) "string"
["column_name"]=>
string(4) "name"
["column_default"]=>
NULL
["data_type"]=>
string(7) "varchar"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(2)
["character_maximum_length"]=>
string(2) "50"
["collation_name"]=>
string(15) "utf8_general_ci"
["comment"]=>
string(0) ""
["extra"]=>
string(0) ""
["key"]=>
string(0) ""
["privileges"]=>
string(31) "select,insert,update,references"
}
}
Line 980:
980 $this->_table_columns = array_combine($this->_table_columns, $this->_table_columns);
looks superfluous taken the previous line 979 into account:
979 $this->_table_columns = $this->list_columns();
Merging two times the same array is useless, especially as the array is this:
array(2) {
["id"]=>
array(13) {
["type"]=>
string(3) "int"
["min"]=>
string(11) "-2147483648"
["max"]=>
string(10) "2147483647"
["column_name"]=>
string(2) "id"
["column_default"]=>
NULL
["data_type"]=>
string(3) "int"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(1)
["display"]=>
string(2) "11"
["comment"]=>
string(0) ""
["extra"]=>
string(14) "auto_increment"
["key"]=>
string(3) "PRI"
["privileges"]=>
string(31) "select,insert,update,references"
}
["name"]=>
array(12) {
["type"]=>
string(6) "string"
["column_name"]=>
string(4) "name"
["column_default"]=>
NULL
["data_type"]=>
string(7) "varchar"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(2)
["character_maximum_length"]=>
string(2) "50"
["collation_name"]=>
string(15) "utf8_general_ci"
["comment"]=>
string(0) ""
["extra"]=>
string(0) ""
["key"]=>
string(0) ""
["privileges"]=>
string(31) "select,insert,update,references"
}
}
It only contains string keys. You should open a bug report with the kohana framework.
Comment line 980 until this get's fixed.
I found a way to resolve this error, just declare the table colums in the model.
protected $_table_columns = array(
'column' => NULL,
'names' => NULL,
'go' => NULL,
'here' => NULL,
......
);
this will ged rid of the problem and increase performance as well.