I'm using Illuminate to access my database
<body>
<?php
$edges = Edge::all();
foreach ($edges as $key => $value) {
print $value;
}
?>
</body>
browser returns:
{"childID":"A","parentID":"C","updated_at":null,"created_at":null}{"childID":"B","parentID":"E","updated_at":null,"created_at":null}{"childID":"C","parentID":"D","updated_at":null,"created_at":null}{"childID":"C","parentID":"F","updated_at":null,"created_at":null}{"childID":"Y","parentID":"Z","updated_at":"2014-08-07 10:26:54","created_at":"2014-08-07 10:26:54"}
What's odd or unexpected for me at least is that my results are returned in JSON. If you could
shine some light on this, i.e. why this might be, or the reason is...I'd be grateful.
If I dump the results in the browser with:
<?php
print '<pre>';print_r($edges);
?>
produces:
Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => Edge Object
(
[connection:protected] =>
[table:protected] =>
[primaryKey:protected] => id
[perPage:protected] => 15
[incrementing] => 1
[timestamps] => 1
[attributes:protected] => Array
(
[childID] => A
[parentID] => C
[updated_at] =>
[created_at] =>
)
[original:protected] => Array
(
[childID] => A
[parentID] => C
[updated_at] =>
[created_at] =>
)
[relations:protected] => Array
(
)
[hidden:protected] => Array
(
)
[visible:protected] => Array
(
)
[appends:protected] => Array
(
)
[fillable:protected] => Array
(
)
[guarded:protected] => Array
(
[0] => *
)
[dates:protected] => Array
(
)
[touches:protected] => Array
(
)
[observables:protected] => Array
(
)
[with:protected] => Array
(
)
[morphClass:protected] =>
[exists] => 1
)
[1] => Edge Object
(...)
...
)
In terms of the front-end results - I'm really only interested in the:
[childID] => A
[parentID] => C
[updated_at] =>
[created_at] =>
part of the object; only NOT in JSON; in plain text.
Related
I am trying to send a mail using the SendGrid PHP API library. It worked when I tried it yesterday but today the reponse just has zero information:
SendGrid\Response Object
(
[statusCode:protected] => 0
[body:protected] =>
[headers:protected] => Array
(
[0] =>
)
)
The following object is being used in the \SendGrid\SendGrid()->send() method:
SendGrid\Mail\Mail Object
(
[from:SendGrid\Mail\Mail:private] => SendGrid\Mail\From Object
(
[name:SendGrid\Mail\EmailAddress:private] => test1
[email:SendGrid\Mail\EmailAddress:private] => test#example.com
[substitutions:SendGrid\Mail\EmailAddress:private] =>
[subject:SendGrid\Mail\EmailAddress:private] =>
)
[subject:SendGrid\Mail\Mail:private] => SendGrid\Mail\Subject Object
(
[subject:SendGrid\Mail\Subject:private] => this is a test
)
[contents:SendGrid\Mail\Mail:private] => Array
(
[0] => SendGrid\Mail\Content Object
(
[type:SendGrid\Mail\Content:private] => text/html
[value:SendGrid\Mail\Content:private] =>
<h1>sending mails</h1>
)
)
[attachments:SendGrid\Mail\Mail:private] =>
[reply_to:SendGrid\Mail\Mail:private] =>
[personalization:SendGrid\Mail\Mail:private] => Array
(
[0] => SendGrid\Mail\Personalization Object
(
[tos:SendGrid\Mail\Personalization:private] => Array
(
[0] => SendGrid\Mail\To Object
(
[name:SendGrid\Mail\EmailAddress:private] => mr test
[email:SendGrid\Mail\EmailAddress:private] => testtest#example.com
[substitutions:SendGrid\Mail\EmailAddress:private] =>
[subject:SendGrid\Mail\EmailAddress:private] =>
)
)
[ccs:SendGrid\Mail\Personalization:private] => Array
(
[0] => SendGrid\Mail\Cc Object
(
[name:SendGrid\Mail\EmailAddress:private] =>
[email:SendGrid\Mail\EmailAddress:private] => testtest1#example.com
[substitutions:SendGrid\Mail\EmailAddress:private] =>
[subject:SendGrid\Mail\EmailAddress:private] =>
)
)
[bccs:SendGrid\Mail\Personalization:private] =>
[subject:SendGrid\Mail\Personalization:private] =>
)
)
)
Obviously I used correct addresses in the tos and ccs sections.
Is something wrong with the sent object?
Apart from the code if there are any other problems in sending mail the send-grid library remains silent without throwing any exceptions and just returns the response 0. I would suggest you to
visit this link
In php-http-client\lib create a folder Exception.
Copy lib/Exception/InvalidRequest.php into the folder.
Modify lib/Client.php
These modifications are to throw appropriate exceptions which will help you to find what could be the problem in your case and be able to take it further.
Array from collection looks like this.
$result = $collection->find();
Array
(
[0] => Array
(
[_id] => MongoDB\BSON\ObjectId Object
(
[oid] => 5c52b90454851c44aa2987e2
)
[name] => Array
(
[date] => 2019-01-31 10:59:48
[value] => DESKTOP-TODTF5E
)
[network_addresses] => Array
(
[0] => Array
(
[ip_1] => 12.21.134
[ip_2] => 50
[mac] => xx:xx:xx:xx:xx:xx
)
[1] => Array
(
[ip_1] => 192.168.0
[ip_2] => 2
[mac] => yy:yy:yy:yy:yy:yy
)
)
)
)
I can find if some mac exist in specific row of sub array like this:
$result = $collection->find(["network_addresses.0.mac" =>
"xx:xx:xx:xx:xx:xx"]);
But I need to check if certain mac exists in any row of subarray, so instead of row index 0 I need to put some asterix or something.
How to do that ?
$query = (new Query)->select(["name"])
->from(['db_name','collection_name'])
->where(["network_addresses" => [ '$elemMatch' =>['mac' => "xx:xx:xx:xx:xx:xx"]]]);
$results = $query->all();
I have response and I want to fetch referenceId from it, the response is
Application_Model_User Object
(
[_data:protected] => Array
(
[id] => 2
[email] => test#gmail.com
[password] => ef1dca60798e10a51e3b6201ae7c40fbe2a10887
[salt] => 87fc83906190d1e29b60c5813065af068e16459d
[name] => test
[creationDate] => 2011-07-05
[lastTimeStamp] => 2016-06-03 09:13:53
[enabled] => 1
[loginHash] =>
[employeeNumber] => 0007
[userphoneNumber] => +546546546545
[jobTitle] => Business Manager
)
[_references:protected] => Array
(
[role] => Array
(
[referenceClass] => Application_Model_Role
[referenceId] => 4
[mapperClass] => Application_Model_RoleMapper
[mapper] =>
)
[organisation] => Array
(
[referenceClass] => Application_Model_Organisation
[referenceId] => 1
[mapperClass] => Application_Model_OrganisationMapper
[mapper] =>
)
)
)
How can I fetch ?
In .phtml file in ajax after
success: function(response){
var data = jQuery.parseJSON(response);
for (var i in data)
{
var referenceId = data[i]['referenceId'];
}
}
You can use a getter. You can create a method to return the referenceId.
I've extended ExtendedFileUtilityProcessDataHookInterface and created a hook for FAL file upload field.
class tx_bibusdocuments_fileUploadHook implements TYPO3\CMS\Core\Utility\File\ExtendedFileUtilityProcessDataHookInterface {
public function processData_postProcessAction($action, array $cmdArr, array $result, \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility $parentObject){}
}
When I print the "$result" array, I got an array like this;
Array
(
[0] => Array
(
[0] => TYPO3\CMS\Core\Resource\File Object
(
[metaDataLoaded:protected] =>
[metaDataProperties:protected] => Array
(
)
[indexingInProgress:protected] =>
[updatedProperties:protected] => Array
(
)
[indexerService:protected] =>
[properties:protected] => Array
(
[size] => 198218
[modification_date] => 1408449118
[creation_date] => 1408449118
[mime_type] => application/pdf
[name] => HomeTest.pdf
[identifier] => /user_upload/test.pdf
[identifier_hash] => 2bc8d0c4ed9f8a87fb9913af5dcd3977e0102027
[storage] => 1
[folder_hash] => e32a309fabc28dd85f053b65c5bd0da99860eb02
[type] => 5
[sha1] => 8a46595222d30c9cb4bcc48a4901d3e0f05e25ad
[extension] => pdf
[missing] => 0
[uid] => 139856
)
)
)
)
How can I get uid and name of the file from this $result array?
We can iterate the result array like this way;
public function processData_postProcessAction($action, array $cmdArr, array $result, \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility $parentObject){
$files = array_pop( $result );
if ( !is_array( $files ) ) {
return;
}
foreach ( $files as $file ) {
$fileUid .= $file->getUid(); // Uid of the file
$fileName .= $file->getName(); // Name of the file
}
}
I want to Search a value in an array Like
`[_id] => MongoId Object (
[$id] => 511f4ce622efc34f15000001
)
[metadata] => Array (
[filename] => 6410-funny_face.gif
[parrent] => myfolder/newfolder2
[user] => Array ( >>>>>>>> i need to fetch all users
[root] => 7
[admin] => 7
[user] => 0
)
[group] => Array (
[23] => 2
)
)
[filename] => 6410-funny_face.gif
[uploadDate] => MongoDate Object (
[sec] => 1361005798
[usec] => 799000
)
[length] => 3083
[chunkSize] => 262144
[md5] => eb3846f78f461165e5bf59a05707edd1`
I need to find the user's key and value in PHP or MongoShell
im using db.collection.find(array(metadata.filename: 6410-funny_face.gif)); gives the correct answer but while in finding db.collection.find(array(metadata.user: array(7)));
db.collection.find({"metadata.user.root":7})
This should work if I understand your question.