Bueno y con las dos clases siguientes si que me interesa obtener opiniones, pues las anteiores si que me han servido, espero puedan ver los resultados finales.
lo publico lo mas resumido posible para no alargar mucho, luego si alguno lo desea me envia un MP y se las mando al mail.
tengo algunas falencias y me interesaria lo probaran y aportaran informando como podrían ser mas optimas.
Código PHP:
<?php
final class MySqlCommand extends DbCommand {
/******************************************************/
/* Internal Member */
/******************************************************/
private $CommandText;
private $CommandType;
private $cnn;
/******************************************************/
/* Construct */
/******************************************************/
public function __construct($CommandText, $Connection) {
$this->set_CommandText( $CommandText );
$this->set_CommandType( CommandType::Text );
$this->set_Connection( $Connection );
}
/******************************************************/
/* Properties */
/******************************************************/
public function get_CommandText () {
return $this->CommandText;
}
public function set_CommandText ($value) {
$this->CommandText = $value;
}
public function get_CommandType () {
return $this->CommandType;
}
public function set_CommandType ($value) {
$this->CommandType = $value;
}
/******************************************************/
/* FUNCTIONS */
/******************************************************/
public function ExecuteNonQuery (){
switch( $this->get_CommandType() ) {
case CommandType::StoredProcedure:
//TODO: CreateParameters for this option
$StrSql = 'call ' . $this->get_CommandText(); //(p1,p2)
break;
case CommandType::TableDirect:
$StrSql = 'Select * From ' . $this->get_CommandText();
break;
case CommandType::Text:
$StrSql = $this->get_CommandText();
break;
}
$result = mysql_query( $StrSql, $this->get_Connection() );
if( $result ) {
return mysql_num_rows( $result );
}else{
return 0;
}
}
public function ExecuteScalar (){
$result = mysql_query( $this->get_CommandText() , $this->get_Connection() );
if( $result ) {
$row = mysql_fetch_row( $result );
return $row[0];
}else{
return 0;
}
}
public function ExecuteReader (){
switch( $this->get_CommandType() ) {
case CommandType::StoredProcedure:
//TODO: CreateParameters for this option
$StrSql = 'call ' . $this->get_CommandText(); //(p1,p2)
break;
case CommandType::TableDirect:
$StrSql = 'Select * From ' . $this->get_CommandText();
break;
case CommandType::Text:
$StrSql = $this->get_CommandText();
break;
}
$result = mysql_query( $StrSql, $this->get_Connection() );
if( $result ) {
return $result;
}else{
return 0;
}
}
}
?>
Saludos a todos.