Doctrine repository findOneBy print sql. why? how can I disable this? - codeigniter

$rep = $em->getRepository('Entities\User');
$user = $rep->findOneBy(array('email'=>'d*****e#s*****o.com'));
print output:
SELECT t0.uid AS uid1, t0.email AS email2, t0.password AS password3, t0.name AS name4, t0.surname AS surname5, t0.matrikel AS matrikel6, t0.status AS status7, t0.registration_time AS registration_time8, t0.gid AS gid9 FROM user t0 WHERE t0.email = ? LIMIT 1 array(1) { [0]=> string(21) "d*****e#s*****o.com" } array(1) { [0]=> string(6) "string" }
I just wanna the entity, not print output. Where can I disable this?

You probably have the Echo SQL Logger enabled. Turn it off.

Related

Laravel query showing different Result in DB::Table and DB::Select with inner join

I'm using 3 table
1.organizations
2.users
3.organization_user
So the organization_user is the pivot table for getting org. and user.
DB::select("SELECT users.name 'User Name',organizations.name 'Org Name'
FROM users INNER JOIN organization_users ON
organization_users.user_id=users.id
INNER JOIN organizations ON
organizations.id=organization_users.organization_id
WHERE organization_users.organization_id=$org_id");
And getting the below result
[
{
"User Name": "Navid Anjum",
"Org Name": "org1"
},
{
"User Name": "kamal",
"Org Name": "org1"
} ]
But when using
DB::table('organization_users')
->join('users','users.id','=','organization_users.user_id')
->join('organizations','organizations.id','=',
'organization_users.organization_id')
->select('users.name as Name','organizations.name as Org Name')
->where('organization_users.id','=',$org_id)
->get();
And getting the below result
[
{
"Name": "Navid Anjum",
"Org Name": "org1"
} ]
So What I'm doing wrong?
you not set the right id for organization_users in the second statement :
DB::table('organization_users')
->join('users','users.id','=','organization_users.user_id')
->join('organizations','organizations.id','=',
'organization_users.organization_id')
->select('users.name as Name','organizations.name as Org Name')
->where('organization_users.organization_id','=',$org_id)
->get();

Mail merge template : local variable not getting value in if..else

{ MERGEFIELD TableStart:Test}{ SET PLAN {MERGEFIELD Name}="XYZ" "1" "0"}}
{ MERGEFIELD TableEnd:Test }
{ IF { REF PLAN } = "1" "Pass" "Fail"}
In this example always getting result Fail, whether Name is "XYZ" or not.
can anyone suggest further ?
In your case in the SET field you should use IF field to evaluate condition. Please see the following field codes:
{ SET PLAN { IF {MERGEFIELD Name} = XYZ "1" "0"} }
{ IF { REF PLAN } = "1" "Pass" "Fail" }
After executing simple mail merge using the following code:
Document doc = new Document(#"C:\Temp\in.docx");
doc.MailMerge.Execute(new string[] { "Name" }, new string[] { "XYZ" });
doc.Save(#"C:\Temp\out.docx");
The resulting document has the following field codes:
{ SET PLAN XYZ = XYZ "1" "0"} }
{ IF { REF PLAN } = "1" "Pass" "Fail" }
which is properly evaluated with "Pass" text.
Also in MS Word document field whitespaces matters. See the screenshot from MS Word document on my side

Get single data from session array - CodeIgniter

I want to get single value from the flashdata array in the view which is sent from the controller.
controller:
$post=array(
'author_id'=>$this->input->post('author'),
'title'=>$this->input->post('post_title'),
'subtitle'=>$this->input->post('post_subtitle'),
'post'=>$this->input->post('textarea1'),
'image'=>$this->upload->file_name,
);
$this->session->set_flashdata('postdata',$post);
view
<?php var_dump($this->session->flashdata('postdata'))?>
The above gave me the following result.
array(5) { ["author_id"]=> string(1) "6" ["title"]=> string(3) "uyk" ["subtitle"]=> string(26) "Full-Stack Web Development" ["post"]=> string(1) "u" ["image"]=> string(0) "" }
How can I get only single value like title or subtitle?
What about this $this->session->userdata['postdata']['title']

How to separate values in a variable in powershell?

This may sound like a stupid question, but I am trying to separate the values in a variable so that I can cross compare them with another variable to decide what to do within an if statement.
Basically, I want to take the beginning letter of a users username, whatever letter that is, will then be compared to both variable to decide what action to take. So for example if the username is "Josh" the message "Home2" should appear. I'm not sure whether what I'm trying to achieve is possible but any help is appreciated.
$UserName = $env:username
$HomeDriveLetterAK = "\\charlie\home_A-K\$Username"
$HomeDriveLetterAK = "\\charlie\home_L-Z\$Username"
$Home1 = "A, B, C, D, E, F"
$Home2 = "H, I, J, K, L, M"
If ($username.StartsWith($Home1, 1))
{
[System.Windows.Forms.MessageBox]::Show("Home1" , "Status" , 'OK', 'error')
}
ElseIf ($username.StartsWith($Home2, 1))
{
[System.Windows.Forms.MessageBox]::Show("Home2" , "Status" , 'OK', 'error')
}
Alternatively, you can use a Switch:
$username = "John"
Switch -Wildcard ( $username[0] )
{
'[A-F]' { [System.Windows.Forms.MessageBox]::Show("Home1" , "Status" , 'OK', 'error') }
'[G-M]' { [System.Windows.Forms.MessageBox]::Show("Home2" , "Status" , 'OK', 'error') }
'[N-S]' { [System.Windows.Forms.MessageBox]::Show("Home3" , "Status" , 'OK', 'error') }
'[T-Z]' { [System.Windows.Forms.MessageBox]::Show("Home4" , "Status" , 'OK', 'error') }
Default { Write-Output 'Unable to determine "Home" for this user.'}
}
First, make $Home1 & $Home2 arrays, not CSV strings. I'll make parsing everything a lot easier. Then use the ToCharArray() method on the String object that is $username to get the first character, and the -contains operator to compare.
$Home1 = ("A","B","C","D","E","F")
$Home2 = ("H","I","J","K","L","M")
$FirstLetter = $username.ToCharArray()[0];
if ($Home1 -contains $FirstLetter) {
[System.Windows.Forms.MessageBox]::Show("Home1" , "Status" , 'OK', 'error');
} elseif ($Home2 -contains $FirstLetter) {
[System.Windows.Forms.MessageBox]::Show("Home2" , "Status" , 'OK', 'error');
}
BTW, you probably want to fix the variable name in this line too:
$HomeDriveLetterAK = "\\charlie\home_L-Z\$Username"

Using Codeigniter Payments

How to properly use the $this->payments->payment_action(); function?
All I get is this:
object(stdClass)#137 (5) {
["type"]=>
string(14) "local_response"
["status"]=>
string(7) "failure"
["response_code"]=>
string(3) "000"
["response_message"]=>
string(32) "The method called does not exist"
["details"]=>
string(27) "No further details provided"
}
As per the question, You are receiving some objects.
For ex: Here i'm just printing the object content. If you ant to store in db, then you can do with $obj.
$obj = $this->payments->payment_action();
echo "Type = ".$obj->type;
echo "Status= ".$obj->status;
echo "Response code= ".$obj->response_code;
echo "Response Message= ".$obj->response_message;
echo "Details= ".$obj->details;

Resources