Hy guys...
I need some help...
In an object i have
$this->data as array of mysql query results(see example)
and a function in_multi_array( ) which isn't important.It just seraches for
$needle in a multidimensiona l array and returns bool
I have also these functions in an object
function &getID($need le)
{
foreach($this->data as $key=>$value)
if(in_array($ne edle,$value))
return $key;
}
function &getByValue($ne edle)
{
if($this->in_multi_array ($needle,$this->data))
{
$id=$this->getID($needle) ;
$array=$this->data[$id];
}
return $array;
}
When you call $sample=$object->getByValue("so mething") and if "something" is
a result of a query (any field) then you get all the fields that belong to
that result in array
example:
DataBase:
id | name | lastname
--------------------------------------
1 John Smith
2 Mark Jones
3 George Burchnall
query="SELECT id,name,lastnam e FROM people"
after everything....
$this->data will be:
[data] => Array
(
[0] => Array
(
[id] => 1
[name] => John
[lastname] => Smith
)
[1] => Array
(
[id] => 2
[name] => Mark
[lastname] => Jones
)
[2] => Array
(
[id] => 3
[name] => George
[lastname] => Burchnall
)
and when I call $sample=$object->getByValue("Ma rk")
$sample will be array (
[id] => 2
[name] => Mark
[lastname] => Jones
)
How can I get multiple results back if I have more than one "Mark" in DB
I would like then that $sample would be [0] for this Mark we just retreived
and [1] for second and so on so on...
I think I made my self clear :))
Thanx for the help....
I need some help...
In an object i have
$this->data as array of mysql query results(see example)
and a function in_multi_array( ) which isn't important.It just seraches for
$needle in a multidimensiona l array and returns bool
I have also these functions in an object
function &getID($need le)
{
foreach($this->data as $key=>$value)
if(in_array($ne edle,$value))
return $key;
}
function &getByValue($ne edle)
{
if($this->in_multi_array ($needle,$this->data))
{
$id=$this->getID($needle) ;
$array=$this->data[$id];
}
return $array;
}
When you call $sample=$object->getByValue("so mething") and if "something" is
a result of a query (any field) then you get all the fields that belong to
that result in array
example:
DataBase:
id | name | lastname
--------------------------------------
1 John Smith
2 Mark Jones
3 George Burchnall
query="SELECT id,name,lastnam e FROM people"
after everything....
$this->data will be:
[data] => Array
(
[0] => Array
(
[id] => 1
[name] => John
[lastname] => Smith
)
[1] => Array
(
[id] => 2
[name] => Mark
[lastname] => Jones
)
[2] => Array
(
[id] => 3
[name] => George
[lastname] => Burchnall
)
and when I call $sample=$object->getByValue("Ma rk")
$sample will be array (
[id] => 2
[name] => Mark
[lastname] => Jones
)
How can I get multiple results back if I have more than one "Mark" in DB
I would like then that $sample would be [0] for this Mark we just retreived
and [1] for second and so on so on...
I think I made my self clear :))
Thanx for the help....
Comment