|
Posted by ward on 05/11/06 15:52
Good morning Robert.
Well guess what, apparently the hosting company does have PEAR
installed and now I'll have to figure out how to use it.
I guess what gets me is (and it's a silly rhetorical question), why is
this so complicated? In my mind's eye, I see choosing the group_id(s)
and what fields I want displayed.
Then it's a matter of extracting the data within the array and running
the query. Then of course presenting the data.
I have some more research to do.
Thanks again for the assist.
Ward
On Wed, 10 May 2006 17:58:31 -0500, "robert"
<ab@no.spam-alama-ding-dong> wrote:
>| It appears as though I'm missing some components here such as
>| mdb.class.php. Is this from the PEAR???
>
>again, mdb.class.php is a ficticious name...i don't know what modules you
>have or what are required...i'm not at all a fan of pear.
>
>
>| The only other thing I see that I'm not that familar with is
>| db_dbArray. I can't find much when googled.
>
>i'll post a db class you can use...it will work out of the box with mysql
>(that is what you have, correct?) as long as you are using php 5...if not,
>well...
>
>
>| So perhaps I should start from scratch in hopes of solving this thing
>| without PEAR. Though from what I'm reading, using the PEAR is suppose
>| to make things "easier." I'm not sure if PEAR is installed on the
>| hosting company's server; I am trying to find out.
>
>well, what it is supposed to do and what it actually does are two different
>tales altogether...and yes, it is a pain in the ass when your isp doesn't
>have it installed nor wants it installed.
>
>
>
>| If I'm not mistaken, the following portion of my script creates two
>| arrays: sel_groups and sel_cols.
>|
>| Is this a true statement?
>
>it appears so...though i configure mine a bit differently:
>
><input name="sel_groups[<?= $id ?>]" type="checkbox" />
>
>and
>
><input name="sel_cols[<?= $name ?>]" type="checkbox" />
>
>
>
>
>==== free-bee
>
>useage:
>
><?
>require_once 'db.class.php';
>
>db::connect('localhost', 'user', 'password', 'sampleDb');
>
>$sql = "
> SELECT Foo
> FROM bar
> WHERE 1 = 1
> ";
>$records = db::execute($sql);
>foreach ($records as $record)
>{
> echo '<pre>' . $record['FOO'] . '</pre>';
>}
>?>
>
>==== db.class.php
>
><?
>class db
>{
> static private $_instance = null;
> static private $_lastStatement = '';
>
> private function __clone(){}
>
> private function __construct(){}
>
> static function connect($server, $user, $password, $catalog = null)
> {
> try
> {
> mysql_connect($server, $user, $password);
> if (!is_null($catalog)){ mysql_select_db($catalog); }
> } catch (exception $ex) {
> print "<pre>\r\n" . $ex->getMessage() . "\r\n" .
> ' in file ' . $ex->getFile() . "\r\n" .
> ' on line ' . $ex->getLine() . "\r\n" .
> '</pre>';
> return false;
> }
> return true;
> }
>
> static function getInstance()
> {
> if (is_null(self::$_instance)){ self::$_instance = new db(); }
> return self::$_instance;
> }
>
> static function getLastStatement(){ return self::$_lastStatement; }
>
> static function decode($string)
> {
> $translation = get_html_translation_table(HTML_ENTITIES);
> $translation = array_flip($translation);
> $string = strtr($string, $translation);
> return $string;
> }
>
> static function encode($string)
> {
> $translation = get_html_translation_table(HTML_ENTITIES);
> $string = strtr($string, $translation);
> return $string;
> }
>
> static function execute($sql, $decode = false, $returnNewId = false)
> {
> self::$_lastStatement = $sql;
> $array = array();
> $key = 0;
> $records = mysql_query($sql);
> $fieldCount = @mysql_num_fields($records);
> $translation = get_html_translation_table(HTML_ENTITIES);
> $translation = array_flip($translation);
> while ($row = @mysql_fetch_array($records, MYSQL_NUM))
> {
> for ($i = 0; $i < $fieldCount; $i++)
> {
> $value = $row[$i];
> if ($decode){ $value = strtr($value, $translation); }
> $array[$key][strtoupper(@mysql_field_name($records, $i))] = $value;
> }
> $key++;
> }
> if ($returnNewId)
> {
> $array = array();
> $array[0]['ID'] = mysql_insert_id();
> }
> @mysql_free_result($records);
> return $array;
> }
>
> static function prepare($string, $encode = false)
> {
> if ($encode){ $string = self::encode($string); }
> $string = stripslashes(str_replace("'", "''", $string));
> return $string;
> }
>}
>?>
>
Navigation:
[Reply to this message]
|