Bueno.......ahora
FUNCIONA... solo arreglando la consulta pero
no entiendo lo de porque singular() debe ser un metodo estatico (?)
Me podrian hechar luz al respecto ? como seria? no hago el NEW al final del metodo ?
Dejo el codigo "completo" (lo que hice hasta ahora)... a ver si me orientan:
Código PHP:
<?
Include('adodb5/adodb.inc.php');
$con= NewADOConnection('mysql');
$con->connect('localhost', 'root', '','diccio');
$con->debug=true;
$pal = new word('seriales');
$pal->setCon ($con); // necesaria para acceder a 'diccionarios'
echo $pal->singular();
var_dump ($pal->is_warez());
//////////////////////////////////////
class Word {
private $word=NULL;
private $con; // conexion a la DB
private $plural;
public function is_warez(){
$sql = "SELECT type FROM dicx WHERE word='{$this->word}' and type='w'";
$rs = $this->con->execute ($sql);
if ($rs->RecordCount()!=0){
return TRUE;
}else{
if ($this->plural){
$word2 = self::singular()->getWord();
}else{
$word2 = self::plural()->getWord();
}
$sql = "SELECT type FROM dicx WHERE word='{$word2}' and type='w'";
$rs = $this->con->execute ($sql);
return ($rs->RecordCount()!=0);
}
}
public function is_common(){ // la,las,para,con,contra,...
}
// devuelve el singular (singulariza)
public function singular (){
if ($this->word[strlen($this->word)-1]=='s'){
if ($this->word[strlen($this->word)-2]=='e'){ // -es
$wordm = substr ($this->word,0,-2);
}else{
$wordm = substr ($this->word,0,-1); // -s
}
}
//if (strlen ($wordm)==0){
//$wordm=$this->word;
//}
$nw = new word($wordm);
return $nw;
}
// devuelve el plural (pluraliza)
public function plural (){
if ($this->is_vowel($this->word[strlen($this->word)-1])){
$wordm = $this->word . 's';
}else{
$wordm = $this->word .'es';
}
$nw = new word($wordm);
return $nw;
}
// dice si es vocal
private function is_vowel ($char){
if (strlen($char)==1){
$vocales = str_split('aeiouáéíóú'); // comparar en minusculas
$out = (in_array($char,$vocales));
}else{
$out=FALSE; // tambien podria generar una excepcion
}
return $out;
}
public function define_if_its_plural(){
$this->plural = ( ($this->word[strlen($this->word)-1]=='s') and (strlen($this->word)>=3)) ;
}
// devuelve si es plural
public function is_plural (){
return $this->plural ;
}
public function is_singular (){
return (!$this->plural);
}
public function setWord($w){
$this->word=$w;
}
public function getWord(){
return $this->word;
}
public function setCon ($con){
$this->con=$con;
}
public function __tostring(){
return $this->word;
}
public function __construct ($w=NULL){
$this->word = $w;
$this->define_if_its_plural();
}
} #fin de clase