[ previous ] [ next ] [ threads ]
 To :  yate@v...
 From :  Monica Tepelus <monica@v...>
 Subject :  Re: [yate] Re :Re: [yate] Execute Postgresql Query on Ext Module (php)
 Date :  Mon, 11 Dec 2017 16:48:14 +0200
Hi,

You can't use yate's database connection from php.  If you want to use 
php, then you need to create a connection from the script.

You could use yate's database connection if you switch to javascript.

Regards,
Monica Tepelus

On 10/07/2017 12:22 AM, Ganapathi Chidambaram wrote:
> Hi
>
> Please find the mentioned below complete script for the same.
>
> And reason why am not using ,i don't want to create multiple 
> connection and mentioning credentials opened on multiple area. And 
> also i except the Query to logged on log file of yate.
>
>
> #!/usr/bin/php -q
>  require_once("libyate.php");
> Yate::Init();
>
> Yate::Output(true);
>
> Yate::Debug(true);
> Yate::SetLocal("trackparam","call_handle.php");
>
> Yate::Install("call.route",80);
>
> for (;;) {
>     $ev=Yate::GetEvent();
>          if ($ev === false)
>                 break;
>
>          if ($ev === true) {
>                 continue;
>             }
>
>         switch ($ev->type) {
>
>            case "incoming":
>  if(check_local($ev->params["caller"]));
>                            $ev->params["type"]='int';
>                         $ev->Acknowledge();
>                 break;
>         }
> }
>
> function check_local_user($num)
> {
> $m = new Yate("database");
> $m->account = "db";
> $m->query = "SELECT num from users where num = '$num'";
> $m->Dispatch();
> if( $m->rows > 0 ) return true;
>
> }
>
> Regards,
> Ganapathi
> +91-9500197700  | ganapathi.rj@g... 
> 
>
>
> From : Jamie Gordon 
> TO : Yate mailing list 
> Sent : Sat, Oct 7, 2017 02:41 AM,
> Subject: Re: [yate] Execute Postgresql Query on Ext Module (php )
>
> Hi Ganapathi,
> Without seeing the rest of your script, which may explain the reason ...
>
> why not use the standard PHP database tools instead of involving YATE ?
> For example PDO ?
>
>
>
>
>
> On 06/10/2017 21:35, Ganapathi Chidambaram wrote:
>> Hi
>>
>> As i am trying to execute the PostgreSQL Query on external 
>> script(php) like mentioned below. But it doesn't look like executing 
>> as per the flow/logging.
>>
>> PHP :
>>
>> $m = new Yate("database");
>> $m->account = "db";
>> $m->query = "SELECT num from users where num = '$num'";
>> $m->Dispatch();
>> if( $m->rows > 0 ) return true;
>>
>>
>> Regards,
>> Ganapathi
>>
>>
>
> -- 
>
>
> Jamie Gordon
>
> Office: +44 (0)330 3310810
> Mobile: +44 (0)781 7639737
> http://www.digitallines.net
>
>
>
> Digital Lines Limited's registered office is Snappers, Church Road, Rudgeway, Bristol BS35 3SH. Registered in England, number 05293518
>
> ***************************************************************************************************************
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify the system manager.





  
    
  
  
    Hi,

You can't use yate's database connection from php.  If you want to use php, then you need to create a connection from the script.

You could use yate's database connection if you switch to javascript.

Regards,
Monica Tepelus

On 10/07/2017 12:22 AM, Ganapathi Chidambaram wrote:
Hi

Please find the mentioned below complete script for the same.

And reason why am not using ,i don't want to create multiple connection and mentioning credentials opened on multiple area. And also i except the Query to logged on log file of yate.


#!/usr/bin/php -q
<?php
require_once("libyate.php");
Yate::Init();

Yate::Output(true);

Yate::Debug(true);
Yate::SetLocal("trackparam","call_handle.php");

Yate::Install("call.route",80);

for (;;) {
    $ev=Yate::GetEvent();
         if ($ev === false)
                break;

         if ($ev === true) {
                continue;
            }

        switch ($ev->type) {

           case "incoming":
                         if(check_local($ev->params["caller"]));
                           $ev->params["type"]='int';
                        $ev->Acknowledge();
                break;
        }
}

function check_local_user($num)
{
$m = new Yate("database");
$m->account = "db";
$m->query = "SELECT num from users where num = '$num'";
$m->Dispatch();
if( $m->rows > 0 ) return true;

}

Regards,
Ganapathi


From : Jamie Gordon <jamie@d...>
TO : Yate mailing list <yate@v...>
Sent : Sat, Oct 7, 2017 02:41 AM,
Subject: Re: [yate] Execute Postgresql Query on Ext Module (php )

Hi Ganapathi,
Without seeing the rest of your script, which may explain the reason ...

why not use the standard PHP database tools instead of involving YATE ?
For example PDO ?





On 06/10/2017 21:35, Ganapathi Chidambaram wrote:
Hi

As i am trying to execute the PostgreSQL Query on external script(php) like mentioned below. But it doesn't look like executing as per the flow/logging.

PHP :

$m = new Yate("database");
$m->account = "db";
$m->query = "SELECT num from users where num = '$num'";
$m->Dispatch();
if( $m->rows > 0 ) return true;


Regards,
Ganapathi



-- 


Jamie Gordon

Office: +44 (0)330 3310810
Mobile: +44 (0)781 7639737
http://www.digitallines.net



Digital Lines Limited's registered office is Snappers, Church Road, Rudgeway, Bristol BS35 3SH. Registered in England, number 05293518

***************************************************************************************************************
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify the system manager.