[PHP] Question about sqli class

2007-12-30 Thread alvaro
I don´t know if this is the correct place to ask this questions but I haver 
some doubts about using mysqli class in php. I am designing a web place using 
wamp2 (php5, mysql 5.0.x ). My databases have been done using phpmyadmin so 
they are "normal" mysql, I mean that I have done nothing with SQLITE. On the 
other hand, I am accessing to my databases and tables using mysqli class and 
methods  for example:
$conn = new mysqli ( ..)  (this is what I am using)
I am using that because I read in the internet that mysqli methods where more 
efficient but I don´t know if it´s correct to use that methods with my mysql 
database (it runs perfect).

so... is it correct?  supposing that it´s correct to use it..is it faster 
and better to use mysqli methods than using the functions that were used before 
these new classes appeared?

thanks...

my email is:
[EMAIL PROTECTED]

[PHP] php and var statics

2003-08-26 Thread Alvaro Martinez
I have written this code:

class db{
   var $_miInstancia;

   function db (){
  // funcion que se conecta con la BBDD
 static $miInstancia;
 $this->_miInstancia=&$miInstancia;

 $result = @mysql_pconnect("inforalv", "discoteca", "password");
 if (!$result)
   return false;
 if ([EMAIL PROTECTED]("discoteca"))
   return false;
   }

function getInstancia(){
   if (!isset($this))
  $_miInstancia=new db();
   return $_miInstancia;
}
}

This is a Singleton Pattern, but it doesnt work.
I want to obtain only one instance of db class but when I do this...:

   $conexiondb=db::getInstancia();
   $conexiondb=db::getInstancia();

In the two calls I get a new db object.
Could you please tell me if there is anything wrong?

Thanks.

alvaro

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: php and var statics

2003-08-26 Thread Alvaro Martinez
Ok,
I correct the two mistakes but it doesnt works yet.
What is character & for?

Alvaro
- Original Message - 
From: "Greg Beaver" <[EMAIL PROTECTED]>
To: "Alvaro Martinez" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, August 26, 2003 3:58 PM
Subject: Re: php and var statics




Alvaro Martinez wrote:
> I have written this code:
>
> class db{
>var $_miInstancia;
>
>function db (){
>   // funcion que se conecta con la BBDD
>  static $miInstancia;
>  $this->_miInstancia=&$miInstancia;
>
>  $result = @mysql_pconnect("inforalv", "discoteca",
"password");
>  if (!$result)
>return false;
>  if ([EMAIL PROTECTED]("discoteca"))
>return false;
>}
>
> function getInstancia(){
>if (!isset($this))
>   $_miInstancia=new db();
>return $_miInstancia;
> }
> }
>
> This is a Singleton Pattern, but it doesnt work.
> I want to obtain only one instance of db class but when I do this...:
>
>$conexiondb=db::getInstancia();
>$conexiondb=db::getInstancia();
>
> In the two calls I get a new db object.
> Could you please tell me if there is anything wrong?

two mistakes - you need to use &, and the static var must be in
getInstancia()

function &getInstancia(){
 static $miInstancia;
 if (!get_class($miInstancia) == 'db') {
 $miInstancia = &new db();
 }
 return $miInstancia;
}

$conexiondb = &db::getInstancia();

Regards,
Greg
--
http://www.phpdoc.org
phpDocumentor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] var static

2003-08-28 Thread Alvaro Martinez
I want to obtain only one instance of one class. In other to do that, I call
to a static method, that creates the instance(if it doesnt exit) or returns
the reference of the instance.
The call to the static method is the next:

   $conexiondb=db::getInstancia();

Well, but if I call to db::getInstancia() another time, I obtain another new
object  :-(

The code of the db class is the next (it is a Singleton Pattern, but it
doesnt work)

class db{
   var $_miInstancia;

   function db (){
  // funcion que se conecta con la BBDD
 static $miInstancia;
 $this->_miInstancia=&$miInstancia;

 $result = @mysql_pconnect("inforalv", "discoteca", "password");
 if (!$result)
   return false;
 if ([EMAIL PROTECTED]("discoteca"))
   return false;
   }

&function getInstancia(){
   if (!isset($this))
  $_miInstancia=new db();
   return $_miInstancia;
}
}

I think that the problem is that the var _miInstance is not static and I
dont know how to do it.
Could you please tell me if there is anything wrong?

Thanks.

Alvaro

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] var static

2003-08-28 Thread Alvaro Martinez
I want to obtain only one instance of one class. In other to do that, I call
to a static method, that creates the instance(if it doesnt exit) or returns
the reference of the instance.
The call to the static method is the next:

   $conexiondb=db::getInstancia();

Well, but if I call to db::getInstancia() another time, I obtain another new
object  :-(

The code of the db class is the next (it is a Singleton Pattern, but it
doesnt work)

class db{
   var $_miInstancia;

   function db (){
  // funcion que se conecta con la BBDD
 static $miInstancia;
 $this->_miInstancia=&$miInstancia;

 $result = @mysql_pconnect("inforalv", "discoteca", "password");
 if (!$result)
   return false;
 if ([EMAIL PROTECTED]("discoteca"))
   return false;
   }

&function getInstancia(){
   if (!isset($this))
  $_miInstancia=new db();
   return $_miInstancia;
}
}

I think that the problem is that the var _miInstance is not static and I
dont know how to do it.
Could you please tell me if there is anything wrong?

Thanks.

Alvaro

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] var static

2003-08-28 Thread Alvaro Martinez
I've found the solution myself.
The db class is the next:

class db{

function db (){
// funcion que se conecta con la BBDD
$result = @mysql_pconnect("inforalv", "discoteca", "password");
if (!$result)
return false;
if ([EMAIL PROTECTED]("discoteca"))
return false;
}

function &getInstancia(){
static $miInstancia;
if (!get_class($miInstancia) == 'db')
$miInstancia=new db();
return $miInstancia;
}


and the call to this class is the next:

$conexiondb1=&db::getInstancia();
$conexiondb2=&db::getInstancia();

In the second call I obtain the same object.

Muchas gracias por vuestra ayuda

Alvaro

"Dynamical.Biz" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]

Although PHP supports static variables in functions (see here), it has no
support for static variables in classes.
http://www.php.net/manual/en/language.variables.scope.php

(espero que te sirva)


saludos

aniceto lópez :: DYNAMICAL.BIZ
web development & host services
Barcelona - Spain




-Mensaje original-
Asunto: [PHP] var static


I want to obtain only one instance of one class. In other to do that, I call
to a static method, that creates the instance(if it doesnt exit) or returns
the reference of the instance.
The call to the static method is the next:

   $conexiondb=db::getInstancia();

Well, but if I call to db::getInstancia() another time, I obtain another new
object  :-(

The code of the db class is the next (it is a Singleton Pattern, but it
doesnt work)

class db{
   var $_miInstancia;

   function db (){
  // funcion que se conecta con la BBDD
 static $miInstancia;
 $this->_miInstancia=&$miInstancia;

 $result = @mysql_pconnect("inforalv", "discoteca", "password");
 if (!$result)
   return false;
 if ([EMAIL PROTECTED]("discoteca"))
   return false;
   }

&function getInstancia(){
   if (!isset($this))
  $_miInstancia=new db();
   return $_miInstancia;
}
}

I think that the problem is that the var _miInstance is not static and I
dont know how to do it.
Could you please tell me if there is anything wrong?

Thanks.

Alvaro

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] open php from

2003-08-29 Thread Alvaro Martinez
Hi!
I'm a beginner. I want to redirect from one php page to another php page and
I dont know what method to use.
How can I do it?
Thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] open php from

2003-08-29 Thread Alvaro Martinez
Thank you to you them all

"Curt Zirzow" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
* Thus wrote Jonathan Pitcher ([EMAIL PROTECTED]):
> Alvaro,
>
> To redirect use the header function (http://www.php.net/header)
>
> The call would be something like:
>
> header("Location: anotherpage.php");

I'd like to add that the location MUST be an absolute url. ie:
  Location: http://host.com/anotherpage

Even if its on the same server.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problem with PHP 4.0.5

2001-05-07 Thread Alvaro Collado

I have installed PHP4.0.5 in a Red Hat Linux 6.0 with Apache.
When I run the test no problem, all is OK, but when I run a html index file in 
Netscape ( LocalHost )
whith a single code like this 

 

nothing was display, nothing.

When I change the code for an know error for example  Netscape prints the full 
text of the tag
"" .

Please help me.

Thanks




[PHP] Problem with PHP 4.0.5

2001-05-07 Thread Alvaro Collado


Mr . John Vanderbeck

None of both codes works, all this test were do.
The Netscape ingnore all the tags with \n";
?>

Some systems are configured to not allow the shorthand "http://gamedesign.incagold.com/)
- GameDesign, the industry source for game design and development issues





Re: [PHP] Variables not working!

2004-01-28 Thread Alvaro Zuniga
Try this for a generic fix if it is the globals issue:

Place this somewhere to set to TRUE or FALSE when needed

$GLOBAL_FIX  = TRUE;

use an include on every script:

if($GLOBAL_VARS_FIX) {
   if( phpversion() >= '4.2.0' ) {
  extract($_POST);
  extract($_GET);
  extract($_SERVER);
  extract($_ENV);
  extract($_COOKIE);
   }
}
---
Alvaro Zuniga
Information Technology Professional
(337) 654 6515
www.zunitek.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Question

2003-07-11 Thread Alvaro Rosales R.
Hi guys,I am new to PHP and I am writing my forst scripts, so maybe this quesetion 
is a kinda stupid, but it is driving me crazy,  can you tell meHow can I set a line 
break in long line of my code?.
thanks in advance!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Long lines

2003-07-11 Thread Alvaro Rosales R.
Hi guys,I am new to PHP and I am writing my first scripts, so maybe this question 
is a kinda stupid, but it is driving me crazy,  can you tell me How can I set a line 
break in longs line of my code?.
thanks in advance!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php